Skip to content

Commit

Permalink
finalized mixed-symmetry algebra dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Sep 10, 2019
1 parent 0c3584b commit e0138ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ x * y + (dy * x + dx * y)v₁ϵ₁
```
Higher order and multivariable Taylor numbers are also supported.
```Julia
julia> @basis tangent(ℝ,2,2)
julia> @basis tangent(ℝ,2,2) # 1D Grade, 2nd Order, 2 Variables
(⟨+₁₂⟩, v, v₁, ∂₁, ∂₂, ∂₁v₁, ∂₂v₁, ∂₁₂, ∂₁₂v₁)

julia> ∂1 * ∂1v1
Expand All @@ -365,20 +365,21 @@ julia> ∂1 * ∂2
julia> v1*∂12
∂₁₂v₁

julia> ∂12*∂2
julia> ∂12*∂2 # 3rd order is zero
0v
```
Although the implementation in this release is still experimental.
```Julia
julia> @mixedbasis tangent(ℝ^2,2,2);

julia> SChain{Any,V,2}([0,1,0,0,1,0])
julia> @mixedbasis tangent(ℝ^2,2,2); # 2D Grade, 2nd Order, 2 Variables

julia>= ∂1v1 + ∂2v2 # vector field
0v₁₂ + 1∂₁v₁ + 0∂₂v₁ + 0∂₁v₂ + 1∂₂v₂ + 0∂₁₂

julia> ans^2
0.0 + 1.0∂₁∂₁ + 1.0∂₂∂₂
julia># Laplacian
0.0v₁ + 0.0v₂ + 1∂₁∂₁ + 1∂₂∂₂

julia> ans*∂1 # 3rd order is zero
0.0v⃖
```
For example, a constructor with explicit `Any` type delcaration must be used to be able to properly work with nested symmetric Leibniz basis elements. If the `StaticArray` type is not set to `Any` currently, the type system is incompatible.
Although fully generalized, the implementation in this release is still experimental.
## Constructing linear transformations from mixed tensor product ⊗
Expand Down
28 changes: 15 additions & 13 deletions src/algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ function declare_mutating_operations(M,F,set_val,SUB,MUL)
if v 0 && !diffcheck(V,a,b)
A,B,Q,Z = symmetricmask(V,a,b)
val = (typeof(V)<:Signature || count_ones(A&B)==0) ? (parity(A,B,V) ? $SUB(v) : v) : $MUL(parityinner(A,B,V),v)
if diffvars(V)0 && !iszero(Z)
TAny && (return true)
val *= getbasis(V,Z)
if diffvars(V)0
!iszero(Z) && (TAny ? (return true) : (val *= getbasis(V,Z)))
count_ones(Q)+order(val)>diffmode(V) && (return false)
end
$s(m,val,(AB)|Q,Dimension{N}())
Expand All @@ -64,9 +63,8 @@ function declare_mutating_operations(M,F,set_val,SUB,MUL)
A,B,Q,Z = symmetricmask(V,a,b)
pcc,bas,cc = (hasinf(V) && hasorigin(V)) ? conformal(A,B,V) : (false,AB,false)
val = (typeof(V)<:Signature || count_ones(A&B)==0) ? (parity(A,B,V)pcc ? $SUB(v) : v) : $MUL(parityinner(A,B,V),pcc ? $SUB(v) : v)
if diffvars(V)0 && !iszero(Z)
TAny && (return true)
val *= getbasis(V,Z)
if diffvars(V)0
!iszero(Z) && (TAny ? (return true) : (val *= getbasis(V,Z)))
count_ones(Q)+order(val)>diffmode(V) && (return false)
end
$s(m,val,bas|Q,Dimension{N}())
Expand All @@ -86,10 +84,12 @@ function declare_mutating_operations(M,F,set_val,SUB,MUL)
if val 0
g,C,t,Z = $uct(A,B,V)
v = val
if diffvars(V)0 && !iszero(Z)
TAny && (return true)
_,_,Q,_ = symmetricmask(V,A,B)
v *= getbasis(V,Z)
if diffvars(V)0
if !iszero(Z)
TAny && (return true)
_,_,Q,_ = symmetricmask(V,A,B)
v *= getbasis(V,Z)
end
count_ones(Q)+order(v)>diffmode(V) && (return false)
end
t && $s(m,typeof(V) <: Signature ? g ? $SUB(v) : v : $MUL(g,v),C,Dimension{N}())
Expand Down Expand Up @@ -483,9 +483,11 @@ function generate_product_algebra(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CON
g,C,f,Z = interior(α,β,V)
!iszero(C) && TAny && (return true)
v = iszero(C) ? γ : γ*getbasis(V,C)
if diffvars(V)0 && !iszero(Z)
_,_,Q,_ = symmetricmask(V,α,β)
v *= getbasis(V,Z)
if diffvars(V)0
if !iszero(Z)
_,_,Q,_ = symmetricmask(V,α,β)
v *= getbasis(V,Z)
end
order(v)>diffmode(V) && (return false)
end
f && (mv.v = typeof(V)<:Signature ? (g ? $SUB(mv.v,v) : $ADD(mv.v,v)) : $ADD(mv.v,$MUL(g,v)))
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Base.@pure promote_type(t...) = Base.promote_type(t...)
assign_expr!(e,x,:N,:(ndims(V)))
assign_expr!(e,x,:M,:(Int(N/2)))
assign_expr!(e,x,:t,vec:mvec ? :Any : :(promote_type($T,$S)))
assign_expr!(e,x,:out,mv0 ? :(t=Any;zeros(svec(N,Any)).+out) : :(zeros($vec(N,t))))
assign_expr!(e,x,:out,mv0 ? :(t=Any;convert(svec(N,Any),out)) : :(zeros($vec(N,t))))
assign_expr!(e,x,:mv,:(MBlade{V,0,getbasis(V,0),$(mv≠0 ? Any : :t)}($mv)))
assign_expr!(e,x,:r,:(binomsum(N,G)))
assign_expr!(e,x,:bng,:(binomial(N,G)))
Expand Down

0 comments on commit e0138ce

Please sign in to comment.