Manual

LuxurySparse

We provide more detailed optimization through a self-defined sparse library which is more efficient for operations related to quantum gates.

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.

source
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.

  • perm is the permutation order,
  • vals is the multiplication factor.

Generalized Permutation Matrix

source
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) -> SparseMatrixCOO

A 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)
source
allocated_coo(::Type, M::Int, N::Int, nnz::Int) -> SparseMatrixCOO

Construct a preallocated SparseMatrixCOO instance.

source
dynamicize(A::AbstractMatrix) -> AbastractMatrix

transform a matrix to a dynamic form.

source

faster invperm

source
LuxurySparse.isdenseFunction.
isdense(M) -> Bool

Return 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.

source
LuxurySparse.pmrandFunction.
pmrand(T::Type, n::Int) -> PermMatrix

Return random PermMatrix.

source
staticize(A::AbstractMatrix) -> AbastractMatrix

transform a matrix to a static form.

source