Skip to content

Commit 46faf81

Browse files
committed
Add documentation for random_matrix
1 parent 46d62b8 commit 46faf81

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaQuantumControl.github.io/QuantumControlTestUtils.jl/stable/)
44
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaQuantumControl.github.io/QuantumControlTestUtils.jl/dev/)
55
[![Build Status](https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl/actions/workflows/CI.yml?query=branch%3Amaster)
6+
7+
The [QuantumControlTestUtils](https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl) package collects methods that are used for testing and benchmarking within the [JuliaQuantumControl](https://github.com/JuliaQuantumControl) organization

docs/src/index.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ CurrentModule = QuantumControlTestUtils
44

55
# QuantumControlTestUtils
66

7-
Documentation for [QuantumControlTestUtils](https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl).
7+
The [QuantumControlTestUtils](https://github.com/JuliaQuantumControl/QuantumControlTestUtils.jl) package collects methods that are used for testing and benchmarking within the [JuliaQuantumControl](https://github.com/JuliaQuantumControl) organization
8+
9+
## Exported Functions
810

911
```@index
1012
```
1113

14+
## Reference
15+
1216
```@autodocs
13-
Modules = [QuantumControlTestUtils]
17+
Modules = [QuantumControlTestUtils, QuantumControlTestUtils.RandomObjects]
18+
Private = false
1419
```

src/random.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ using SparseArrays
77
export random_state_vector, random_matrix
88

99

10+
"""Construct a random matrix.
11+
12+
```julia
13+
Ĥ = random_matrix(N; kwargs...)
14+
```
15+
16+
by default initializes `Ĥ` as a general complex ``N×N`` matrix with a spectral
17+
radius of approximately 1.0. Keyword arguments allow to initialize real or
18+
complex, Hermitian or non-Hermitian, dense or sparse matrices with arbitrary
19+
spectral radius. The non-zero entries in Ĥ will be uniformly distributed around
20+
zero, with a range of values that depends on `N` and the desired spectral
21+
radius.
22+
23+
# Keyword arguments
24+
25+
* `density=1.0`: A number > 0.0 and ≤ 1.0. Any value < 1.0 implies a sparse
26+
matrix where `density` is the approximate fraction of non-zero elements to
27+
total elements
28+
* `complex=true`: Whether the matrix should be complex-valued (default) or
29+
real-valued
30+
* `hermitian=false`: Whether the matrix should be general (default) or
31+
Hermitian (real eigenvalues)
32+
* `spectral_radius=1.0`: The approximate spectral radius, i.e. maximum absolute
33+
eigenvalue. This is according to [Girko-Ginibri's circular
34+
law](https://www.johndcook.com/blog/2018/07/27/circular-law/), in the limit
35+
of large ``N``
36+
* `rng=Random.GLOBAL_RNG`: The random number generator to use. The call
37+
`Random.rand(rng, N, N)` must produces a real-valued ``N×N`` matrix with
38+
elements uniformly distributed between 0 and 1
39+
"""
1040
function random_matrix(
1141
N;
1242
density=1.0,

0 commit comments

Comments
 (0)