LuxurySparse
We provide more detailed optimization through a self-defined sparse library which is more efficient for operations related to quantum gates.
Yao.LuxurySparse.IMatrix
— Type.IMatrix{N, Tv}()
IMatrix{N}() where N = IMatrix{N, Int64}()
IMatrix(A::AbstractMatrix{T}) where T -> IMatrix
IMatrix matrix, with size N as label, use Int64
as its default type, both *
and kron
are optimized.
Yao.LuxurySparse.PermMatrix
— Type.PermMatrix{Tv, Ti}(perm::Vector{Ti}, vals::Vector{Tv}) where {Tv, Ti<:Integer}
PermMatrix(perm::Vector{Ti}, vals::Vector{Tv}) where {Tv, Ti}
PermMatrix(ds::AbstractMatrix)
PermMatrix represents a special kind linear operator: Permute and Multiply, which means M * v = v[perm] * val
Optimizations are used to make it much faster than SparseMatrixCSC
.
perm
is the permutation order,vals
is the multiplication factor.
Yao.LuxurySparse.fast_invperm
— Method.faster invperm
Yao.LuxurySparse.notdense
— Function.notdense(M) -> Bool
Return true if a matrix is not dense.
Note: It is not exactly same as isparse, e.g. Diagonal, IMatrix and PermMatrix are both notdense but not isparse.
Yao.LuxurySparse.pmrand
— Function.pmrand(T::Type, n::Int) -> PermMatrix
Return random PermMatrix.
Yao.LuxurySparse.statify
— Function.statify(A::AbstractMatrix) -> AbastractMatrix
transform a matrix to a static form.
Yao.LuxurySparse.matvec
— Function.matvec(x::VecOrMat) -> MatOrVec
Return vector if a matrix is a column vector, else untouched.
Yao.LuxurySparse.mulcol!
— Function.mulcol!(v::Vector, i::Int, f) -> VecOrMat
multiply col i of v by f inplace.
Yao.LuxurySparse.mulrow!
— Function.mulrow!(v::Vector, i::Int, f) -> VecOrMat
multiply row i of v by f inplace.
Yao.LuxurySparse.swapcols!
— Function.swapcols!(v::VecOrMat, i::Int, j::Int[, f1, f2]) -> VecOrMat
swap col i and col j of v inplace, with f1, f2 factors applied on i and j (before swap).
Yao.LuxurySparse.swaprows!
— Function.swaprows!(v::VecOrMat, i::Int, j::Int[, f1, f2]) -> VecOrMat
swap row i and row j of v inplace, with f1, f2 factors applied on i and j (before swap).
Yao.LuxurySparse.u1rows!
— Function.u1rows!(state::VecOrMat, i::Int, j::Int, a, b, c, d) -> VecOrMat
apply u1 on row i and row j of state inplace.