Cm2Ue4

435 days ago by JoeJim

COMPUTERMATHEMATIK ZWEI

12.) Gram-Schmidtsches Orthogonalisierungsverfahren

v1=vector([1,2,3,4]);v2=vector([-1,3,4,0]);v3=vector([1,-1,-1,1]) M=matrix([v1,v2,v3]) 
       
import numpy def gso(Matrix): oM=matrix(Matrix.nrows(),Matrix.ncols()) j=0;nrows=Matrix.nrows(); #first row oM[0]=Matrix[0] #others: for w in (1,nrows): oM[w]=Matrix[w]-sum(numpy.dot(oM[j],M[w])/numpy.dot(oM[j],oM[j]),j,0,w-1) return(oM) 
       
print (gso(M)) 
       
Traceback (click to the left of this block for traceback)
...
TypeError: data type not understood
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_52.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("cHJpbnQgKGdzbyhNKSk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpHvQw_m/___code___.py", line 2, in <module>
    exec compile(u'print (gso(M))
  File "", line 1, in <module>
    
  File "/tmp/tmp3myUv_/___code___.py", line 13, in gso
    oM[w]=Matrix[w]-sum(numpy.dot(oM[j],M[w])/numpy.dot(oM[j],oM[j]),j,_sage_const_0 ,w-_sage_const_1 )       
  File "/home/Chris/Sagemath/local/lib/python2.6/site-packages/sage/misc/functional.py", line 659, in symbolic_sum
    return expression.sum(*args, **kwds)
TypeError: data type not understood