From 0646f8c98bd19db837500fc0fe95e47ca7016a9e Mon Sep 17 00:00:00 2001 From: Michael Reed <18372368+chakravala@users.noreply.github.com> Date: Sat, 2 Mar 2019 11:59:42 -0500 Subject: [PATCH] separated definition of hodge and complement, crossprod methods --- README.md | 4 +-- src/algebra.jl | 76 ++++++++++++++++++++++++++++++++++----------- src/multivectors.jl | 2 +- src/symbolic.jl | 31 +++++++++++++----- 4 files changed, 84 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 9390fdc..dfcd48a 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ This package is a work in progress providing the necessary tools to work with ar It is currently possible to do both high-performance numerical computations with `Grassmann` and it is also currently possible to use symbolic scalar coefficients when the `Reduce` package is also loaded (compatibility instructions at bottom). -Products available for high-performance and sparse computation include `∧,∨,⋅,*` (exterior, regressive, interior, geometric). +Products available for sparse & high-performance ops include `∧,∨,⋅,*,×` (exterior, regressive, interior, geometric, cross). -Some unary operations include `complementleft`,`complementright`,`reverse,`,`involve`,`conj`, and `adjoint`. +Some unary operations include `complementleft`,`complementright`,`reverse`,`involute`,`conj`, and `adjoint`. #### Design, code generation diff --git a/src/algebra.jl b/src/algebra.jl index 07f56aa..86ec9d6 100644 --- a/src/algebra.jl +++ b/src/algebra.jl @@ -38,7 +38,7 @@ for (op,set) ∈ ((:add,:(+=)),(:set,:(=))) return m end @inline function $(Symbol(:join,sm))(m::MArray{Tuple{M},T,1,M},v::T,A::Basis{V},B::Basis{V}) where {V,T<:Field,M} - if v ≠ 0 !(hasdual(V) && hasdual(A) && hasdual(B)) + if v ≠ 0 && !(hasdual(V) && hasdual(A) && hasdual(B)) $sm(m,parity(A,B) ? -(v) : v,bits(A) ⊻ bits(B),Dimension{ndims(V)}()) end return m @@ -71,6 +71,20 @@ for (op,set) ∈ ((:add,:(+=)),(:set,:(=))) end return m end + @inline function $(Symbol(:cross,sm))(V::VectorSpace{N,D},m::MArray{Tuple{M},T,1,M},A::Bits,B::Bits,v::T) where {N,D,T<:Field,M} + if v ≠ 0 + p,C,t = crossprod(A,B,V) + t && $sm(m,p ? -(v) : v,C,Dimension{N}()) + end + return m + end + @inline function $(Symbol(:cross,sm))(m::MArray{Tuple{M},T,1,M},A::Basis{V},B::Basis{V},v::T) where {V,T<:Field,M} + if v ≠ 0 + p,C,t = crossprod(bits(A),bits(B),V) + t && $sm(m,p ? -(v) : v,C,Dimension{N}()) + end + return m + end @inline function $(Symbol(:join,sb))(V::VectorSpace{N,D},m::MArray{Tuple{M},T,1,M},A::Bits,B::Bits,v::T) where {N,D,T<:Field,M} if v ≠ 0 && !(hasdual(V) && isodd(A) && isodd(B)) $sb(m,parity(A,B,V) ? -(v) : v,A ⊻ B,Dimension{N}()) @@ -187,15 +201,17 @@ end ## complement -export complementleft, complementright +export complementleft, complementright, complementhodge @pure complement(N::Int,B::UInt) = (~B)&(one(Bits)<