Difference between revisions of "RandomUnitary"
Jump to navigation
Jump to search
(Uploaded v1.01) |
|||
| Line 4: | Line 4: | ||
|req=[[opt_args]] | |req=[[opt_args]] | ||
|rel=[[RandomDensityMatrix]]<br />[[RandomStateVector]]<br />[[RandomSuperoperator]] | |rel=[[RandomDensityMatrix]]<br />[[RandomStateVector]]<br />[[RandomSuperoperator]] | ||
| − | |upd=November | + | |upd=November 23, 2012 |
| − | |v=1. | + | |v=1.01}} |
<tt>'''RandomUnitary'''</tt> is a [[List of functions|function]] that generates a random [[unitary]] or [[orthogonal matrix]], uniformly according to [[Haar measure]]. | <tt>'''RandomUnitary'''</tt> is a [[List of functions|function]] that generates a random [[unitary]] or [[orthogonal matrix]], uniformly according to [[Haar measure]]. | ||
==Syntax== | ==Syntax== | ||
* <tt>U = RandomUnitary(DIM)</tt> | * <tt>U = RandomUnitary(DIM)</tt> | ||
| − | * <tt>U = RandomUnitary(DIM,RE)</tt> | + | * <tt>U = RandomUnitary(DIM,RE)</tt>\ |
| − | |||
==Argument descriptions== | ==Argument descriptions== | ||
* <tt>DIM</tt>: The number of rows (or equivalently, columns) that <tt>U</tt> will have. | * <tt>DIM</tt>: The number of rows (or equivalently, columns) that <tt>U</tt> will have. | ||
* <tt>RE</tt> (optional, default 0): A flag (either 0 or 1) indicating that <tt>U</tt> should only have real entries (<tt>RE = 1</tt>) or that it is allowed to have complex entries (<tt>RE = 1</tt>). That is, if you set <tt>RE = 1</tt> then <tt>U</tt> will be an orthogonal matrix, not just a unitary matrix. | * <tt>RE</tt> (optional, default 0): A flag (either 0 or 1) indicating that <tt>U</tt> should only have real entries (<tt>RE = 1</tt>) or that it is allowed to have complex entries (<tt>RE = 1</tt>). That is, if you set <tt>RE = 1</tt> then <tt>U</tt> will be an orthogonal matrix, not just a unitary matrix. | ||
| − | |||
==Examples== | ==Examples== | ||
| Line 52: | Line 50: | ||
0.0000 0.0000 1.0000 | 0.0000 0.0000 1.0000 | ||
</pre> | </pre> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==Notes== | ==Notes== | ||
Revision as of 00:02, 24 November 2012
| RandomUnitary | |
| Generates a random unitary or orthogonal matrix | |
| Other toolboxes required | opt_args |
|---|---|
| Related functions | RandomDensityMatrix RandomStateVector RandomSuperoperator |
RandomUnitary is a function that generates a random unitary or orthogonal matrix, uniformly according to Haar measure.
Syntax
- U = RandomUnitary(DIM)
- U = RandomUnitary(DIM,RE)\
Argument descriptions
- DIM: The number of rows (or equivalently, columns) that U will have.
- RE (optional, default 0): A flag (either 0 or 1) indicating that U should only have real entries (RE = 1) or that it is allowed to have complex entries (RE = 1). That is, if you set RE = 1 then U will be an orthogonal matrix, not just a unitary matrix.
Examples
A random qubit gate
To generate a random quantum gate that acts on qubits, you could use the following code:
>> RandomUnitary(2) ans = 0.2280 + 0.6126i -0.2894 - 0.6993i -0.3147 + 0.6883i -0.2501 + 0.6039i
A random orthogonal matrix
To generate a random orthogonal (rather than unitary) matrix, set RE = 1:
>> U = RandomUnitary(3,1)
U =
0.9805 -0.1869 -0.0603
0.1678 0.6381 0.7515
-0.1020 -0.7470 0.6570
To verify that this matrix is indeed orthogonal, we multiply it by its transpose:
>> U'*U
ans =
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000
Notes
The random unitary matrix is generated by constructing a Ginibre ensemble of appropriate size, performing a QR decomposition on that ensemble, and then multiplying the columns of the unitary matrix Q by the sign of the corresponding diagonal entries of R.[1]
References
- ↑ Māris Ozols. How to generate a random unitary matrix, 2009.