Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Oct 2, 2024
1 parent 5c18ff5 commit 8d6a78e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,15 @@ @misc{Russo_2017_Extended
}

#Last name begins with S
@misc{SE_1688950,
author = "Stack Exchange Mathematics",
title = "Why do the columns of a unitary matrix form an orthonormal basis?",
howpublished = {https://math.stackexchange.com/q/1688950}

}


@misc{Seshadri_2021_Git,
author = "Seshadri, Akshay",
title = "Minimax Fidelity Estimation",
Expand Down
1 change: 1 addition & 0 deletions toqito/rand/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from toqito.rand.random_state_vector import random_state_vector
from toqito.rand.random_states import random_states
from toqito.rand.random_circulant_gram_matrix import random_circulant_gram_matrix
from toqito.rand.random_orthonormal_basis import random_orthonormal_basis
43 changes: 43 additions & 0 deletions toqito/rand/random_orthonormal_basis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Generate random orthonormal basis."""
import numpy as np

from toqito.matrix_props import is_orthonormal
from toqito.rand import random_unitary


def random_orthonormal_basis(dim: int) -> list[np.ndarray]:
r"""Generate a real random orthonormal basis of given dimension $d$.
The basis is generated from the columns of a random unitary matrix of the same dimension
as the columns of a unitary matrix typically form an orthonormal basis :cite:`SE_1688950`.
Examples
==========
To generate a random orthonormal basis of dimension 4,
>>> from toqito.rand import random_orthonormal_basis
>>> random_orthonormal_basis(4) # doctest: +SKIP
[array([0.52188745, 0.4983613 , 0.69049811, 0.04981832]),
array([-0.48670459, 0.58756912, -0.10226756, 0.63829658]),
array([ 0.23965404, -0.58538248, 0.187136 , 0.75158061]),
array([ 0.658269 , 0.25243989, -0.69118291, 0.158815 ])]
References
==========
.. bibliography::
:filter: docname in docnames
dim: int
Number of elements in the random orthonormal basis.
"""
random_mat = random_unitary(dim, is_real=True)

rand_orth_basis = [random_mat[:, i] for i in range(dim)]

if not is_orthonormal(np.array(rand_orth_basis)):
raise ValueError("Random orthonormal basis could not constructed.")

return rand_orth_basis


1 change: 1 addition & 0 deletions toqito/rand/tests/test_random_orthonormal_basis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for random orthonormal basis."""

0 comments on commit 8d6a78e

Please sign in to comment.