diff --git a/Project.toml b/Project.toml index 4bd8172..a31be43 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,6 @@ LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" QuantumInterface = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -RandomMatrices = "2576dda1-a324-5b11-aa66-c48ed7e3c618" RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" @@ -28,7 +27,6 @@ LRUCache = "1" LinearAlgebra = "1" QuantumInterface = "0.3.3" Random = "1" -RandomMatrices = "0.5" RecursiveArrayTools = "3" SparseArrays = "1" Strided = "1, 2" diff --git a/src/state_definitions.jl b/src/state_definitions.jl index 657e186..edc68f0 100644 --- a/src/state_definitions.jl +++ b/src/state_definitions.jl @@ -1,4 +1,3 @@ -using RandomMatrices """ randstate([T=ComplexF64,] basis) @@ -16,7 +15,12 @@ randstate(b) = randstate(ComplexF64, b) Returns a Haar random pure state of dimension `length(b)` by applying a Haar random unitary to a fixed pure state. """ -randstate_haar(b::Basis) = Ket(b, rand(Haar(2), length(b), 2)[:,1]) +function randstate_haar(b::Basis) + dim = length(b) + mat = rand(ComplexF64, dim, dim) + q, r = qr!(mat) + return Ket(b, q[:,1]) +end """ randoperator([T=ComplexF64,] b1[, b2]) @@ -33,7 +37,14 @@ randoperator(b) = randoperator(ComplexF64, b) Returns a Haar random unitary matrix of dimension `length(b)`. """ -randunitary_haar(b::Basis) = DenseOperator(b, b, rand(Haar(2), length(b), 2)) +function randunitary_haar(b::Basis) + dim = length(b) + mat = rand(ComplexF64, dim, dim) + q, r = qr!(mat) + d = Diagonal([r[i, i] / abs(r[i, i]) for i in 1:dim]) + data = q * d + DenseOperator(b, b, data) +end """ thermalstate(H,T) diff --git a/test/Project.toml b/test/Project.toml index dde7892..d7fe21b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -11,7 +11,6 @@ OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" QuantumInterface = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5" QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -RandomMatrices = "2576dda1-a324-5b11-aa66-c48ed7e3c618" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" diff --git a/test/test_jet.jl b/test/test_jet.jl index 1eab195..dacde23 100644 --- a/test/test_jet.jl +++ b/test/test_jet.jl @@ -3,7 +3,7 @@ using QuantumOpticsBase using JET # imported to be declared as modules filtered out from analysis result -using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays, RandomMatrices +using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays @testset "jet" begin if get(ENV,"JET_TEST","")=="true" @@ -14,8 +14,7 @@ using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays, Rando AnyFrameModule(Strided), AnyFrameModule(StridedViews), AnyFrameModule(Dates), - AnyFrameModule(SparseArrays), - AnyFrameModule(RandomMatrices)) + AnyFrameModule(SparseArrays)) ) @show rep @test length(JET.get_reports(rep)) <= 24