in tutorials/LinearAlgebra/testing.py [0:0]
def find_eigenvector_test(fun):
for i in range(10):
(a, x) = (None, None)
if i < 3:
(a, x) = (edge_matrices[-1-i], edge_values[-1-i])
else:
(a, x) = gen_eigenmatrix(2)
result = fun(a, x)
if result == None or result == ...:
print("Your function must return a value!")
return
if result == [[0], [0]]:
print("The eigenvector must be non-zero!")
return
matrix_product = matrix_mult_ref(a, result)
scalar_product = scalar_mult_ref(x, result)
if not matrix_equal(matrix_product, scalar_product):
print("Wrong eigenvector!\nEigenvalue: {0:.3f}\n\n".format(x)
+ gen_labeled_message([a, result, matrix_product, scalar_product], ["A: ", "You returned V: ", "Matrix product AV:", "Scalar product xV: "])
+ "Try again!")
return
print("Success!")