File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -153,15 +153,23 @@ normalize(qarr::AbstractQuArray) = normalize!(copy(qarr))
153153# matrix operations returning an array
154154# sparse to dense
155155function Base. full (qarr:: AbstractQuMatrix )
156- fc = full (rawcoeffs (qarr))
156+ fc = full (coeffs (qarr))
157157 QAT = similar_type (qarr)
158158 return QAT (fc, bases (qarr))
159159end
160+
161+ # convert to a sparse matrix
162+ function Base. sparse (qarr:: AbstractQuMatrix )
163+ sc = sparse (coeffs (qarr))
164+ QAT = similar_type (qarr)
165+ return QAT (sc, bases (qarr))
166+ end
167+
160168# Base.full(ct::CTranspose) = full(ct.qarr)'
161169
162170# exponential of dense matrix
163171function Base. expm (qarr:: AbstractQuMatrix )
164- fc = expm (full (rawcoeffs (qarr)))
172+ fc = expm (full (coeffs (qarr)))
165173 QAT = similar_type (qarr)
166174 return QAT (fc, bases (qarr))
167175end
Original file line number Diff line number Diff line change @@ -55,3 +55,6 @@ qv1 = normalize!(QuArray(v1))
5555
5656# Vectorize
5757@assert vec (qv) == vec (qv' )
58+
59+ # Sparse matrix
60+ @assert sparse (sigmax)* sparse (sigmax) == sparse (QuArray (eye (2 )))
You can’t perform that action at this time.
0 commit comments