LuxurySparse
We provide more detailed optimization through a self-defined sparse library which is more efficient for operations related to quantum gates.
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.
LuxurySparse.PermMatrix — Type.PermMatrix{Tv, Ti}(perm::AbstractVector{Ti}, vals::AbstractVector{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.
LuxurySparse.SparseMatrixCOO — Type.SparseMatrixCOO(is::Vector, js::Vector, vs::Vector, m::Int, n::Int) -> SparseMatrixCOO
SparseMatrixCOO{Tv, Ti}(is::Vector{Ti}, js::Vector{Ti}, vs::Vector{Tv}, m::Int, n::Int) -> SparseMatrixCOOA sparse matrix in COOrdinate format.
Also known as the ‘ijv’ or ‘triplet’ format.
Notes
COO matrices should not be used in arithmetic operations like addition, subtraction, multiplication, division, and matrix power.
Advantages of the COO format
- facilitates fast conversion among sparse formats
- permits duplicate entries (see example)
- very fast conversion to and from CSR/CSC formats (CSR is not implemented)
Disadvantages of the COO format
does not directly support:
- arithmetic operations
- slicing
Intended Usage
- COO is a fast format for constructing sparse matrices
- Once a matrix has been constructed, convert to CSR or CSC format for fast arithmetic and matrix vector operations
- By default when converting to CSR or CSC format, duplicate (i,j) entries will be summed together. This facilitates efficient construction of finite element matrices and the like. (see example)
LuxurySparse.allocated_coo — Method.allocated_coo(::Type, M::Int, N::Int, nnz::Int) -> SparseMatrixCOOConstruct a preallocated SparseMatrixCOO instance.
LuxurySparse.dynamicize — Function.dynamicize(A::AbstractMatrix) -> AbastractMatrixtransform a matrix to a dynamic form.
LuxurySparse.fast_invperm — Method.faster invperm
LuxurySparse.isdense — Function.isdense(M) -> BoolReturn true if a matrix is dense.
Note: It is not exactly same as !isparse, e.g. Diagonal, IMatrix and PermMatrix are both not isdense and not isparse.
LuxurySparse.pmrand — Function.pmrand(T::Type, n::Int) -> PermMatrixReturn random PermMatrix.
LuxurySparse.staticize — Function.staticize(A::AbstractMatrix) -> AbastractMatrixtransform a matrix to a static form.