1
a = array([[2*R0*(Q0**2), 2*R1*(Q1**2), 2*R2*(Q2**2), 2*R3*(Q3**2), 2*R4*(Q4**2), 0, 0, 0],
       [0, 0, 0, 2*R3*(Q3**2), 2*R4*(Q4**2), 0, 0, 0], [0, 2*R1*(Q1**2),0, 0, 0,  2*R5*(Q5**2), 2*R6*(Q6**2), 2*R7*(Q7**2)], [1, 1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]])

b = array([[95-(R0*(Q0**3))-(R1*(Q1**3))-(R2*(Q2**3))-(R3*(Q3**3))-(R4*(Q4**3))], [-(R4*(Q4**3))-(R3*(Q3**3))],
        [-(R6*(Q6**3))-(R7*(Q7**3))-(R1*(Q1**3))-(R5*(Q5**3))], [-Q0+Q1+Q6], [0.6-Q1+Q2+Q5], [-Q2+Q3+Q4], [1.4-Q7-Q5], [Q7-Q6]])

p = solve(a, b)

print ("deltaQ:", p)

Solve (a,b) is a gauss jordan elimination function that solves linear equations where R0-R7 AND Q0-Q7 ARE CONSTANTS! It works with other matrices, however for this one i get an error.

1
  • Maybe a = np.matrix(a) and b=np.matrix(b) Commented Jul 7, 2017 at 8:52

2 Answers 2

1

the array a doesn't have consistent rows hence numpy initializes the array as 1D array holding different "objects" instead of 2D array.

>>>> print(a.dtype)
object

Hence the error complaining about not having 2D array but only 1D.

Sign up to request clarification or add additional context in comments.

Comments

0

When I faced this issue, it was regarding eigen vector generation for a laplacian matrix which was a sparse matrix. I had to use laplacian_matrix.todense() function( laplacian_matrix is from package networkx) and the exception got resolved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.