diff --git a/.appveyor.yml b/.appveyor.yml index 855eaa7..94fe534 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,10 +2,8 @@ environment: matrix: - julia_version: 1 - julia_version: 1.6 - - julia_version: 1.7 - - julia_version: 1.8 - - julia_version: 1.9 - julia_version: 1.10 + - julia_version: 1.11 - julia_version: nightly platform: diff --git a/src/algebra.jl b/src/algebra.jl index cd030a4..4140a29 100644 --- a/src/algebra.jl +++ b/src/algebra.jl @@ -13,13 +13,16 @@ # https://crucialflow.com import Base: +, -, *, ^, /, //, inv, <, >, <<, >>, >>> -import AbstractTensors: ∧, ∨, ⟑, ⊗, ⊛, ⊙, ⊠, ⨼, ⨽, ⋆, ∗, rem, div, TAG, SUB +import AbstractTensors: ∧, ∨, ⟑, ⊖, ⊘, ⊗, ⊛, ⊙, ⊠, ⨼, ⨽, ⋆, ∗, rem, div, TAG, SUB import AbstractTensors: plus, minus, times, contraction, equal, wedgedot, veedot import AbstractTensors: pseudosandwich, antisandwich, antidot import Leibniz: diffcheck, diffmode, symmetricsplit import Leibniz: loworder, isnull, Field, ExprField const Sym,SymField = :AbstractTensors,Any +export ∗, ⊛, ⊖, ∧, ∨, ⟑, wedgedot, veedot, ⊗, ⨼, ⨽, ⊙, ⊠, ⟂, ∥ +export ⊘, sandwich, pseudosandwich, antisandwich + if VERSION >= v"1.10.0"; @eval begin import AbstractTensors.$(Symbol("⟇")) export $(Symbol("⟇")) @@ -89,9 +92,6 @@ function wedgedot_metric(a::Submanifold{V},b::Single{V},g) where V order(b.v)+order(bas)>diffmode(V) ? Zero(V) : v*bas end -export ∗, ⊛, ⊖ -import AbstractTensors: ⊖, ⊘, ∗ - @doc """ ∗(ω::TensorAlgebra,η::TensorAlgebra) @@ -139,8 +139,6 @@ function ∧(a::X,b::Y) where {X<:TensorTerm{V},Y<:TensorTerm{V}} where V return Single{V}(parity(x,y) ? -v : v,getbasis(V,(A⊻B)|Q)) end -export ∧, ∨, ⟑, wedgedot, veedot, ⊗ - #⊗(a::A,b::B) where {A<:TensorAlgebra,B<:TensorAlgebra} = a∧b ⊗(a::A,b::B) where {A<:TensorGraded,B<:TensorGraded} = Dyadic(a,b) ⊗(a::A,b::B) where {A<:TensorGraded,B<:TensorGraded{V,0} where V} = a*b @@ -196,9 +194,6 @@ Regressive product as defined by the DeMorgan's law: ∨(ω...) = ⋆⁻¹(∧( ## interior product: a ∨ ⋆(b) -import LinearAlgebra: dot, ⋅ -export ⋅ - """ contraction(ω::TensorAlgebra,η::TensorAlgebra) @@ -268,8 +263,6 @@ end end end -export ⨼, ⨽ - @doc """ dot(ω::TensorAlgebra,η::TensorAlgebra) @@ -278,9 +271,6 @@ Interior (right) contraction product: ω⋅η = ω∨⋆η ## cross product -import LinearAlgebra: cross, × -export × - @doc """ cross(ω::TensorAlgebra,η::TensorAlgebra) @@ -289,8 +279,6 @@ Cross product: ω×η = ⋆(ω∧η) # symmetrization and anti-symmetrization -export ⊙, ⊠ - """ ⊙(ω::TensorAlgebra,η::TensorAlgebra) @@ -315,14 +303,12 @@ end ## sandwich product -export ⊘, sandwich, pseudosandwich, antisandwich - ⊘(x::TensorTerm{V},y::TensorTerm{V}) where V = reverse(y)*x*involute(y) ⊘(x::TensorAlgebra{V},y::TensorAlgebra{V}) where V = reverse(y)*x*involute(y) ⊘(x::Couple{V},y::TensorAlgebra{V}) where V = (scalar(x)⊘y)+(imaginary(x)⊘y) ⊘(x::PseudoCouple{V},y::TensorAlgebra{V}) where V = (imaginary(x)⊘y)+(volume(x)⊘y) @generated ⊘(a::TensorGraded{V,G},b::Spinor{V}) where {V,G} = product_sandwich(a,b) -@generated ⊘(a::TensorGraded{V,G},b::AntiSpinor{V}) where {V,G} = product_sandwich(a,b) +@generated ⊘(a::TensorGraded{V,G},b::CoSpinor{V}) where {V,G} = product_sandwich(a,b) @generated ⊘(a::TensorGraded{V,G},b::Couple{V}) where {V,G} = product_sandwich(a,b) @generated ⊘(a::TensorGraded{V,G},b::PseudoCouple{V}) where {V,G} = product_sandwich(a,b) @generated ⊘(a::TensorGraded{V,G},b::TensorGraded{V,L}) where {V,G,L} = product_sandwich(a,b) @@ -330,7 +316,7 @@ export ⊘, sandwich, pseudosandwich, antisandwich isinduced(g) && (return :(a⊘b)) product_sandwich(a,b,false,true) end -@generated function ⊘(a::TensorGraded{V,G},b::AntiSpinor{V},g) where {V,G} +@generated function ⊘(a::TensorGraded{V,G},b::CoSpinor{V},g) where {V,G} isinduced(g) && (return :(a⊘b)) product_sandwich(a,b,false,true) end @@ -360,7 +346,7 @@ For normalized even grade η it is ω⊘η = (~η)⊖ω⊖η >>>(y::TensorAlgebra{V},x::Couple{V}) where V = (y>>>scalar(x))+(y>>>imaginary(x)) >>>(y::TensorAlgebra{V},x::PseudoCouple{V}) where V = (y>>>imaginary(x))+(y>>>volume(x)) @generated >>>(b::Spinor{V},a::TensorGraded{V,G}) where {V,G} = product_sandwich(a,b,true) -@generated >>>(b::AntiSpinor{V},a::TensorGraded{V,G}) where {V,G} = product_sandwich(a,b,true) +@generated >>>(b::CoSpinor{V},a::TensorGraded{V,G}) where {V,G} = product_sandwich(a,b,true) @generated >>>(b::Couple{V},a::TensorGraded{V,G}) where {V,G} = product_sandwich(a,b,true) @generated >>>(b::PseudoCouple{V},a::TensorGraded{V,G}) where {V,G} = product_sandwich(a,b,true) @generated >>>(b::TensorGraded{V,L},a::TensorGraded{V,G}) where {V,G,L} = product_sandwich(a,b,true) @@ -368,7 +354,7 @@ For normalized even grade η it is ω⊘η = (~η)⊖ω⊖η isinduced(g) && (return :(b>>>a)) product_sandwich(a,b,true,true) end -@generated function >>>(b::AntiSpinor{V},a::TensorGraded{V,G},g) where {V,G} +@generated function >>>(b::CoSpinor{V},a::TensorGraded{V,G},g) where {V,G} isinduced(g) && (return :(b>>>a)) product_sandwich(a,b,true,true) end @@ -405,8 +391,6 @@ antidot_metric(a,b) = complementleft(contraction_metric(complementright(a),compl ## linear algebra -export ⟂, ∥ - ∥(a,b) = iszero(a∧b) ## exponentiation @@ -511,7 +495,7 @@ for (nv,d) ∈ ((:inv,:/),(:inv_rat,://)) throw(error("inv($m) is undefined")) end end - for pinor ∈ (:Spinor,:AntiSpinor) + for pinor ∈ (:Spinor,:CoSpinor) @eval begin function $nv(m::$pinor{V,T},$(args...)) where {V,T} rm = ~m @@ -800,7 +784,7 @@ adder(a,b,op=:+) = adder(typeof(a),typeof(b),op) end end end @noinline function adderanti(a::Type{<:TensorTerm{V,L}},b::Type{<:TensorTerm{V,G}},op) where {V,L,G} - (iseven(L) || iseven(G)) && (return :(error("$(basis(a)) and $(basis(b)) are not expressible as AntiSpinor"))) + (iseven(L) || iseven(G)) && (return :(error("$(basis(a)) and $(basis(b)) are not expressible as CoSpinor"))) left,bop,VEC = addvec(a,b,false,op) if mdims(V)-1,:(G+L),:exter),(:∨,:<,:(G+L-mdims(V)),:meet end end -for input ∈ (:Multivector,:Spinor,:AntiSpinor) - inspin,inanti = input==:Spinor,input==:AntiSpinor +for input ∈ (:Multivector,:Spinor,:CoSpinor) + inspin,inanti = input==:Spinor,input==:CoSpinor for (op,product) ∈ ((:∧,:exteradd),(:*,:geomadd), (:∨,:meetadd),(:contraction,:skewadd)) outspin = product ∈ (:exteradd,:geomadd,:skewadd) outmulti = input == :Multivector - outype = outmulti ? :Multivector : outspin ? :($(inspin ? :isodd : :iseven)(G) ? AntiSpinor : Spinor) : inspin ? :(isodd(G)⊻isodd(N) ? AntiSpinor : Spinor) : :(isodd(G)⊻isodd(N) ? Spinor : AntiSpinor) + outype = outmulti ? :Multivector : outspin ? :($(inspin ? :isodd : :iseven)(G) ? CoSpinor : Spinor) : inspin ? :(isodd(G)⊻isodd(N) ? CoSpinor : Spinor) : :(isodd(G)⊻isodd(N) ? Spinor : CoSpinor) product! = outmulti ? Symbol(product,:multi!) : outspin ? :($(inspin ? :isodd : :iseven)(G) ? $(Symbol(product,:anti!)) : $(Symbol(product,:spin!))) : :(isodd(G)⊻isodd(N) ? $(Symbol(product,outspin⊻inspin ? :anti! : :spin!)) : $(Symbol(product,outspin⊻inspin ? :spin! : :anti!))) preproduct! = outmulti ? Symbol(product,:multi!_pre) : outspin ? :($(inspin ? :isodd : :iseven)(G) ? $(Symbol(product,:anti!_pre)) : $(Symbol(product,:spin!_pre))) : :(isodd(G)⊻isodd(N) ? $(Symbol(product,outspin⊻inspin ? :anti!_pre : :spin!_pre)) : $(Symbol(product,outspin⊻inspin ? :spin!_pre : :anti!_pre))) prop = op≠:* ? Symbol(:product_,op) : :product @@ -1453,9 +1437,9 @@ for (op,product) ∈ ((:∧,:exteradd),(:*,:geomadd), end end -for input ∈ (:Spinor,:AntiSpinor) +for input ∈ (:Spinor,:CoSpinor) inspin = input==:Spinor - outype = :($(inspin ? :isodd : :iseven)(G) ? AntiSpinor : Spinor) + outype = :($(inspin ? :isodd : :iseven)(G) ? CoSpinor : Spinor) product! = :($(inspin ? :isodd : :iseven)(G) ? geomaddanti! : geomaddspin!) preproduct! = :($(inspin ? :isodd : :iseven)(G) ? geomaddanti!_pre : geomaddspin!_pre) product2! = :(isodd(G) ? geomaddanti! : geomaddspin!) diff --git a/src/composite.jl b/src/composite.jl index 3239f59..92acd57 100644 --- a/src/composite.jl +++ b/src/composite.jl @@ -15,6 +15,7 @@ export exph, log_fast, logh_fast, pseudoexp, pseudolog, pseudometric, pseudodot, @pseudo export pseudoabs, pseudoabs2, pseudosqrt, pseudocbrt, pseudoinv, pseudoscalar export pseudocos, pseudosin, pseudotan, pseudocosh, pseudosinh, pseudotanh +export vandermonde, volumes, detsimplex, submesh ## exponential & logarithm function @@ -297,7 +298,7 @@ for (op,logm,field) ∈ ((:⟑,:(Base.log),false),(:wedgedot_metric,:log_metric, args = field ? (:g,) : () indu(t=:(log(t))) = field ? :(isinduced(g) && (return :($$t))) : nothing @eval qlog(b::PseudoCouple,$(args...),x::Int=10000) = qlog(multispin(b),$(args...),x) -@eval qlog(b::AntiSpinor,$(args...),x::Int=10000) = qlog(Multivector(b),$(args...),x) +@eval qlog(b::CoSpinor,$(args...),x::Int=10000) = qlog(Multivector(b),$(args...),x) @eval function qlog(w::T,$(args...),x::Int=10000) where T<:TensorAlgebra $(indu(:(qlog(w,x)))) V = Manifold(w) @@ -319,7 +320,7 @@ for (op,logm,field) ∈ ((:⟑,:(Base.log),false),(:wedgedot_metric,:log_metric, end # http://www.netlib.org/cephes/qlibdoc.html#qlog @eval qlog_fast(b::PseudoCouple,$(args...),x::Int=10000) = qlog_fast(multispin(b),$(args...),x) -@eval qlog_fast(b::AntiSpinor,$(args...),x::Int=10000) = qlog_fast(Multivector(b),$(args...),x) +@eval qlog_fast(b::CoSpinor,$(args...),x::Int=10000) = qlog_fast(Multivector(b),$(args...),x) for pinor ∈ (:Multivector,:Spinor); VEC = pinor≠:Spinor ? :mvec : :mvecs @eval @generated function qlog_fast(b::$pinor{V,T,E},$(args...),x::Int=10000) where {V,T,E} $(indu(:(qlog_fast(b,x)))) @@ -387,17 +388,17 @@ end end @eval begin - Base.exp(t::AntiSpinor,$(args...)) = exp(Multivector(t),$(args...)) - Base.expm1(t::AntiSpinor,$(args...)) = expm1(Multivector(t),$(args...)) - $logm(t::AntiSpinor,$(args...)) = $logm(Multivector(t),$(args...)) - Base.log1p(t::AntiSpinor,$(args...)) = log1p(Multivector(t),$(args...)) - log_fast(t::AntiSpinor,$(args...)) = log_fast(Multivector(t),$(args...)) - logh_fast(t::AntiSpinor,$(args...)) = logh_fast(Multivector(t),$(args...)) + Base.exp(t::CoSpinor,$(args...)) = exp(Multivector(t),$(args...)) + Base.expm1(t::CoSpinor,$(args...)) = expm1(Multivector(t),$(args...)) + $logm(t::CoSpinor,$(args...)) = $logm(Multivector(t),$(args...)) + Base.log1p(t::CoSpinor,$(args...)) = log1p(Multivector(t),$(args...)) + log_fast(t::CoSpinor,$(args...)) = log_fast(Multivector(t),$(args...)) + logh_fast(t::CoSpinor,$(args...)) = logh_fast(Multivector(t),$(args...)) end for op ∈ (:cosh,:sinh) @eval begin Base.$op(t::PseudoCouple,$(args...)) = $op(multispin(t),$(args...)) - Base.$op(t::AntiSpinor,$(args...)) = $op(Multivector(t),$(args...)) + Base.$op(t::CoSpinor,$(args...)) = $op(Multivector(t),$(args...)) end end @@ -825,8 +826,6 @@ Base.in(v::Chain{V,1},t::Chain{W,1,<:Chain{V,1}}) where {V,W} = v ∈ value(t) Base.inv(t::Chain{V,1,<:Chain{W,1}}) where {W,V} = inv(value(t)) grad(t::Chain{V,1,<:Chain{W,1}}) where {V,W} = grad(value(t)) -export vandermonde - @generated approx(x,y::Chain{V}) where V = :(polynom(x,$(Val(mdims(V))))⋅y) approx(x,y::Values{N}) where N = value(polynom(x,Val(N)))⋅y approx(x,y::AbstractVector) = [x^i for i ∈ 0:length(y)-1]⋅y @@ -906,8 +905,6 @@ function Base.findlast(P,t::ChainBundle) end Base.findall(P,t) = findall(P .∈ getindex.(points(t),value(t))) -export volumes, detsimplex, submesh - edgelength(e) = (v=points(e)[value(e)]; value(abs(v[2]-v[1]))) volumes(m,dets) = value.(abs.(.⋆(dets))) volumes(m) = mdims(Manifold(m))≠2 ? volumes(m,detsimplex(m)) : edgelength.(value(m)) @@ -1007,7 +1004,7 @@ for op ∈ (:div,:rem,:mod,:mod1,:fld,:fld1,:cld,:ldexp) Base.$op(a::PseudoCouple{V,B},m) where {V,B} = PseudoCouple{V,B}($op(value(a),m)) Base.$op(a::Chain{V,G,T},m) where {V,G,T} = Chain{V,G}($op.(value(a),m)) Base.$op(a::Spinor{V,T},m) where {T,V} = Spinor{V}($op.(value(a),m)) - Base.$op(a::AntiSpinor{V,T},m) where {T,V} = AntiSpinor{V}($op.(value(a),m)) + Base.$op(a::CoSpinor{V,T},m) where {T,V} = CoSpinor{V}($op.(value(a),m)) Base.$op(a::Multivector{V,T},m) where {T,V} = Multivector{V}($op.(value(a),m)) end end @@ -1017,20 +1014,20 @@ for op ∈ (:mod2pi,:rem2pi,:rad2deg,:deg2rad,:round) Base.$op(a::PseudoCouple{V,B};args...) where {V,B} = PseudoCouple{V,B}($op(value(a);args...)) Base.$op(a::Chain{V,G,T};args...) where {V,G,T} = Chain{V,G}($op.(value(a);args...)) Base.$op(a::Spinor{V,T};args...) where {V,T} = Spinor{V}($op.(value(a);args...)) - Base.$op(a::AntiSpinor{V,T};args...) where {V,T} = AntiSpinor{V}($op.(value(a);args...)) + Base.$op(a::CoSpinor{V,T};args...) where {V,T} = CoSpinor{V}($op.(value(a);args...)) Base.$op(a::Multivector{V,T};args...) where {V,T} = Multivector{V}($op.(alue(a);args...)) end end Base.isfinite(a::Chain) = prod(isfinite.(value(a))) Base.isfinite(a::Spinor) = prod(isfinite.(value(a))) -Base.isfinite(a::AntiSpinor) = prod(isfinite.(value(a))) +Base.isfinite(a::CoSpinor) = prod(isfinite.(value(a))) Base.isfinite(a::Multivector) = prod(isfinite.(value(a))) Base.isfinite(a::Couple) = isfinite(value(a)) Base.isfinite(a::PseudoCouple) = isfinite(value(a)) Base.rationalize(t::Type,a::Chain{V,G,T};tol::Real=eps(T)) where {V,G,T} = Chain{V,G}(rationalize.(t,value(a),tol)) Base.rationalize(t::Type,a::Multivector{V,T};tol::Real=eps(T)) where {V,T} = Multivector{V}(rationalize.(t,value(a),tol)) Base.rationalize(t::Type,a::Spinor{V,T};tol::Real=eps(T)) where {V,T} = Spinor{V}(rationalize.(t,value(a),tol)) -Base.rationalize(t::Type,a::AntiSpinor{V,T};tol::Real=eps(T)) where {V,T} = AntiSpinor{V}(rationalize.(t,value(a),tol)) +Base.rationalize(t::Type,a::CoSpinor{V,T};tol::Real=eps(T)) where {V,T} = CoSpinor{V}(rationalize.(t,value(a),tol)) Base.rationalize(t::Type,a::Couple{V,B};tol::Real=eps(T)) where {V,B} = Couple{V,B}(rationalize(t,value(a),tol)) Base.rationalize(t::Type,a::PseudoCouple{V,B};tol::Real=eps(T)) where {V,B} = PseudoCouple{V,B}(rationalize(t,value(a),tol)) Base.rationalize(t::T;kvs...) where T<:TensorAlgebra = rationalize(Int,t;kvs...) @@ -1067,7 +1064,7 @@ end Base.map(fn, x::Multivector{V}) where V = Multivector{V}(map(fn, value(x))) Base.map(fn, x::Spinor{V}) where V = Spinor{V}(map(fn, value(x))) -Base.map(fn, x::AntiSpinor{V}) where V = AntiSpinor{V}(map(fn, value(x))) +Base.map(fn, x::CoSpinor{V}) where V = CoSpinor{V}(map(fn, value(x))) Base.map(fn, x::Chain{V,G}) where {V,G} = Chain{V,G}(map(fn,value(x))) Base.map(fn, x::TensorTerm) = fn(value(x))*basis(x) Base.map(fn, x::Couple{V,B}) where {V,B} = Couple{V,B}(Complex(fn(x.v.re),fn(x.v.im))) @@ -1085,9 +1082,9 @@ Base.rand(::AbstractRNG,::SamplerType{Multivector{V,T}}) where {V,T} = Multivect Base.rand(::AbstractRNG,::SamplerType{Spinor}) = rand(Spinor{rand(Manifold)}) Base.rand(::AbstractRNG,::SamplerType{Spinor{V}}) where V = Spinor{V}(DirectSum.orand(svecs(mdims(V),Float64))) Base.rand(::AbstractRNG,::SamplerType{Spinor{V,T}}) where {V,T} = Spinor{V}(rand(svecs(mdims(V),T))) -Base.rand(::AbstractRNG,::SamplerType{AntiSpinor}) = rand(AntiSpinor{rand(Manifold)}) -Base.rand(::AbstractRNG,::SamplerType{AntiSpinor{V}}) where V = AntiSpinor{V}(DirectSum.orand(svecs(mdims(V),Float64))) -Base.rand(::AbstractRNG,::SamplerType{AntiSpinor{V,T}}) where {V,T} = AntiSpinor{V}(rand(svecs(mdims(V),T))) +Base.rand(::AbstractRNG,::SamplerType{CoSpinor}) = rand(CoSpinor{rand(Manifold)}) +Base.rand(::AbstractRNG,::SamplerType{CoSpinor{V}}) where V = CoSpinor{V}(DirectSum.orand(svecs(mdims(V),Float64))) +Base.rand(::AbstractRNG,::SamplerType{CoSpinor{V,T}}) where {V,T} = CoSpinor{V}(rand(svecs(mdims(V),T))) Base.rand(::AbstractRNG,::SamplerType{Couple}) = rand(Couple{rand(Manifold)}) Base.rand(::AbstractRNG,::SamplerType{Couple{V}}) where V = rand(Couple{V,Submanifold{V}(UInt(rand(1:1<!iszero(x),t[2])]) diff --git a/src/parity.jl b/src/parity.jl index b1a023e..8559c02 100644 --- a/src/parity.jl +++ b/src/parity.jl @@ -24,8 +24,8 @@ export complementleftanti, complementrightanti ## reverse -import Base: reverse, conj, ~ -export involute, clifford, pseudoreverse, antireverse +import Base: reverse, conj, ~, signbit, imag, real +export involute, clifford, pseudoreverse, antireverse, odd, even, angular, radial, ₊, ₋, ǂ ## product parities @@ -420,9 +420,6 @@ for par ∈ (:conformal,:regressive,:interior) end end -import Base: signbit, imag, real -export odd, even, angular, radial, ₊, ₋, ǂ - @pure signbit(V::T) where T<:Manifold = (ib=indexbasis(rank(V)); parity.(Ref(V),ib,ib)) @pure signbit(V::T,G) where T<:Manifold = (ib=indexbasis(rank(V),G); parity.(Ref(V),ib,ib)) @pure angular(V::T) where T<:Manifold = Values(findall(signbit(V))...) @@ -448,9 +445,9 @@ Base.isodd(t::Zero) = true Base.iseven(t::TensorGraded{V,G}) where {V,G} = iseven(G) ? true : iszero(t) Base.isodd(t::TensorGraded{V,G}) where {V,G} = isodd(G) ? true : iszero(t) Base.iseven(t::Spinor) = true -Base.iseven(t::AntiSpinor) = iszero(t) +Base.iseven(t::CoSpinor) = iszero(t) Base.isodd(t::Spinor) = iszero(t) -Base.isodd(t::AntiSpinor) = true +Base.isodd(t::CoSpinor) = true Base.iseven(t::Couple{V,B}) where {V,B} = iseven(grade(B)) ? true : iszero(imaginary(t)) Base.isodd(t::Couple{V,B}) where {V,B} = isodd(grade(B)) ? iszero(scalar(t)) : iszero(t) Base.iseven(t::PseudoCouple{V,B}) where {V,B} = iseven(imaginary(t)) && iseven(volume(t)) @@ -458,10 +455,10 @@ Base.isodd(t::PseudoCouple{V,B}) where {V,B} = isodd(imaginary(t)) && isodd(volu Base.iseven(t::Multivector) = norm(t) ≈ norm(even(t)) Base.isodd(t::Multivector) = norm(t) ≈ norm(odd(t)) -even(t::AntiSpinor{V}) where V = Zero{V}() +even(t::CoSpinor{V}) where V = Zero{V}() odd(t::Spinor{V}) where V = Zero{V}() even(t::Spinor) = t -odd(t::AntiSpinor) = t +odd(t::CoSpinor) = t even(t::Couple{V,B}) where {V,B} = iseven(grade(B)) ? t : scalar(t) odd(t::Couple{V,B}) where {V,B} = isodd(grade(B)) ? imaginary(t) : Zero{V}() even(t::PseudoCouple{V,B}) where {V,B} = even(imaginary(t)) + even(volume(t)) diff --git a/src/products.jl b/src/products.jl index f1a9a1b..2bfdad2 100644 --- a/src/products.jl +++ b/src/products.jl @@ -490,13 +490,13 @@ plus(b::Multivector{V},a::Submanifold{V,G}) where {V,G} = plus(a,b) plus(b::Multivector{V},a::Single{V,G}) where {V,G} = plus(a,b) plus(b::Spinor{V},a::Submanifold{V,G}) where {V,G} = plus(a,b) plus(b::Spinor{V},a::Single{V,G}) where {V,G} = plus(a,b) -plus(b::AntiSpinor{V},a::Submanifold{V,G}) where {V,G} = plus(a,b) -plus(b::AntiSpinor{V},a::Single{V,G}) where {V,G} = plus(a,b) +plus(b::CoSpinor{V},a::Submanifold{V,G}) where {V,G} = plus(a,b) +plus(b::CoSpinor{V},a::Single{V,G}) where {V,G} = plus(a,b) -(t::Submanifold) = Single(-value(t),t) -(a::Chain{V,G}) where {V,G} = Chain{V,G}(-value(a)) -(a::Multivector{V}) where V = Multivector{V}(-value(a)) -(a::Spinor{V}) where V = Spinor{V}(-value(a)) --(a::AntiSpinor{V}) where V = AntiSpinor{V}(-value(a)) +-(a::CoSpinor{V}) where V = CoSpinor{V}(-value(a)) -(a::Couple{V,B}) where {V,B} = Couple{V,B}(-a.v) -(a::PseudoCouple{V,B}) where {V,B} = PseudoCouple{V,B}(-a.v) ⟑(a::Single{V,0},b::Chain{V,G}) where {V,G} = Chain{V,G}(a.v*b.v) @@ -537,8 +537,8 @@ for (op,po) ∈ ((:plus,:+),(:minus,:-)) $op(a::Couple{V},b::PseudoCouple{V}) where V = $op($op(a,imaginary(b)),volume(b)) $op(a::PseudoCouple{V},b::Couple{V}) where V = $op(imaginary(a),b)+volume(a) $op(a::Phasor{V},b::Phasor{V}) where V = $op(Couple(a),Couple(b)) - $op(a::Spinor{V},b::AntiSpinor{V}) where V = $op(Multivector(a),Multivector(b)) - $op(a::AntiSpinor{V},b::Spinor{V}) where V = $op(Multivector(a),Multivector(b)) + $op(a::Spinor{V},b::CoSpinor{V}) where V = $op(Multivector(a),Multivector(b)) + $op(a::CoSpinor{V},b::Spinor{V}) where V = $op(Multivector(a),Multivector(b)) end end @@ -683,8 +683,8 @@ for (couple,calar) ∈ ((:Couple,:scalar),(:PseudoCouple,:volume)) $op(a::$couple{V},b::Multivector{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) $op(a::Spinor{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) $op(a::$couple{V},b::Spinor{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) - $op(a::AntiSpinor{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) - $op(a::$couple{V},b::AntiSpinor{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) + $op(a::CoSpinor{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) + $op(a::$couple{V},b::CoSpinor{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) $op(a::Chain{V,G},b::$couple{V},$(args...)) where {V,G} = (G==0 || G==mdims(V)) ? $op(Single(a),b,$(args...)) : $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) $op(a::$couple{V},b::Chain{V,G},$(args...)) where {V,G} = (G==0 || G==mdims(V)) ? $op(a,Single(b),$(args...)) : $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) $op(a::TensorTerm{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) @@ -705,8 +705,8 @@ for (couple,calar) ∈ ((:Couple,:scalar),(:PseudoCouple,:volume)) ∧(a::$couple{V},b::Multivector{V}) where V = ($calar(a)∧b) + (imaginary(a)∧b) ∧(a::Spinor{V},b::$couple{V}) where V = (a∧$calar(b)) + (a∧imaginary(b)) ∧(a::$couple{V},b::Spinor{V}) where V = ($calar(a)∧b) + (imaginary(a)∧b) - ∧(a::AntiSpinor{V},b::$couple{V}) where V = (a∧$calar(b)) + (a∧imaginary(b)) - ∧(a::$couple{V},b::AntiSpinor{V}) where V = ($calar(a)∧b) + (imaginary(a)∧b) + ∧(a::CoSpinor{V},b::$couple{V}) where V = (a∧$calar(b)) + (a∧imaginary(b)) + ∧(a::$couple{V},b::CoSpinor{V}) where V = ($calar(a)∧b) + (imaginary(a)∧b) ∧(a::Chain{V},b::$couple{V}) where V = (a∧$calar(b)) + (a∧imaginary(b)) ∧(a::$couple{V},b::Chain{V}) where V = ($calar(a)∧b) + (imaginary(a)∧b) ∧(a::TensorTerm{V,0},b::$couple{V}) where V = a⟑b @@ -732,8 +732,8 @@ for (couple,calar) ∈ ((:Couple,:scalar),(:PseudoCouple,:volume)) ∨(a::$couple{V},b::Multivector{V}) where V = ($calar(a)∨b) + (imaginary(a)∨b) ∨(a::Spinor{V},b::$couple{V}) where V = (a∨$calar(b)) + (a∨imaginary(b)) ∨(a::$couple{V},b::Spinor{V}) where V = ($calar(a)∨b) + (imaginary(a)∨b) - ∨(a::AntiSpinor{V},b::$couple{V}) where V = (a∨$calar(b)) + (a∨imaginary(b)) - ∨(a::$couple{V},b::AntiSpinor{V}) where V = ($calar(a)∨b) + (imaginary(a)∨b) + ∨(a::CoSpinor{V},b::$couple{V}) where V = (a∨$calar(b)) + (a∨imaginary(b)) + ∨(a::$couple{V},b::CoSpinor{V}) where V = ($calar(a)∨b) + (imaginary(a)∨b) ∨(a::Chain{V},b::$couple{V}) where V = (a∨$calar(b)) + (a∨imaginary(b)) ∨(a::$couple{V},b::Chain{V}) where V = ($calar(a)∨b) + (imaginary(a)∨b) end @@ -766,8 +766,8 @@ for (couple,calar) ∈ ((:Couple,:scalar),(:PseudoCouple,:volume)) $op(a::$couple{V},b::Multivector{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) $op(a::Spinor{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) $op(a::$couple{V},b::Spinor{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) - $op(a::AntiSpinor{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) - $op(a::$couple{V},b::AntiSpinor{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) + $op(a::CoSpinor{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) + $op(a::$couple{V},b::CoSpinor{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) $op(a::Chain{V},b::$couple{V},$(args...)) where V = $op(a,$calar(b),$(args...)) + $op(a,imaginary(b),$(args...)) $op(a::$couple{V},b::Chain{V},$(args...)) where V = $op($calar(a),b,$(args...)) + $op(imaginary(a),b,$(args...)) $op(a::$couple{V},b::TensorTerm{V,0},$(args...)) where V = a⟑b @@ -813,8 +813,8 @@ for F ∈ Fields *(a::Multivector{V},b::F) where {F<:$F,V} = Multivector{V}(a.v*b) *(a::F,b::Spinor{V}) where {F<:$F,V} = Spinor{V}(a*b.v) *(a::Spinor{V},b::F) where {F<:$F,V} = Spinor{V}(a.v*b) - *(a::F,b::AntiSpinor{V}) where {F<:$F,V} = AntiSpinor{V}(a*b.v) - *(a::AntiSpinor{V},b::F) where {F<:$F,V} = AntiSpinor{V}(a.v*b) + *(a::F,b::CoSpinor{V}) where {F<:$F,V} = CoSpinor{V}(a*b.v) + *(a::CoSpinor{V},b::F) where {F<:$F,V} = CoSpinor{V}(a.v*b) *(a::F,b::Chain{V,G}) where {F<:$F,V,G} = Chain{V,G}(a*b.v) *(a::Chain{V,G},b::F) where {F<:$F,V,G} = Chain{V,G}(a.v*b) *(a::F,b::Single{V,G,B,T} where B) where {F<:$F,V,G,T} = Single{V,G}($Sym.:∏(a,b.v),basis(b)) @@ -848,7 +848,7 @@ for (op,po) ∈ ((:+,:plus),(:-,:minus)) @generated function $po(a::TensorTerm{V,G},b::Spinor{V,T}) where {V,G,T} adder(a,b,$(QuoteNode(op))) end - @generated function $po(a::TensorTerm{V,G},b::AntiSpinor{V,T}) where {V,G,T} + @generated function $po(a::TensorTerm{V,G},b::CoSpinor{V,T}) where {V,G,T} adder(a,b,$(QuoteNode(op))) end end @@ -856,7 +856,7 @@ end @generated minus(b::Chain{V,G,T},a::TensorTerm{V,G}) where {V,G,T} = adder(a,b,:-,true) @generated minus(b::Chain{V,G,T},a::TensorTerm{V,L}) where {V,G,T,L} = adder(a,b,:-,true) @generated minus(b::Spinor{V,T},a::TensorTerm{V,G}) where {V,G,T} = adder(a,b,:-,true) -@generated minus(b::AntiSpinor{V,T},a::TensorTerm{V,G}) where {V,G,T} = adder(a,b,:-,true) +@generated minus(b::CoSpinor{V,T},a::TensorTerm{V,G}) where {V,G,T} = adder(a,b,:-,true) @generated minus(b::Multivector{V,T},a::TensorTerm{V,G}) where {V,G,T} = adder(a,b,:-,true) @eval begin @@ -953,7 +953,7 @@ end Spinor{dual(V)}(out) end end end - @generated function Base.adjoint(m::AntiSpinor{V,T}) where {V,T} + @generated function Base.adjoint(m::CoSpinor{V,T}) where {V,T} CONJ,VEC = conjvec(m) TF = T ∉ FieldsBig ? :Any : :T if mdims(V)