| 1 | initial version |
Hello
Of course you can not multiply 1x1 matrices with a 3x1 matrix... You should use vectors instead of matrix columns (they are considered as the same time as row and column vector and hence no need to transpose). The following works
B = Matrix([[-1,0,1], [0,-1,1], [1,0,1], [0,1,1], [-1,0,1]])
A = B.transpose()*B
c = vector([0,0,2,2,0]) # <- changed to vector
b = B.transpose()*c
x = vector([1,0,1]) # <- changed to vector
r = b-A*x
p = r
a = ((r.norm())^2)/(p*A*p) # <- removed transpose
x = x+a*p
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.