Skip to content

Commit ba25a31

Browse files
committed
Add complex number and non-complex example
1 parent cc76cc0 commit ba25a31

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

notebooks/comparison.ipynb

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 3,
5+
"execution_count": 6,
66
"metadata": {},
77
"outputs": [
88
{
@@ -24,7 +24,7 @@
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 4,
27+
"execution_count": 7,
2828
"metadata": {
2929
"tags": []
3030
},
@@ -90,6 +90,9 @@
9090
}
9191
],
9292
"source": [
93+
"'''\n",
94+
"Run with Complex Numbers\n",
95+
"'''\n",
9396
"# Random square matrix\n",
9497
"rand_square_matrix = torch.rand(50, 50, dtype=float)\n",
9598
"\n",
@@ -109,10 +112,39 @@
109112
},
110113
{
111114
"cell_type": "code",
112-
"execution_count": null,
115+
"execution_count": 8,
113116
"metadata": {},
114-
"outputs": [],
115-
"source": []
117+
"outputs": [
118+
{
119+
"name": "stdout",
120+
"output_type": "stream",
121+
"text": [
122+
"Old Method Eigenvector ij: 0.0225447410369363\n",
123+
"--------------------------------------------------\n",
124+
"New Method Eigenvector ij: 0.02254474103693581\n"
125+
]
126+
}
127+
],
128+
"source": [
129+
"'''\n",
130+
"Run with Complex Numbers Disabled\n",
131+
"'''\n",
132+
"# Random square matrix\n",
133+
"rand_square_matrix = torch.rand(50, 50, dtype=float)\n",
134+
"\n",
135+
"# Hermitian matrix\n",
136+
"hermitian_matrix = rand_square_matrix * rand_square_matrix.T\n",
137+
"\n",
138+
"# Old \n",
139+
"old_eigenvector_ij = get_eigenvector_val_old(hermitian_matrix, i=0, j=0, disable_complex=True)\n",
140+
"\n",
141+
"# New\n",
142+
"new_eigenvector_ij = get_eigenvector_val(hermitian_matrix, i=0, j=0, disable_complex=True)\n",
143+
"\n",
144+
"print(f'Old Method Eigenvector ij: {old_eigenvector_ij}')\n",
145+
"print('-'*50)\n",
146+
"print(f'New Method Eigenvector ij: {new_eigenvector_ij}')"
147+
]
116148
}
117149
],
118150
"metadata": {

0 commit comments

Comments
 (0)