diff --git a/Project.toml b/Project.toml index baa044f..0e4ffa4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Grassmann" uuid = "4df31cd9-4c27-5bea-88d0-e6a7146666d8" authors = ["Michael Reed"] -version = "0.8.16" +version = "0.8.17" [deps] AbstractTensors = "a8e43f4a-99b7-5565-8bf1-0165161caaea" @@ -17,7 +17,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" julia = "1" Leibniz = "0.2" DirectSum = "0.8.1" -AbstractTensors = "0.7.7" +AbstractTensors = "0.8" ComputedFieldTypes = "1" Requires = "1" diff --git a/src/composite.jl b/src/composite.jl index 51c317a..dc81447 100644 --- a/src/composite.jl +++ b/src/composite.jl @@ -1085,7 +1085,7 @@ Base.rand(::AbstractRNG,::SamplerType{PseudoCouple{V,B,T} where B}) where {V,T} # Dyadic -export operator, gradedoperator +export operator, gradedoperator, evenoperator, oddoperator @generated function operator(t::TensorAlgebra{V},::Val{G}=Val(1)) where {V,G} N = mdims(V) @@ -1104,3 +1104,11 @@ gradedoperator(t::TensorAlgebra{V}) where V = Multivector{V}(Λ(V).b .⊘ Ref(t) end operator(fun,V,G::Int) = operator(fun,V,Val(G)) gradedoperator(fun,V) = Multivector{V}(fun.(Λ(V).b)) + +@pure function evenbasis(V,even=true) + N = mdims(V) + r,b = binomsum_set(N),binomial_set(N) + vcat([Λ(V).b[list(r[g]+1,r[g]+b[g])] for g ∈ evens(even ? 1 : 2,N+1)]...) +end +evenoperator(t::TensorAlgebra{V}) where V = Spinor{V}(evenbasis(V) .⊘ Ref(t)) +oddoperator(t::TensorAlgebra{V}) where V = AntiSpinor{V}(evenbasis(V,false) .⊘ Ref(t)) diff --git a/src/multivectors.jl b/src/multivectors.jl index b46e31e..81c0a94 100644 --- a/src/multivectors.jl +++ b/src/multivectors.jl @@ -23,7 +23,7 @@ import AbstractTensors: TensorTerm, TensorGraded, TensorMixed, equal import Leibniz: grade, antigrade, showvalue, basis, order export TensorNested -abstract type TensorNested{V} <: Manifold{V} end +abstract type TensorNested{V,T} <: Manifold{V,T} end for op ∈ (:(Base.:+),:(Base.:-)) @eval begin @@ -59,15 +59,15 @@ export UniformScaling, I, points ## Chain{V,G,𝕂} -@computed struct Chain{V,G,𝕂} <: TensorGraded{V,G} - v::Values{binomial(mdims(V),G),𝕂} - Chain{V,G,𝕂}(v) where {V,G,𝕂} = new{DirectSum.submanifold(V),G,𝕂}(v) +@computed struct Chain{V,G,T} <: TensorGraded{V,G,T} + v::Values{binomial(mdims(V),G),T} + Chain{V,G,T}(v) where {V,G,T} = new{DirectSum.submanifold(V),G,T}(v) end """ - Chain{V,G,𝕂} <: TensorGraded{V,G} <: TensorAlgebra{V} + Chain{V,G,T} <: TensorGraded{V,G,T} <: TensorAlgebra{V,T} -Chain type with pseudoscalar `V::Manifold`, grade/rank `G::Int`, scalar field `𝕂::Type`. +Chain type with pseudoscalar `V::Manifold`, grade/rank `G::Int`, scalar field `T::Type`. """ Chain{V,G}(val::S) where {V,G,S<:AbstractVector{𝕂}} where 𝕂 = Chain{V,G,𝕂}(val) Chain{V,G}(val::NTuple{N,T}) where {V,G,N,T} = Chain{V,G}(Values{N,T}(val)) @@ -85,6 +85,7 @@ Chain(v::Chain{V,G,𝕂}) where {V,G,𝕂} = v DyadicProduct{V,W,G,T,N} = Chain{V,G,Chain{W,G,T,N},N} DyadicChain{V,G,T,N} = DyadicProduct{V,V,G,T,N} +Base.Matrix(m::Chain{V,G,<:TensorGraded{W,G}}) where {V,W,G} = hcat(value.(Chain.(value(m)))...) Base.Matrix(m::Chain{V,G,<:Chain{W,G}}) where {V,W,G} = hcat(value.(value(m))...) DyadicChain(m::Matrix) = Chain{Submanifold(size(m)[1]),1}(m) function Chain{V,G}(m::Matrix) where {V,G} @@ -203,12 +204,12 @@ Base.ones(::Type{Chain{V,G,T,X}}) where {V,G,T<:Chain,X} = Chain{V,G,T}(ones.(nt ⊗(a::Type{<:Chain{V,1}},b::Type{<:Chain{W,1,T}}) where {V,W,T} = Chain{V,1,Chain{W,1,T,mdims(W)},mdims(V)} """ - ChainBundle{V,G,P} <: Manifold{V} <: TensorAlgebra{V} + ChainBundle{V,G,T,P} <: Manifold{V,T} <: TensorAlgebra{V,T} Subsets of a bundle cross-section over a `Manifold` topology. """ -struct ChainBundle{V,G,𝕂,Points} <: Manifold{V} - @pure ChainBundle{V,G,𝕂,P}() where {V,G,𝕂,P} = new{DirectSum.submanifold(V),G,𝕂,P}() +struct ChainBundle{V,G,T,Points} <: Manifold{V,T} + @pure ChainBundle{V,G,T,P}() where {V,G,T,P} = new{DirectSum.submanifold(V),G,T,P}() end const bundle_cache = (Vector{Chain{V,G,T,X}} where {V,G,T,X})[] @@ -253,7 +254,6 @@ end value(c::Vector{<:Chain}) = c value(::ChainBundle{V,G,T,P}) where {V,G,T,P} = bundle_cache[P]::(Vector{Chain{V,G,T,binomial(mdims(V),G)}}) -AbstractTensors.valuetype(::ChainBundle{V,G,T} where {V,G}) where T = T getindex(m::ChainBundle,i::I) where I<:Integer = getindex(value(m),i) getindex(m::ChainBundle,i) = getindex(value(m),i) @@ -271,17 +271,17 @@ Base.display(m::ChainBundle) = (print(showbundle(m));display(value(m))) Base.show(io::IO,m::ChainBundle) = print(io,showbundle(m),length(m)) @pure showbundle(m::ChainBundle{V,G}) where {V,G} = "$(iscell(m) ? 'C' : islocal(m) ? 'I' : 'Λ')$(DirectSum.sups[G])$V×" -## Multivector{V,𝕂} +## Multivector{V,T} -@computed struct Multivector{V,𝕂} <: TensorMixed{V} - v::Values{1<