I am trying to write a function which takes a giving 2x2 matrix and checks if one of its elements is large than a certain value. If this is the case, it returns 1, otherwise it should return 0. Up to now I have:
def Is_it_too_large(W_n, max_value):
value_1 = abs( W_n(0,0) )
value_2 = abs( W_n(0,1) )
value_3 = abs( W_n(1,0) )
value_4 = abs( W_n(1,1) )
if value_1 < max_value && value_2 < max_value && value_3 < max_value && value_4 < max_value:
bool = 0
else:
bool = 1
return bool
However, if I test the function with, for example,
A = np.matrix([[1,3,7],[2,8,3],[7,8,1]])
print Is_it_too_large(A,10)
I get the error "invalid syntax". Any ideas what is wrong here?
Aucun commentaire:
Enregistrer un commentaire