Skip to content

Commit

Permalink
Fix deprecation warnings for 0.4-dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
acroy committed May 1, 2015
1 parent cec96eb commit 3e13212
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/arrays/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
function coherentstatevec_inf(n::Int,alpha::Number)
s = zeros(typeof(float(alpha)),n)
s[1] = one(alpha)
for i in [2:n]
for i in 2:n
s[i] = alpha/sqrt(i-1)*s[i-1]
end
z = QuArray(s)
Expand Down
8 changes: 4 additions & 4 deletions src/arrays/ladderops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
lowermatrix(lens, particle) = eye_sandwich(lens, particle, lower_single(lens[particle]))

laddercoeffs(n) = sqrt(linspace(1, n, n))
lower_single(n) = sparse([1:n-1], [2:n], laddercoeffs(n-1), n, n)
raise_single(n) = sparse([2:n], [1:n-1], laddercoeffs(n-1), n, n)
lower_single(n) = sparse([1:n-1;], [2:n;], laddercoeffs(n-1), n, n)
raise_single(n) = sparse([2:n;], [1:n-1;], laddercoeffs(n-1), n, n)

before_eye(lens, pivot) = speye(prod(lens[[1:pivot-1]]))
after_eye(lens, pivot) = speye(prod(lens[[pivot+1:length(lens)]]))
before_eye(lens, pivot) = speye(prod(lens[1:pivot-1]))
after_eye(lens, pivot) = speye(prod(lens[pivot+1:length(lens)]))
function eye_sandwich(lens, pivot, op)
return kron(before_eye(lens, pivot),
op,
Expand Down
20 changes: 18 additions & 2 deletions src/arrays/spinops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ spin(s::HalfSpin) = s
spin(j::Integer) = HalfSpin(2*j)
function spin(j)
if isinteger(j)
return spin(int(j)) # j = 0.0, 1.0, 2.0...
return spin(@compat(rount(Int,j))) # j = 0.0, 1.0, 2.0...
elseif isinteger(2*j)
return HalfSpin(int(2*j)) # j = .5, 1.5, 2.5...
return HalfSpin(@compat(round(Int,2*j))) # j = .5, 1.5, 2.5...
else
error("Spin must be a multiple of 1/2.")
end
Expand All @@ -25,6 +25,7 @@ spin_value(s::HalfSpin) = s.val/2
#####################
# Auxiliary Methods #
#####################
<<<<<<< HEAD
spin_coeffs(j, scalar) = [scalar*sqrt(j*(j+1)-(x+1)*x) for x in j-1:-1:-j]

function spinjyx_mat(s::HalfSpin, a, b)
Expand All @@ -37,6 +38,21 @@ end

spinjx_mat(j) = spinjyx_mat(spin(j), .5, 1)
spinjy_mat(j) = spinjyx_mat(spin(j), -.5im, -1)
=======

function mat_coeffs_1(j::Float64)
m = j-1:-1:-j
N = length(m)+1
m_coeffs = [sqrt(j*(j+1.0) - (x+1.0)*x) for x in m]
return spdiagm(m_coeffs,1,N,N)
end

function mat_coeffs_2(j::Float64)
m = j:-1:-j
N = length(m)
return spdiagm(m,0,N,N)
end
>>>>>>> Fix deprecation warnings for 0.4-dev.

function spinjpm_mat(s::HalfSpin, k)
N = s.val + 1
Expand Down
4 changes: 2 additions & 2 deletions src/bases/labelbasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@
######################
# Accessor Functions #
######################
ind_value(n, range, denom, modulus) = range[(div(n, denom) % modulus)+1]
ind_value(n, range, denom, modulus) = range[@compat(round(Int,div(n, denom) % modulus))+1]
tuple_at_ind(b::LabelBasis, i) = ntuple(nfactors(b), x->ind_value(i-1, ranges(b,x), b.denoms[x], size(b,x)))
pos_in_range(r::Range, i) = i in r ? (i-first(r))/step(r) : throw(BoundsError())
getpos(b::LabelBasis, label) = int(sum(map(*, map(pos_in_range, ranges(b), label), b.denoms))+1)
getpos(b::LabelBasis, label) = @compat round(Int, sum(map(*, map(pos_in_range, ranges(b), label), b.denoms))+1)

Base.in(label, b::LabelBasis) = reduce(&, map(in, label, ranges(b)))

Expand Down

0 comments on commit 3e13212

Please sign in to comment.