Skip to content

Commit

Permalink
upgraded to AbstractTensors v0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Apr 23, 2024
1 parent 1170cc0 commit d2268bb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ environment:
- julia_version: 1.6
- julia_version: 1.7
- julia_version: 1.8
- julia_version: 1.9
- julia_version: 1.10
- julia_version: nightly

platform:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DirectSum"
uuid = "22fd7b30-a8c0-5bf2-aabe-97783860d07c"
authors = ["Michael Reed"]
version = "0.8.10"
version = "0.8.11"

[deps]
ComputedFieldTypes = "459fdd68-db75-56b8-8c15-d717a790f88e"
Expand All @@ -13,7 +13,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[compat]
julia = "1"
Leibniz = "0.2"
AbstractTensors = "0.7"
AbstractTensors = "0.8"
ComputedFieldTypes = "1"

[extras]
Expand Down
25 changes: 10 additions & 15 deletions src/DirectSum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Leibniz: parityrightnull, parityleftnull, parityrightnullpre, parityleftn
import Leibniz: hasconformal, parval, TensorTerm, mixed, subs, sups, vio

import Leibniz: grade, order, options, metric, polymode, dyadmode, diffmode, diffvars
import Leibniz: antigrade, hasinf, hasorigin, norm, indices, isbasis, Bits, bits,
import Leibniz: pseudograde, hasinf, hasorigin, norm, indices, isbasis, Bits, bits,
import Leibniz: isdyadic, isdual, istangent, involute, basis, alphanumv, alphanumw

import Leibniz: algebra_limit, sparse_limit, cache_limit, fill_limit
Expand All @@ -59,7 +59,7 @@ The type `TensorBundle{n,ℙ,g,ν,μ}` uses *byte-encoded* data available at pre
and `μ` is an integer specifying the order of the tangent bundle (i.e. multiplicity limit of Leibniz-Taylor monomials).
Lastly, `ν` is the number of tangent variables.
"""
abstract type TensorBundle{n,Options,Metrics,Vars,Diff,Name} <: Manifold{n} end
abstract type TensorBundle{n,Options,Metrics,Vars,Diff,Name} <: Manifold{n,Int} end
rank(::TensorBundle{n}) where n = n
mdims(M::TensorBundle) = rank(M)

Expand Down Expand Up @@ -205,7 +205,7 @@ end
Basis type with pseudoscalar `V::Manifold`, grade/rank `G::Int`, bits `B::UInt64`.
"""
struct Submanifold{V,n,Indices} <: TensorTerm{V,n}
struct Submanifold{V,n,Indices} <: TensorTerm{V,n,Int}
@pure Submanifold{V,n,S}() where {V,n,S} = new{V,n,S}()
end

Expand Down Expand Up @@ -376,11 +376,11 @@ for n ∈ 0:9
end

"""
Single{V,G,B,𝕂} <: TensorTerm{V,G} <: TensorGraded{V,G}
Single{V,G,B,T} <: TensorTerm{V,G,T} <: TensorGraded{V,G,T}
Single type with pseudoscalar `V::Manifold`, grade/rank `G::Int`, `B::Submanifold{V,G}`, field `𝕂::Type`.
Single type with pseudoscalar `V::Manifold`, grade/rank `G::Int`, `B::Submanifold{V,G}`, field `T::Type`.
"""
struct Single{V,G,B,T} <: TensorTerm{V,G}
struct Single{V,G,B,T} <: TensorTerm{V,G,T}
v::T
Single{A,B,C,D}(t) where {A,B,C,D} = new{submanifold(A),B,basis(C),D}(t)
Single{A,B,C,D}(t::E) where E<:TensorAlgebra{A} where {A,B,C,D} = new{submanifold(A),B,basis(C),D}(t)
Expand Down Expand Up @@ -482,7 +482,7 @@ export Zero, One
Null quantity `Zero` of the `Grassmann` algebra over `V`.
"""
struct Zero{V} <: TensorTerm{V,0}
struct Zero{V} <: TensorTerm{V,0,Int}
@pure Zero{V}() where V = new{submanifold(V)}()
end
@pure Zero(V::T) where T<:TensorBundle = Zero{V}()
Expand Down Expand Up @@ -521,9 +521,7 @@ end
@pure Base.isone(::Zero) = false
@pure Base.isinf(::Zero) = false

@pure AbstractTensors.values(::Zero) = 0
@pure valuetype(::Zero) = Int
@pure valuetype(::Type{<:Zero}) = Int
@pure AbstractTensors.value(::Zero) = 0

Base.show(io::IO,::Zero{V}) where V = print(io,"𝟎")

Expand All @@ -545,7 +543,6 @@ end

@inline Base.abs2(t::Zero) = t

const g_zero = Zero
@pure One(::Type{T}) where T = one(T)
@pure Zero(::Type{T}) where T = zero(T)

Expand All @@ -558,7 +555,7 @@ export Infinity
Infinite quantity `Infinity` of the `Grassmann` algebra over `V`.
"""
struct Infinity{V} <: TensorTerm{V,0}
struct Infinity{V} <: TensorTerm{V,0,Float64}
@pure Infinity{V}() where V = new{submanifold(V)}()
end
@pure Infinity(V::T) where T<:TensorBundle = Infinity{V}()
Expand All @@ -583,9 +580,7 @@ end
@pure Base.isone(::Infinity) = false
@pure Base.isinf(::Infinity) = true

