Skip to content

Commit

Permalink
Add complex number and non-complex example
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchieng committed Nov 2, 2021
1 parent cc76cc0 commit ba25a31
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions notebooks/comparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 7,
"metadata": {
"tags": []
},
Expand Down Expand Up @@ -90,6 +90,9 @@
}
],
"source": [
"'''\n",
"Run with Complex Numbers\n",
"'''\n",
"# Random square matrix\n",
"rand_square_matrix = torch.rand(50, 50, dtype=float)\n",
"\n",
Expand All @@ -109,10 +112,39 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Old Method Eigenvector ij: 0.0225447410369363\n",
"--------------------------------------------------\n",
"New Method Eigenvector ij: 0.02254474103693581\n"
]
}
],
"source": [
"'''\n",
"Run with Complex Numbers Disabled\n",
"'''\n",
"# Random square matrix\n",
"rand_square_matrix = torch.rand(50, 50, dtype=float)\n",
"\n",
"# Hermitian matrix\n",
"hermitian_matrix = rand_square_matrix * rand_square_matrix.T\n",
"\n",
"# Old \n",
"old_eigenvector_ij = get_eigenvector_val_old(hermitian_matrix, i=0, j=0, disable_complex=True)\n",
"\n",
"# New\n",
"new_eigenvector_ij = get_eigenvector_val(hermitian_matrix, i=0, j=0, disable_complex=True)\n",
"\n",
"print(f'Old Method Eigenvector ij: {old_eigenvector_ij}')\n",
"print('-'*50)\n",
"print(f'New Method Eigenvector ij: {new_eigenvector_ij}')"
]
}
],
"metadata": {
Expand Down

0 comments on commit ba25a31

Please sign in to comment.