Skip to content

Commit 699aeba

Browse files
authored
Remove RandomMatrices as a dependency (#180)
1 parent 2b6763b commit 699aeba

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1313
QuantumInterface = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5"
1414
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
15-
RandomMatrices = "2576dda1-a324-5b11-aa66-c48ed7e3c618"
1615
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
1716
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1817
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
@@ -28,7 +27,6 @@ LRUCache = "1"
2827
LinearAlgebra = "1"
2928
QuantumInterface = "0.3.3"
3029
Random = "1"
31-
RandomMatrices = "0.5"
3230
RecursiveArrayTools = "3"
3331
SparseArrays = "1"
3432
Strided = "1, 2"

src/state_definitions.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using RandomMatrices
21
"""
32
randstate([T=ComplexF64,] basis)
43
@@ -16,7 +15,12 @@ randstate(b) = randstate(ComplexF64, b)
1615
1716
Returns a Haar random pure state of dimension `length(b)` by applying a Haar random unitary to a fixed pure state.
1817
"""
19-
randstate_haar(b::Basis) = Ket(b, rand(Haar(2), length(b), 2)[:,1])
18+
function randstate_haar(b::Basis)
19+
dim = length(b)
20+
mat = rand(ComplexF64, dim, dim)
21+
q, r = qr!(mat)
22+
return Ket(b, q[:,1])
23+
end
2024

2125
"""
2226
randoperator([T=ComplexF64,] b1[, b2])
@@ -33,7 +37,14 @@ randoperator(b) = randoperator(ComplexF64, b)
3337
3438
Returns a Haar random unitary matrix of dimension `length(b)`.
3539
"""
36-
randunitary_haar(b::Basis) = DenseOperator(b, b, rand(Haar(2), length(b), 2))
40+
function randunitary_haar(b::Basis)
41+
dim = length(b)
42+
mat = rand(ComplexF64, dim, dim)
43+
q, r = qr!(mat)
44+
d = Diagonal([r[i, i] / abs(r[i, i]) for i in 1:dim])
45+
data = q * d
46+
DenseOperator(b, b, data)
47+
end
3748

3849
"""
3950
thermalstate(H,T)

test/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1111
QuantumInterface = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5"
1212
QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c"
1313
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
14-
RandomMatrices = "2576dda1-a324-5b11-aa66-c48ed7e3c618"
1514
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1615
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1716
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"

test/test_jet.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using QuantumOpticsBase
33
using JET
44

55
# imported to be declared as modules filtered out from analysis result
6-
using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays, RandomMatrices
6+
using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays
77

88
@testset "jet" begin
99
if get(ENV,"JET_TEST","")=="true"
@@ -14,8 +14,7 @@ using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays, Rando
1414
AnyFrameModule(Strided),
1515
AnyFrameModule(StridedViews),
1616
AnyFrameModule(Dates),
17-
AnyFrameModule(SparseArrays),
18-
AnyFrameModule(RandomMatrices))
17+
AnyFrameModule(SparseArrays))
1918
)
2019
@show rep
2120
@test length(JET.get_reports(rep)) <= 24

0 commit comments

Comments
 (0)