@pure AbstractTensors.values(::Infinity) = Inf
@pure valuetype(::Infinity) = Float64
@pure valuetype(::Type{<:Infinity}) = Float64
@pure AbstractTensors.value(::Infinity) = Inf

Base.show(io::IO,::Infinity{V}) where V = print(io,"")

Expand Down
6 changes: 3 additions & 3 deletions src/basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end
generate(V::Int) = generate(Submanifold(V),V)
generate(V::Manifold) = generate(V,rank(V))
function generate(V,N)
exp = Submanifold{V}[Submanifold{V,0}(g_zero(UInt))]
exp = Submanifold{V}[Submanifold{V,0}(Zero(UInt))]
for i 1:N
set = combo(N,i)
for k 1:length(set)
Expand Down Expand Up @@ -133,14 +133,14 @@ end

@inline function lookup_basis(V,v::Symbol)::Union{Single,Submanifold}
p,b,w,z = indexparity(V,v)
z && return g_zero(V)
z && return Zero(V)
d = Submanifold{w}(indexbits(mdims(w),b))
return p ? Single(-1,d) : d
end

## fundamentals

abstract type SubAlgebra{V} <: TensorAlgebra{V} end
abstract type SubAlgebra{V} <: TensorAlgebra{V,Int} end

Base.adjoint(G::A) where A<:SubAlgebra{V} where V = Λ(dual(V))
@pure dual(G::A) where A<: SubAlgebra = G'
Expand Down
37 changes: 20 additions & 17 deletions src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@

export basis, grade, order, options, metric, polymode, dyadmode, diffmode, diffvars
export valuetype, value, hasinf, hasorigin, isorigin, norm, indices, tangent, isbasis,
export antigrade, antireverse, antiinvolute, anticlifford
export pseudograde, pseudoreverse, pseudoinvolute, pseudoclifford

(M::Signature)(b::Int...) = Submanifold{M}(b)
(M::DiagonalForm)(b::Int...) = Submanifold{M}(b)
(M::Submanifold)(b::Int...) = Submanifold{supermanifold(M)}(b)
(M::Submanifold{V})(b::Int) where V = isbasis(M) ? grade(M)==b ? M : Zero(V) : Submanifold{supermanifold(M)}((b,))
(M::Submanifold{V})(::Val{G}) where {V,G} = grade(M)==G ? M : Zero(V)
(M::Single{V})(G::Int) where V = grade(M)==G ? M : Zero(V)
(M::Single{V})(::Val{G}) where {V,G} = grade(M)==G ? M : Zero(V)
(M::Signature)(b::T) where T<:AbstractVector{Int} = Submanifold{M}(b)
(M::DiagonalForm)(b::T) where T<:AbstractVector{Int} = Submanifold{M}(b)
(M::Submanifold)(b::T) where T<:AbstractVector{Int} = Submanifold{supermanifold(M)}(b)
Expand Down Expand Up @@ -62,8 +66,6 @@ export isdyadic, isdual, istangent
@pure basis(m::Type{T}) where T<:Submanifold = isbasis(m) ? m() : typeof(Submanifold(m()))
for T (:T,:(Type{T}))
@eval begin
@pure valuetype(::$T) where T<:Submanifold = Int
@pure valuetype(::$T) where T<:Single{V,G,B,𝕂} where {V,G,B} where 𝕂 = 𝕂
@pure isbasis(::$T) where T<:Submanifold{V} where V = issubmanifold(V)
@pure isbasis(::$T) where T<:TensorBundle = false
@pure isbasis(::$T) where T<:Single = false
Expand Down Expand Up @@ -97,8 +99,8 @@ end
grade(t,G::Int) = grade(t,val(G))
grade(t::TensorGraded{V,G},g::Val{G}) where {V,G} = t
grade(t::TensorGraded{V,L},g::Val{G}) where {V,G,L} = Zero(V)
antigrade(t,G::Int) = antigrade(t,val(G))
antigrade(t::TensorAlgebra{V},::Val{G}) where {V,G} = grade(t,val(grade(V)-G))
pseudograde(t,G::Int) = pseudograde(t,val(G))
pseudograde(t::TensorAlgebra{V},::Val{G}) where {V,G} = grade(t,val(grade(V)-G))

