Skip to content

Commit

Permalink
improved value dispatch and fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed May 1, 2020
1 parent d8c7101 commit 333a2c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/multivectors.jl
Expand Up @@ -396,9 +396,9 @@ valuetype(t::MultiGrade) = promote_type(valuetype.(terms(t))...)
@pure valuetype(::Chain{V,G,T} where {V,G}) where T = T
@inline value(m::MultiGrade,T) = m
for T (:Chain,:MultiVector)
@eval @inline value(m::$T,T::DataType=valuetype(m)) = T(valuetype(m),Any) ? convert(T,m.v) : m.v
@eval @inline value(m::$T,T=valuetype(m)) = T(valuetype(m),Any) ? convert(T,m.v) : m.v
end
@inline value(m::SparseChain,T::DataType=valuetype(m)) = T(valuetype(m),Any) ? convert(SparseVector{T,Int},m.v) : m.v
@inline value(m::SparseChain,T=valuetype(m)) = T(valuetype(m),Any) ? convert(SparseVector{T,Int},m.v) : m.v
@inline value_diff(m::Chain{V,0} where V) = (v=value(m)[1];istensor(v) ? v : m)
@inline value_diff(m::Chain) = m

Expand Down
12 changes: 8 additions & 4 deletions src/products.jl
Expand Up @@ -792,7 +792,8 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
@generated function $c(b::Chain{V,G,T}) where {V,G,T<:$Field}
isdyadic(V) && throw(error("Complement for dyadic tensors is undefined"))
if binomial(ndims(V),G)<(1<<cache_limit)
$(insert_expr((:N,:ib,:D,:P),:svec)...)
$(insert_expr((:N,:ib,:D),:svec)...)
P = $(ch ? 0 : :(hasinf(V)+hasorigin(V)))
out = zeros(svec(N,G,Any))
D = diffvars(V)
for k 1:binomial(N,G)
Expand All @@ -804,7 +805,8 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
end
return :(Chain{V,$(N-G)}($(Expr(:call,tvec(N,N-G,:T),out...))))
else return quote
$(insert_expr((:N,:ib,:D,:P),$(QuoteNode(VEC)))...)
$(insert_expr((:N,:ib,:D),$(QuoteNode(VEC)))...)
P = $(ch ? 0 : :(hasinf(V)+hasorigin(V)))
out = zeros($$VEC(N,G,T))
D = diffvars(V)
for k 1:binomial(N,G)
Expand All @@ -822,7 +824,8 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
@generated function $c(m::MultiVector{V,T}) where {V,T<:$Field}
isdyadic(V) && throw(error("Complement for dyadic tensors is undefined"))
if ndims(V)<cache_limit
$(insert_expr((:N,:bs,:bn,:P),:svec)...)
$(insert_expr((:N,:bs,:bn),:svec)...)
P = $(ch ? 0 : :(hasinf(V)+hasorigin(V)))
out = zeros(svec(N,Any))
D = diffvars(V)
for g 1:N+1
Expand All @@ -836,7 +839,8 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
end
return :(MultiVector{V}($(Expr(:call,tvec(N,:T),out...))))
else return quote
$(insert_expr((:N,:bs,:bn,:P),$(QuoteNode(VEC)))...)
$(insert_expr((:N,:bs,:bn),$(QuoteNode(VEC)))...)
P = $(ch ? 0 : :(hasinf(V)+hasorigin(V)))
out = zeros($$VEC(N,T))
D = diffvars(V)
for g 1:N+1
Expand Down

2 comments on commit 333a2c1

@chakravala
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/13951

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.10 -m "<description of version>" 333a2c1f202c582a76c27885de52adfe9d8b99c6
git push origin v0.5.10

Please sign in to comment.