in einer alten Version mit Spyder funktioniert folgender Pythoncode zum Gram-Schmidt verfahren:
Code: Alles auswählen
import numpy as np
matrix_ausgang = Matrix()
def gs_cofficient(v1, v2):
return np.dot(v2, v1) / np.dot(v1, v1)
def multiply(cofficient, v):
return map((lambda x : x * cofficient), v)
def proj(v1, v2):
return multiply(gs_cofficient(v1, v2) , v1)
def gs(X):
#X=np.matrix([Z]).astype(float)
Y = []
for i in range(len(X)):
temp_vec = X[i]
for inY in Y :
proj_vec = proj(inY, X[i])
temp_vec = map(lambda x, y : x - y, temp_vec, proj_vec)
Y.append(temp_vec)
w=widgets.Textarea(
description='orthogonalisierte vektoren sind jetzt',
value = str(Y),
)
display(w)
return Y
[array([2, 3]), <map object at 0x7fe4a79545f8>]
D.h. 2 , 3 stimmt noch, das ist der erste Vektor von gram-schmidt. Aber dann wird ein map object zurückgegeben, gemäß der Codezeile: temp_vec = map(lambda x, y : x - y, temp_vec, proj_vec)
Muss ich dieses Objekt eventuell casten?