7 def null(A
, eps
=1e-15):
8 u
, s
, vh
= scipy
.linalg
.svd(A
)
10 null_space
= scipy
.compress(null_mask
, vh
, axis
=0)
11 return scipy
.transpose(null_space
)
13 def eigenvalues(A
, eps
=1e-15):
14 u
, s
, vh
= scipy
.linalg
.svd(A
)
17 def application(environ
, start_response
):
18 if environ
['REQUEST_METHOD'] == 'POST':
19 post_data
= environ
['wsgi.input'].read()
25 post_data
= urlparse
.parse_qsl(post_data
, True, True)
27 data_string
= str(post_data
[0][1])
28 data_rows
= data_string
.splitlines()
29 for index
, row
in enumerate(data_rows
):
30 data_rows
[index
] = row
.split()
32 given_matrix
= data_rows
33 null_space
= null(given_matrix
)
35 null_space
= null_space
/ null_space
.max()
39 # la, v = scipy.linalg.eig(given_matrix)
40 # output += "eigenvalues:<br>"
43 determinant
= scipy
.linalg
.det(given_matrix
)
46 output
+= "nullspace:<br>"
47 output
+= str(null_space
)
49 output
+= "eigenvalues:<br>"
50 output
+= str(eigenvalues(given_matrix
))
52 output
+= "determinant:<br>"
53 output
+= str(determinant
)
54 # output += "<br><br>"
55 # output += "eigenvalues:<br>"
57 # output += "<br><br>"
58 # output += "eigenvectors:<br>"
59 # output += str(v[:,0][0])
63 output_len
= sum(len(line
) for line
in output
)
64 start_response('200 OK', [('Content-type', 'text/html'),
65 ('Content-Length', str(output_len
))])