P
Pramod
Hi Friends
When run the below program in python i got error like this ,
Matrix
[[ 8 -6 2]
[-4 11 -7]
[ 4 -7 6]]
row vecotr X
[[ 28 -40 33]]
Traceback (most recent call last):
File "solve.py", line 16, in <module>
print A*B
File "/usr/lib/python2.6/dist-packages/numpy/core/defmatrix.py",
line 290, in __mul__
return N.dot(self, asmatrix(other))
ValueError: objects are not aligned
#!/usr/bin/python
N=3
from numpy import linalg
from numpy import matrix
fr=open('mat.txt','r')
A=matrix([[int(fr.readline()) for j in range(N)]for i in range(N)])
B=matrix([[int(fr.readline())for j in range(N)]])
print 'Matrix \n',A
print 'row vecotr X\n',B
#A=matrix([[3,4],[5,2]])
#B=matrix([[11],[9]])
print A*B
#y=linalg.solve(A,B)
#print 'Solution vectoris \n',y
The input file is
8
-6
2
-4
11
-7
4
-7
6
28
-40
33
please try to fix the error in the program
Thankx in advance
When run the below program in python i got error like this ,
Matrix
[[ 8 -6 2]
[-4 11 -7]
[ 4 -7 6]]
row vecotr X
[[ 28 -40 33]]
Traceback (most recent call last):
File "solve.py", line 16, in <module>
print A*B
File "/usr/lib/python2.6/dist-packages/numpy/core/defmatrix.py",
line 290, in __mul__
return N.dot(self, asmatrix(other))
ValueError: objects are not aligned
#!/usr/bin/python
N=3
from numpy import linalg
from numpy import matrix
fr=open('mat.txt','r')
A=matrix([[int(fr.readline()) for j in range(N)]for i in range(N)])
B=matrix([[int(fr.readline())for j in range(N)]])
print 'Matrix \n',A
print 'row vecotr X\n',B
#A=matrix([[3,4],[5,2]])
#B=matrix([[11],[9]])
print A*B
#y=linalg.solve(A,B)
#print 'Solution vectoris \n',y
The input file is
8
-6
2
-4
11
-7
4
-7
6
28
-40
33
please try to fix the error in the program
Thankx in advance