Spaces:
Runtime error
Runtime error
anp-scp
commited on
Commit
•
b3bb8b2
1
Parent(s):
f7111bf
removed plotting of complex types
Browse files
app.py
CHANGED
@@ -42,20 +42,24 @@ x_dash_down, y_dash_down = transform(x,-y)
|
|
42 |
|
43 |
t = np.array([[a_00,a_01], [a_10, a_11]], dtype=np.float64)
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
ax.quiver(0,0,evec[
|
52 |
-
ax.
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
t = np.array([[a_00,a_01], [a_10, a_11]], dtype=np.float64)
|
44 |
|
45 |
+
|
46 |
+
evl, evec = np.linalg.eig(t)
|
47 |
+
fig, ax = plt.subplots()
|
48 |
+
ax.plot(x_dash_up,y_dash_up,'r')
|
49 |
+
ax.plot(x_dash_down,y_dash_down, 'g')
|
50 |
+
if not (np.iscomplex(evl).any() or np.iscomplex(evec).any()):
|
51 |
+
ax.quiver(0,0,evec[0,0]*evl[0],evec[1,0]*evl[0],scale=1,scale_units ='xy',angles='xy', facecolor='yellow', label='$eigen\ vector_{\lambda_0}$')
|
52 |
+
ax.quiver(0,0,evec[0,1]*evl[1],evec[1,1]*evl[1],scale=1,scale_units ='xy',angles='xy', facecolor='blue',label='$eigen\ vector_{\lambda_1}$')
|
53 |
+
ax.set_xlim(-10,10)
|
54 |
+
ax.set_ylim(-10,10)
|
55 |
+
ax.set_aspect('equal', adjustable='box')
|
56 |
+
fig.legend()
|
57 |
+
st.pyplot(fig)
|
58 |
+
|
59 |
+
df = pd.DataFrame({'Eigen Values': evl, 'Eigen Vectors': [str(evec[:,0]), str(evec[:,1])],\
|
60 |
+
'Transformed Eigen Vectors': [str(evec[:,0]*evl[0]), str(evec[:,1]*evl[1])]})
|
61 |
+
st.table(df)
|
62 |
+
|
63 |
+
if np.iscomplex(evl).any() or np.iscomplex(evec).any():
|
64 |
+
st.write("Due to complex eigen vectors or eigne values, the transformed eigen vectors are not\
|
65 |
+
displayed...")
|