@@ -7,114 +7,7 @@ Also support for fundamental functions in Julia standard library:
77 - SparseArrays: sparse, nnz, nonzeros, rowvals, droptol!, dropzeros, dropzeros!, SparseVector, SparseMatrixCSC
88=#
99
10- export AbstractQuantumObject, QuantumObject
11- export QuantumObjectType,
12- BraQuantumObject,
13- KetQuantumObject,
14- OperatorQuantumObject,
15- OperatorBraQuantumObject,
16- OperatorKetQuantumObject,
17- SuperOperatorQuantumObject
18- export Bra, Ket, Operator, OperatorBra, OperatorKet, SuperOperator
19-
20- @doc raw """
21- AbstractQuantumObject{DataType,ObjType,N}
22-
23- Abstract type for all quantum objects like [`QuantumObject`](@ref) and [`QuantumObjectEvolution`](@ref).
24- """
25- abstract type AbstractQuantumObject{DataType,ObjType,N} end
26-
27- abstract type QuantumObjectType end
28-
29- @doc raw """
30- BraQuantumObject <: QuantumObjectType
31-
32- Constructor representing a bra state ``\l angle\p si|``.
33- """
34- struct BraQuantumObject <: QuantumObjectType end
35- Base. show (io:: IO , :: BraQuantumObject ) = print (io, " Bra" )
36-
37- @doc raw """
38- const Bra = BraQuantumObject()
39-
40- A constant representing the type of [`BraQuantumObject`](@ref): a bra state ``\l angle\p si|``
41- """
42- const Bra = BraQuantumObject ()
43-
44- @doc raw """
45- KetQuantumObject <: QuantumObjectType
46-
47- Constructor representing a ket state ``|\p si\r angle``.
48- """
49- struct KetQuantumObject <: QuantumObjectType end
50- Base. show (io:: IO , :: KetQuantumObject ) = print (io, " Ket" )
51-
52- @doc raw """
53- const Ket = KetQuantumObject()
54-
55- A constant representing the type of [`KetQuantumObject`](@ref): a ket state ``|\p si\r angle``
56- """
57- const Ket = KetQuantumObject ()
58-
59- @doc raw """
60- OperatorQuantumObject <: QuantumObjectType
61-
62- Constructor representing an operator ``\h at{O}``.
63- """
64- struct OperatorQuantumObject <: QuantumObjectType end
65- Base. show (io:: IO , :: OperatorQuantumObject ) = print (io, " Operator" )
66-
67- @doc raw """
68- const Operator = OperatorQuantumObject()
69-
70- A constant representing the type of [`OperatorQuantumObject`](@ref): an operator ``\h at{O}``
71- """
72- const Operator = OperatorQuantumObject ()
73-
74- @doc raw """
75- SuperOperatorQuantumObject <: QuantumObjectType
76-
77- Constructor representing a super-operator ``\h at{\m athcal{O}}`` acting on vectorized density operator matrices.
78- """
79- struct SuperOperatorQuantumObject <: QuantumObjectType end
80- Base. show (io:: IO , :: SuperOperatorQuantumObject ) = print (io, " SuperOperator" )
81-
82- @doc raw """
83- const SuperOperator = SuperOperatorQuantumObject()
84-
85- A constant representing the type of [`SuperOperatorQuantumObject`](@ref): a super-operator ``\h at{\m athcal{O}}`` acting on vectorized density operator matrices
86- """
87- const SuperOperator = SuperOperatorQuantumObject ()
88-
89- @doc raw """
90- OperatorBraQuantumObject <: QuantumObjectType
91-
92- Constructor representing a bra state in the [`SuperOperator`](@ref) formalism ``\l angle\l angle\r ho|``.
93- """
94- struct OperatorBraQuantumObject <: QuantumObjectType end
95- Base. show (io:: IO , :: OperatorBraQuantumObject ) = print (io, " OperatorBra" )
96-
97- @doc raw """
98- const OperatorBra = OperatorBraQuantumObject()
99-
100- A constant representing the type of [`OperatorBraQuantumObject`](@ref): a bra state in the [`SuperOperator`](@ref) formalism ``\l angle\l angle\r ho|``.
101- """
102- const OperatorBra = OperatorBraQuantumObject ()
103-
104- @doc raw """
105- OperatorKetQuantumObject <: QuantumObjectType
106-
107- Constructor representing a ket state in the [`SuperOperator`](@ref) formalism ``|\r ho\r angle\r angle``.
108- """
109- struct OperatorKetQuantumObject <: QuantumObjectType end
110- Base. show (io:: IO , :: OperatorKetQuantumObject ) = print (io, " OperatorKet" )
111-
112- @doc raw """
113- const OperatorKet = OperatorKetQuantumObject()
114-
115- A constant representing the type of [`OperatorKetQuantumObject`](@ref): a ket state in the [`SuperOperator`](@ref) formalism ``|\r ho\r angle\r angle``
116- """
117- const OperatorKet = OperatorKetQuantumObject ()
10+ export QuantumObject
11811
11912@doc raw """
12013 struct QuantumObject{MT<:AbstractArray,ObjType<:QuantumObjectType,N}
@@ -232,11 +125,6 @@ _check_dims(dims::Any) = throw(
232125 ),
233126)
234127
235- function check_dims (A:: AbstractQuantumObject , B:: AbstractQuantumObject )
236- A. dims != B. dims && throw (DimensionMismatch (" The two quantum objects don't have the same Hilbert dimension." ))
237- return nothing
238- end
239-
240128function _check_QuantumObject (type:: KetQuantumObject , dims, m:: Int , n:: Int )
241129 (n != 1 ) && throw (DomainError ((m, n), " The size of the array is not compatible with Ket" ))
242130 (prod (dims) != m) && throw (DimensionMismatch (" Ket with dims = $(dims) does not fit the array size = $((m, n)) ." ))
@@ -321,41 +209,6 @@ function Base.show(io::IO, QO::AbstractQuantumObject)
321209 return show (io, MIME (" text/plain" ), op_data)
322210end
323211
324- @doc raw """
325- size(A::AbstractQuantumObject)
326- size(A::AbstractQuantumObject, idx::Int)
327-
328- Returns a tuple containing each dimensions of the array in the [`AbstractQuantumObject`](@ref).
329-
330- Optionally, you can specify an index (`idx`) to just get the corresponding dimension of the array.
331- """
332- Base. size (A:: AbstractQuantumObject ) = size (A. data)
333- Base. size (A:: AbstractQuantumObject , idx:: Int ) = size (A. data, idx)
334-
335- Base. getindex (A:: AbstractQuantumObject , inds... ) = getindex (A. data, inds... )
336- Base. setindex! (A:: AbstractQuantumObject , val, inds... ) = setindex! (A. data, val, inds... )
337-
338- @doc raw """
339- eltype(A::AbstractQuantumObject)
340-
341- Returns the elements type of the matrix or vector corresponding to the [`AbstractQuantumObject`](@ref) `A`.
342- """
343- Base. eltype (A:: AbstractQuantumObject ) = eltype (A. data)
344-
345- @doc raw """
346- length(A::AbstractQuantumObject)
347-
348- Returns the length of the matrix or vector corresponding to the [`AbstractQuantumObject`](@ref) `A`.
349- """
350- Base. length (A:: AbstractQuantumObject ) = length (A. data)
351-
352- Base. isequal (A:: AbstractQuantumObject , B:: AbstractQuantumObject ) =
353- isequal (A. type, B. type) && isequal (A. dims, B. dims) && isequal (A. data, B. data)
354- Base. isapprox (A:: AbstractQuantumObject , B:: AbstractQuantumObject ; kwargs... ) =
355- isequal (A. type, B. type) && isequal (A. dims, B. dims) && isapprox (A. data, B. data; kwargs... )
356- Base.:(== )(A:: AbstractQuantumObject , B:: AbstractQuantumObject ) =
357- (A. type == B. type) && (A. dims == B. dims) && (A. data == B. data)
358-
359212Base. real (x:: QuantumObject ) = QuantumObject (real (x. data), x. type, x. dims)
360213Base. imag (x:: QuantumObject ) = QuantumObject (imag (x. data), x. type, x. dims)
361214
@@ -379,9 +232,3 @@ SparseArrays.SparseMatrixCSC(A::QuantumObject{<:AbstractMatrix}) =
379232 QuantumObject (SparseMatrixCSC (A. data), A. type, A. dims)
380233SparseArrays. SparseMatrixCSC {T} (A:: QuantumObject{<:SparseMatrixCSC} ) where {T<: Number } =
381234 QuantumObject (SparseMatrixCSC {T} (A. data), A. type, A. dims)
382-
383- get_typename_wrapper (A:: AbstractQuantumObject ) = Base. typename (typeof (A)). wrapper
384-
385- # functions for getting Float or Complex element type
386- _FType (:: QuantumObject{<:AbstractArray{T}} ) where {T<: Number } = _FType (T)
387- _CType (:: QuantumObject{<:AbstractArray{T}} ) where {T<: Number } = _CType (T)
0 commit comments