Skip to content

Commit

Permalink
Merge branch 'master' into op_machinery
Browse files Browse the repository at this point in the history
Conflicts:
	src/arrays/quarray.jl
  • Loading branch information
amitjamadagni committed Apr 3, 2015
2 parents d9007d7 + 9c035c7 commit 62145d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/arrays/quarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
rawbases(qarr::QuArray, i) = qarr.bases[i]
bases(qarr::QuArray, i) = rawbases(qarr, i)

rawbases(qarr::AbstractQuArray) = qarr.bases

bases(qarr::QuArray, i) = rawbases(qarr, i)
# works generally as long as the single index form is defined
rawbases(qarr::AbstractQuArray) = ntuple(ndims(qarr), i->rawbases(qarr, i))
bases(qarr::AbstractQuArray) = ntuple(ndims(qarr), i->bases(qarr, i))

########################
Expand All @@ -54,6 +56,8 @@

Base.in(c, qarr::QuArray) = in(c, rawcoeffs(qarr))

Base.(:(==))(a::AbstractQuArray, b::AbstractQuArray) = coeffs(a)==coeffs(b) && bases(a)==bases(b)

##############
# CTranspose #
##############
Expand All @@ -78,7 +82,10 @@
coeffs(ct::CTranspose) = rawcoeffs(ct)'

revind(len, i) = len - (i-1)

rawbases(ct::CTranspose, i) = rawbases(ct.qarr, i)
rawbases(ct::CTranspose) = rawbases(ct.qarr)

bases(ct::CTranspose, i) = rawbases(ct, revind(ndims(ct), i))

########################
Expand Down
3 changes: 3 additions & 0 deletions test/multest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ qv = QuArray(v)
@assert coeffs(qm' * -im) == -im * m'
@assert norm(qv) == norm(v)
@test_approx_eq rawcoeffs(normalize(qv)) rawcoeffs(qv)/norm(v)

# a simple test of the `==` operator
@assert qm*3im == scale!(3im, copy(qm))

0 comments on commit 62145d3

Please sign in to comment.