@pure hasinf(::T) where T<:TensorBundle{N,M} where N where M = _hasinf(M)
@pure hasinf(::Submanifold{M,N,S} where N) where {M,S} = hasinf(M) && isodd(S)
Expand Down Expand Up @@ -157,7 +159,7 @@ export involute, clifford

@pure grade_basis(v,::Submanifold{V,G,B} where G) where {V,B} = grade_basis(V,B)
@pure grade(v,::Submanifold{V,G,B} where G) where {V,B} = grade(V,B)
@pure antigrade(v,::Submanifold{V,G,B} where G) where {V,B} = antigrade(V,B)
@pure pseudograde(v,::Submanifold{V,G,B} where G) where {V,B} = pseudograde(V,B)

@doc """
~(ω::TensorAlgebra)
Expand Down Expand Up @@ -188,37 +190,38 @@ Clifford conjugate of an element: clifford(ω) = involute(reverse(ω))
""" clifford

"""
antireverse(ω::TensorAlgebra)
pseudoreverse(ω::TensorAlgebra)
Anti-reverse of an element: ~ω = (-1)^(antigrade(ω)*(antigrade(ω)-1)/2)*ω
""" antireverse
Anti-reverse of an element: ~ω = (-1)^(pseudograde(ω)*(pseudograde(ω)-1)/2)*ω
""" pseudoreverse

@doc """
antiinvolute(ω::TensorAlgebra)
pseudoinvolute(ω::TensorAlgebra)
Anti-involute of an element: ~ω = (-1)^antigrade(ω)*ω
""" antiinvolute
Anti-involute of an element: ~ω = (-1)^pseudograde(ω)*ω
""" pseudoinvolute

@doc """
anticlifford(ω::TensorAlgebra)
pseudoclifford(ω::TensorAlgebra)
Anti-clifford conjugate of an element: anticlifford(ω) = antiinvolute(antireverse(ω))
""" anticlifford
Pseudo-clifford conjugate element: pseudoclifford(ω) = pseudoinvolute(pseudoreverse(ω))
""" pseudoclifford

for r (:reverse,:involute,:(Base.conj),:clifford)
p = Symbol(:parity,r==:(Base.conj) ? :conj : r)
ar = Symbol(:anti,r)
ar = Symbol(:pseudo,r)
@eval begin
@pure function $r(b::Submanifold{V,G,B}) where {V,G,B}
$p(grade(V,B)) ? Single{V}(-value(b),b) : b
end
$r(b::Single) = value(b) 0 ? Single(value(b),$r(basis(b))) : Zero(Manifold(b))
@pure function $ar(b::Submanifold{V,G,B}) where {V,G,B}
$p(antigrade(V,B)) ? Single{V}(-value(b),b) : b
$p(pseudograde(V,B)) ? Single{V}(-value(b),b) : b
end
$ar(b::Single) = value(b) 0 ? Single(value(b),$ar(basis(b))) : Zero(Manifold(b))
end
end
const antireverse,antiinvolute,anticlifford = pseudoreverse,pseudoinvolute,pseudoclifford

for op (:div,:rem,:mod,:mod1,:fld,:fld1,:cld,:ldexp)
@eval begin
Expand Down
2 changes: 1 addition & 1 deletion src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ end
## complement

import Leibniz: complementright, complementrighthodge, , complement
import AbstractTensors: complementleft, complementlefthodge, complementleftanti, complementrightanti, antimetric
import AbstractTensors: complementleft, complementlefthodge, complementleftanti, complementrightanti, antimetric, pseudometric
export complementleft, complementright, , complementlefthodge, complementrighthodge
export complementleftanti, complementrightanti

Expand Down

2 comments on commit d2268bb

@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/105497

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.8.11 -m "<description of version>" d2268bb49f514739f1ec711d995e9f53241ea744
git push origin v0.8.11

Please sign in to comment.