-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Julia v0.6 [Initial Build] #4
base: master
Are you sure you want to change the base?
Changes from all commits
e3d6252
cd993a3
c49097a
36fab76
0a79adb
b7edf8c
7b5b38f
3da17cd
cae0fbf
ee23ef6
3b0058f
150bbe4
24f365c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
julia 0.3 0.4- | ||
julia 0.6 | ||
Compat | ||
Iterators | ||
Iterators |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,12 @@ klabel(i::InnerProduct) = i.k | |
Base.repr(i::InnerProduct) = brstr(blabel(i))*ktstr(klabel(i))[2:end] | ||
Base.show(io::IO, i::InnerProduct) = print(io, repr(i)) | ||
|
||
Base.(:(==))(a::InnerProduct, b::InnerProduct) = blabel(a) == blabel(b) && klabel(a) == klabel(b) | ||
Base.(:(==))(::InnerProduct, ::Number) = false | ||
Base.(:(==))(::Number, ::InnerProduct) = false | ||
Base.:(==)(a::InnerProduct, b::InnerProduct) = blabel(a) == blabel(b) && klabel(a) == klabel(b) | ||
Base.:(==)(::InnerProduct, ::Number) = false | ||
Base.:(==)(::Number, ::InnerProduct) = false | ||
|
||
Base.hash(i::InnerProduct) = hash(blabel(i), hash(klabel(i))) | ||
Base.hash(i::InnerProduct, h::Uint64) = hash(hash(i), h) | ||
Base.hash(i::InnerProduct, h::UInt64) = hash(hash(i), h) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
|
||
Base.conj(i::InnerProduct) = InnerProduct(klabel(i), blabel(i)) | ||
|
||
|
@@ -26,7 +26,7 @@ Base.conj(i::InnerProduct) = InnerProduct(klabel(i), blabel(i)) | |
############## | ||
|
||
# we can cheat here to avoid tempory StateLabel construction | ||
# to evaluate KroneckerDelta inner products | ||
# to evaluate KroneckerDelta inner products | ||
eval_inner_rule(p::KroneckerDelta, b, k) = inner_rule(p, b, k) | ||
eval_inner_rule(p::KroneckerDelta, b::StateLabel, k::StateLabel) = inner_rule(p, b, k) | ||
|
||
|
@@ -48,10 +48,10 @@ inner_mul(v,c,prodtype,b,k) = v * c * eval_inner_rule(prodtype, b, k) | |
# InnerExpr # | ||
############## | ||
# A InnerExpr is a type that wraps arthimetic expressions | ||
# performed with InnerExprs. The allows storage and | ||
# delayed evaluation of expressions. For example, this | ||
# performed with InnerExprs. The allows storage and | ||
# delayed evaluation of expressions. For example, this | ||
# expression: | ||
# | ||
# | ||
# (< a | b >^2 + < c | d >^2 - 3.13+im) / 2 | ||
# | ||
# is representable as a InnerExpr. | ||
|
@@ -66,7 +66,7 @@ InnerExpr{N<:Number}(n::N) = convert(InnerExpr, n) | |
Base.convert(::Type{InnerExpr}, iex::InnerExpr) = iex | ||
Base.convert{N<:Number}(::Type{InnerExpr}, n::N) = InnerExpr(Expr(:call, +, n)) | ||
|
||
Base.(:(==))(a::InnerExpr, b::InnerExpr) = a.ex == b.ex | ||
Base.:(==)(a::InnerExpr, b::InnerExpr) = a.ex == b.ex | ||
same_num(a::Number, b::Number) = a == b | ||
same_num(a::InnerExpr, b::InnerExpr) = a == b | ||
same_num(iex::InnerExpr, i::InnerProduct) = iex == InnerExpr(i) | ||
|
@@ -75,15 +75,15 @@ same_num(iex::InnerExpr, n::Number) = iex == InnerExpr(n) | |
same_num(n::Number, iex::InnerExpr) = iex == n | ||
|
||
Base.hash(iex::InnerExpr) = hash(iex.ex) | ||
Base.hash(iex::InnerExpr, h::Uint64) = hash(hash(iex), h) | ||
Base.hash(iex::InnerExpr, h::UInt64) = hash(hash(iex), h) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here - |
||
|
||
Base.one(::InnerExpr) = InnerExpr(1) | ||
Base.zero(::InnerExpr) = InnerExpr(0) | ||
|
||
Base.promote_rule{N<:Number}(::Type{InnerExpr}, ::Type{N}) = InnerExpr | ||
|
||
Base.length(iex::InnerExpr) = length(iex.ex.args) | ||
Base.getindex(iex::InnerExpr, i) = iex.ex.args[i] | ||
Base.getindex(iex::InnerExpr, i::Integer) = iex.ex.args[i] | ||
|
||
############## | ||
# inner_eval # | ||
|
@@ -123,20 +123,20 @@ function iexpr_exp(a, b) | |
end | ||
end | ||
|
||
Base.(:^)(a::InnerExpr, b::Integer) = iexpr_exp(a, b) | ||
Base.(:^)(a::InnerExpr, b::Rational) = iexpr_exp(a, b) | ||
Base.(:^)(a::InnerExpr, b::InnerExpr) = iexpr_exp(a, b) | ||
Base.(:^)(a::InnerExpr, b::Number) = iexpr_exp(a, b) | ||
Base.(:^)(a::MathConst{:e}, b::InnerExpr) = iexpr_exp(a, b) | ||
Base.(:^)(a::Number, b::InnerExpr) = iexpr_exp(a, b) | ||
Base.:^(a::InnerExpr, b::Integer) = iexpr_exp(a, b) | ||
Base.:^(a::InnerExpr, b::Rational) = iexpr_exp(a, b) | ||
Base.:^(a::InnerExpr, b::InnerExpr) = iexpr_exp(a, b) | ||
Base.:^(a::InnerExpr, b::Number) = iexpr_exp(a, b) | ||
#Base.:^(a::MathConst{:e}, b::InnerExpr) = iexpr_exp(a, b) | ||
Base.:^(a::Number, b::InnerExpr) = iexpr_exp(a, b) | ||
|
||
Base.exp(iex::InnerExpr) = InnerExpr(:(exp($(iex)))) | ||
Base.exp2(iex::InnerExpr) = InnerExpr(:(exp2($(iex)))) | ||
|
||
Base.sqrt(iex::InnerExpr) = InnerExpr(:(sqrt($(iex)))) | ||
|
||
Base.log(iex::InnerExpr) = length(iex)==2 && iex[1]==:exp ? iex[2] : InnerExpr(:(log($(iex)))) | ||
Base.log(a::MathConst{:e}, b::InnerExpr) = InnerExpr(:(log($(a),$(b)))) | ||
#Base.log(a::MathConst{:e}, b::InnerExpr) = InnerExpr(:(log($(a),$(b)))) | ||
Base.log(a::InnerExpr, b::InnerExpr) = InnerExpr(:(log($(a),$(b)))) | ||
Base.log(a::InnerExpr, b::Number) = InnerExpr(:(log($(a),$(b)))) | ||
Base.log(a::Number, b::InnerExpr) = InnerExpr(:(log($(a),$(b)))) | ||
|
@@ -157,11 +157,11 @@ function iexpr_mul(a,b) | |
end | ||
end | ||
|
||
Base.(:*)(a::InnerExpr, b::InnerExpr) =iexpr_mul(a,b) | ||
Base.(:*)(a::Bool, b::InnerExpr) = iexpr_mul(a,b) | ||
Base.(:*)(a::InnerExpr, b::Bool) = iexpr_mul(a,b) | ||
Base.(:*)(a::InnerExpr, b::Number) = iexpr_mul(a,b) | ||
Base.(:*)(a::Number, b::InnerExpr) = iexpr_mul(a,b) | ||
Base.:*(a::InnerExpr, b::InnerExpr) =iexpr_mul(a,b) | ||
Base.:*(a::Bool, b::InnerExpr) = iexpr_mul(a,b) | ||
Base.:*(a::InnerExpr, b::Bool) = iexpr_mul(a,b) | ||
Base.:*(a::InnerExpr, b::Number) = iexpr_mul(a,b) | ||
Base.:*(a::Number, b::InnerExpr) = iexpr_mul(a,b) | ||
|
||
############ | ||
# Division # | ||
|
@@ -180,16 +180,16 @@ function iexpr_div(a, b) | |
end | ||
end | ||
|
||
Base.(:/)(a::InnerExpr, b::InnerExpr) = iexpr_div(a, b) | ||
Base.(:/)(a::InnerExpr, b::Complex) = iexpr_div(a, b) | ||
Base.(:/)(a::InnerExpr, b::Number) = iexpr_div(a, b) | ||
Base.(:/)(a::Number, b::InnerExpr) = iexpr_div(a, b) | ||
Base.:/(a::InnerExpr, b::InnerExpr) = iexpr_div(a, b) | ||
Base.:/(a::InnerExpr, b::Complex) = iexpr_div(a, b) | ||
Base.:/(a::InnerExpr, b::Number) = iexpr_div(a, b) | ||
Base.:/(a::Number, b::InnerExpr) = iexpr_div(a, b) | ||
|
||
############ | ||
# Addition # | ||
############ | ||
function iexpr_add(a, b) | ||
if same_num(a, 0) | ||
if same_num(a, 0) | ||
return InnerExpr(b) | ||
elseif same_num(b, 0) | ||
return InnerExpr(a) | ||
|
@@ -198,14 +198,14 @@ function iexpr_add(a, b) | |
end | ||
end | ||
|
||
Base.(:+)(a::InnerExpr, b::InnerExpr) = iexpr_add(a, b) | ||
Base.(:+)(a::InnerExpr, b::Number) = iexpr_add(a, b) | ||
Base.(:+)(a::Number, b::InnerExpr) = iexpr_add(a, b) | ||
Base.:+(a::InnerExpr, b::InnerExpr) = iexpr_add(a, b) | ||
Base.:+(a::InnerExpr, b::Number) = iexpr_add(a, b) | ||
Base.:+(a::Number, b::InnerExpr) = iexpr_add(a, b) | ||
|
||
############### | ||
# Subtraction # | ||
############### | ||
Base.(:-)(iex::InnerExpr) = length(iex)==2 && iex[1]==:- ? InnerExpr(iex[2]) : InnerExpr(:(-$(iex))) | ||
Base.:-(iex::InnerExpr) = length(iex)==2 && iex[1]==:- ? InnerExpr(iex[2]) : InnerExpr(:(-$(iex))) | ||
|
||
function iexpr_subtract(a, b) | ||
if same_num(a, b) | ||
|
@@ -219,9 +219,9 @@ function iexpr_subtract(a, b) | |
end | ||
end | ||
|
||
Base.(:-)(a::InnerExpr, b::InnerExpr) = iexpr_subtract(a, b) | ||
Base.(:-)(a::InnerExpr, b::Number) = iexpr_subtract(a, b) | ||
Base.(:-)(a::Number, b::InnerExpr) = iexpr_subtract(a, b) | ||
Base.:-(a::InnerExpr, b::InnerExpr) = iexpr_subtract(a, b) | ||
Base.:-(a::InnerExpr, b::Number) = iexpr_subtract(a, b) | ||
Base.:-(a::Number, b::InnerExpr) = iexpr_subtract(a, b) | ||
|
||
################## | ||
# Absolute Value # | ||
|
@@ -239,7 +239,7 @@ Base.ctranspose(iex::InnerExpr) = conj(iex) | |
# Elementwise Operations # | ||
########################## | ||
for op=(:*,:-,:+,:/,:^) | ||
elop = symbol(string(:.) * string(op)) | ||
elop = Symbol(string(:.) * string(op)) | ||
@eval begin | ||
($elop)(a::InnerExpr, b::InnerExpr) = ($op)(a,b) | ||
($elop)(a::InnerExpr, b::Number) = ($op)(a,b) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
############## | ||
immutable StateLabel{N} | ||
label::NTuple{N} | ||
hash::Uint64 | ||
StateLabel(label::NTuple{N}) = new(label, hash(label)) | ||
StateLabel(label::NTuple{N}, h::Uint64) = new(label, h) | ||
hash::UInt64 | ||
StateLabel{N}(label::NTuple{N}) where N = new(label, hash(label)) | ||
StateLabel{N}(label::NTuple{N}, h::UInt64) where N = new(label, h) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some more |
||
end | ||
|
||
StateLabel(s::StateLabel) = s | ||
|
@@ -18,9 +18,9 @@ Base.getindex(s::StateLabel, arr::AbstractArray) = s.label[arr] | |
|
||
Base.copy{N}(s::StateLabel{N}) = StateLabel{N}(s.label, s.hash) | ||
Base.hash(s::StateLabel) = s.hash | ||
Base.hash(s::StateLabel, h::Uint64) = hash(hash(s), h) | ||
Base.hash(s::StateLabel, h::UInt64) = hash(hash(s), h) | ||
|
||
Base.(:(==)){N}(a::StateLabel{N},b::StateLabel{N}) = hash(a) == hash(b) | ||
Base.:(==){N}(a::StateLabel{N},b::StateLabel{N}) = hash(a) == hash(b) | ||
|
||
Base.start(s::StateLabel) = start(s.label) | ||
Base.next(s::StateLabel, i) = next(s.label, i) | ||
|
@@ -32,7 +32,7 @@ Base.endof(s::StateLabel) = endof(s.label) | |
|
||
Base.length{N}(::StateLabel{N}) = N | ||
|
||
Base.map(f::Union(Function,DataType), s::StateLabel) = StateLabel(map(f, s.label)) | ||
#Base.map(f::Union(Function,DataType), s::StateLabel) = StateLabel(map(f, s.label)) | ||
|
||
tensor(a::StateLabel, b::StateLabel) = StateLabel(tuple(a.label..., b.label...)) | ||
|
||
|
@@ -46,9 +46,9 @@ Base.show(io::IO, s::StateLabel) = print(io, repr(s)) | |
immutable OpLabel{N} | ||
k::StateLabel{N} | ||
b::StateLabel{N} | ||
hash::Uint64 | ||
OpLabel(k::StateLabel{N}, b::StateLabel{N}) = new(k, b, hash(k, hash(b))) | ||
OpLabel(k::StateLabel{N}, b::StateLabel{N}, h::Uint64) = new(k, b, h) | ||
hash::UInt64 | ||
OpLabel{N}(k::StateLabel{N}, b::StateLabel{N}) where N = new(k, b, hash(k, hash(b))) | ||
OpLabel{N}(k::StateLabel{N}, b::StateLabel{N}, h::UInt64) where N = new(k, b, h) | ||
end | ||
|
||
OpLabel(op::OpLabel) = op | ||
|
@@ -61,9 +61,9 @@ blabel(o::OpLabel) = o.b | |
|
||
Base.copy{N}(o::OpLabel{N}) = OpLabel{N}(o.k, o.b, o.hash) | ||
Base.hash(o::OpLabel) = o.hash | ||
Base.hash(o::OpLabel, h::Uint64) = hash(hash(o), h) | ||
Base.hash(o::OpLabel, h::UInt64) = hash(hash(o), h) | ||
|
||
Base.(:(==)){N}(a::OpLabel{N}, b::OpLabel{N}) = hash(a) == hash(b) | ||
Base.:(==){N}(a::OpLabel{N}, b::OpLabel{N}) = hash(a) == hash(b) | ||
|
||
Base.length{N}(::OpLabel{N}) = N | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole warning should probably go away, any version handling should just go into the REQUIRE anyway