Skip to content

Commit

Permalink
renamed AntiSpinor to CoSpinor
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Oct 12, 2024
1 parent 333c8d4 commit 36ca4c5
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 218 deletions.
4 changes: 1 addition & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
66 changes: 25 additions & 41 deletions src/algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(""))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,(AB)|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
Expand Down Expand Up @@ -196,9 +194,6 @@ Regressive product as defined by the DeMorgan's law: ∨(ω...) = ⋆⁻¹(∧(

## interior product: a ∨ ⋆(b)

import LinearAlgebra: dot,
export

"""
contraction(ω::TensorAlgebra,η::TensorAlgebra)
Expand Down Expand Up @@ -268,8 +263,6 @@ end
end
end

export ,

@doc """
dot(ω::TensorAlgebra,η::TensorAlgebra)
Expand All @@ -278,9 +271,6 @@ Interior (right) contraction product: ω⋅η = ω∨⋆η

## cross product

import LinearAlgebra: cross, ×
export ×

@doc """
cross(ω::TensorAlgebra,η::TensorAlgebra)
Expand All @@ -289,8 +279,6 @@ Cross product: ω×η = ⋆(ω∧η)

# symmetrization and anti-symmetrization

export ,

"""
⊙(ω::TensorAlgebra,η::TensorAlgebra)
Expand All @@ -315,22 +303,20 @@ 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)
@generated function (a::TensorGraded{V,G},b::Spinor{V},g) where {V,G}
isinduced(g) && (return :(ab))
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 :(ab))
product_sandwich(a,b,false,true)
end
Expand Down Expand Up @@ -360,15 +346,15 @@ 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)
@generated function >>>(b::Spinor{V},a::TensorGraded{V,G},g) where {V,G}
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
Expand Down Expand Up @@ -405,8 +391,6 @@ antidot_metric(a,b) = complementleft(contraction_metric(complementright(a),compl

## linear algebra

export ,

(a,b) = iszero(ab)

## exponentiation
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -800,21 +784,21 @@ 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<cache_limit
$(insert_expr((:N,),:svecs)...)
t = promote_type(valuetype(a),valuetype(b))
out,ib = svecs(N,Any)(zeros(svecs(N,t<:Number ? t : Int))),indexbasis(N)
setanti!_pre(out,:(value(a,$t)),UInt(basis(a)),Val{N}())
setanti!_pre(out,:($bop(value(b,$t))),UInt(basis(b)),Val{N}())
return :(AntiSpinor{V}($(Expr(:call,tvecs(N,t<:Number ? t : Any),out...))))
return :(CoSpinor{V}($(Expr(:call,tvecs(N,t<:Number ? t : Any),out...))))
else quote
$(insert_expr((:N,:t),VEC)...)
out = zeros(mvecs(N,t))
setanti!(out,value(a,t),UInt(basis(a)),Val{N}())
setanti!(out,$bop(value(b,t)),UInt(basis(b)),Val{N}())
return AntiSpinor{V}(out)
return CoSpinor{V}(out)
end end
end
@noinline function addermulti(a::Type{<:TensorTerm{V,L}},b::Type{<:TensorTerm{V,G}},op) where {V,L,G}
Expand Down Expand Up @@ -918,17 +902,17 @@ adder(a,b,op=:+) = adder(typeof(a),typeof(b),op)
end
val = :(@inbounds $left(value(a,$t)))
setanti!_pre(out,val,X,Val(N))
return :(AntiSpinor{V}($(Expr(:call,tvecs(N,t<:Number ? t : Any),out...))))
return :(CoSpinor{V}($(Expr(:call,tvecs(N,t<:Number ? t : Any),out...))))
else return if !swap; quote
$(insert_expr((:N,:t,:out,:rrr,:bng),VECS)...)
@inbounds out[rrr+1:rrr+bng] = $(bcast(right,:(value(b,$VEC(N,G,t)),)))
addpseudo(out,value(a,t),UInt(basis(a)),Val(N))
return AntiSpinor{V}(out)
return CoSpinor{V}(out)
end; else quote
$(insert_expr((:N,:t,:out,:rrr,:bng),VECS)...)
@inbounds out[rrr+1:rrr+bng] = value(a,$VEC(N,G,t))
addanti!(out,$left(value(b,t)),UInt(basis(b)),Val(N))
return AntiSpinor{V}(out)
return CoSpinor{V}(out)
end end end
else
if mdims(V)<cache_limit
Expand Down Expand Up @@ -1015,7 +999,7 @@ adder(a,b,op=:+) = adder(typeof(a),typeof(b),op)
return Spinor{V}(out)
end end end
end
@noinline function adder(a::Type{<:TensorTerm{V,G}},b::Type{<:AntiSpinor{V,T}},op,swap=false) where {V,G,T}
@noinline function adder(a::Type{<:TensorTerm{V,G}},b::Type{<:CoSpinor{V,T}},op,swap=false) where {V,G,T}
left,right,VEC = addvec(a,b,swap,op)
VECS = Symbol(string(VEC)*"s")
!isodd(G) && (return swap ? :($op(Multivector(b),a)) : :($op(a,Multivector(b))))
Expand All @@ -1032,24 +1016,24 @@ adder(a,b,op=:+) = adder(typeof(a),typeof(b),op)
setanti!_pre(out,val,B,Val(N))
end
end
return :(AntiSpinor{V}($(Expr(:call,tvecs(N,t<:Number ? t : Any),out...))))
return :(CoSpinor{V}($(Expr(:call,tvecs(N,t<:Number ? t : Any),out...))))
else return if !swap; quote
$(insert_expr((:N,:t),VEC)...)
out = convert($VECS(N,t),$(bcast(right,:(value(b,$VECS(N,t)),))))
addanti!(out,value(a,t),UInt(basis(a)),Val(N))
return AntiSpinor{V}(out)
return CoSpinor{V}(out)
end; else quote
$(insert_expr((:N,:t),VEC)...)
out = value(a,$VECS(N,t))
addpseudo(out,$left(value(b,t)),UInt(basis(b)),Val(N))
return AntiSpinor{V}(out)
return CoSpinor{V}(out)
end end end
end
@noinline function product(a::Type{S},b::Type{<:Chain{V,G,T}},swap=false,field=false) where S<:TensorGraded{V,L} where {V,G,L,T}
MUL,VEC = mulvecs(a,b)
vfield = Val(field)
anti = isodd(L) isodd(G)
type = anti ? :AntiSpinor : :Spinor
type = anti ? :CoSpinor : :Spinor
args = field ? (:g,) : ()
(S<:Zero || S<:Infinity) && (return :a)
if G == 0
Expand Down Expand Up @@ -1341,13 +1325,13 @@ for (op,po,GL,grass) ∈ ((:∧,:>,:(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,outspininspin ? :anti! : :spin!)) : $(Symbol(product,outspininspin ? :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,outspininspin ? :anti!_pre : :spin!_pre)) : $(Symbol(product,outspininspin ? :spin!_pre : :anti!_pre)))
prop = op:* ? Symbol(:product_,op) : :product
Expand Down Expand Up @@ -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!)
Expand Down
39 changes: 18 additions & 21 deletions src/composite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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))))
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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...)
Expand Down Expand Up @@ -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)))
Expand All @@ -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<<mdims(V)-1)))})
Base.rand(::AbstractRNG,::SamplerType{Couple{V,B}}) where {V,B} = Couple{V,B}(rand(Complex{Float64}))
Expand Down
Loading

0 comments on commit 36ca4c5

Please sign in to comment.