Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #37 from amitjamadagni/vec
Add vec for AbstractQuArrays plus tests.
  • Loading branch information
acroy committed Jun 29, 2015
2 parents 055bce8 + 7ac66b8 commit 6e2d893
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/arrays/arraymath.jl
Expand Up @@ -121,6 +121,9 @@ function \{B<:OrthonormalBasis}(op::AbstractQuMatrix{B}, vec::AbstractQuVector{B
return QAT(div, bases(op,1))
end

# Vectorize QuArray
Base.vec{B<:OrthonormalBasis}(vec1::AbstractQuArray{B}) = QuArray(vec(coeffs(vec1)))

# matrix operations returning a scalar
# normalization
Base.norm(qarr::AbstractQuArray) = vecnorm(rawcoeffs(qarr))
Expand Down
3 changes: 3 additions & 0 deletions test/multest.jl
Expand Up @@ -37,3 +37,6 @@ v1 = [0.5+0*im, 0.+0.*im]
qv1 = normalize!(QuArray(v1))
@assert coeffs(\(sigmax,qv1)) == [0.+0.*im, 1.+0.*im]
@assert coeffs(\(sigmaz, sigmax)) == [0. 1.;-1. 0.]

# Vectorize
@assert vec(qv) == vec(qv')

0 comments on commit 6e2d893

Please sign in to comment.