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 -> IMatrixIMatrix 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.
permis the permutation order,valsis the multiplication factor.
Yao.LuxurySparse.fast_invperm — Method.faster invperm
Yao.LuxurySparse.notdense — Function.notdense(M) -> BoolReturn 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) -> PermMatrixReturn random PermMatrix.
Yao.LuxurySparse.statify — Function.statify(A::AbstractMatrix) -> AbastractMatrixtransform a matrix to a static form.
Yao.LuxurySparse.matvec — Function.matvec(x::VecOrMat) -> MatOrVecReturn vector if a matrix is a column vector, else untouched.
Yao.LuxurySparse.mulcol! — Function.mulcol!(v::Vector, i::Int, f) -> VecOrMatmultiply col i of v by f inplace.
Yao.LuxurySparse.mulrow! — Function.mulrow!(v::Vector, i::Int, f) -> VecOrMatmultiply row i of v by f inplace.
Yao.LuxurySparse.swapcols! — Function.swapcols!(v::VecOrMat, i::Int, j::Int[, f1, f2]) -> VecOrMatswap 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]) -> VecOrMatswap 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) -> VecOrMatapply u1 on row i and row j of state inplace.