@@ -29,7 +29,7 @@ import AbstractTensors: TensorAlgebra, Manifold, TensorGraded, scalar, isscalar,
2929import AbstractTensors: vector, isvector, bivector, isbivector, volume, isvolume, equal, ⋆
3030import AbstractTensors: value, valuetype, interop, interform, even, odd, isnull, norm, SUM
3131import AbstractTensors: TupleVector, Values, Variables, FixedVector, basis, mdims, PROD
32- import AbstractTensors: Scalar, GradedVector, Bivector, Trivector
32+ import AbstractTensors: Scalar, GradedVector, Bivector, Trivector, SUB
3333
3434import Leibniz: Fields, pre, PRE, vsn, VTI, bit2int, combo, indexbits, indices
3535import Leibniz: printlabel, supermanifold, shift_indices, shift_indices!, printindices
@@ -152,22 +152,23 @@ end
152152
153153@pure DiagonalForm {N,M,S,F,D} () where {N,M,S,F,D} = DiagonalForm {N,M,S,F,D,1} ()
154154@pure DiagonalForm {N,M,S} () where {N,M,S} = DiagonalForm {N,M,S,0,0} ()
155+ @pure DiagonalForm {N,M} (b:: Values{N} ) where {N,M} = DiagonalForm {N,M,diagsig(M,b)} ()
155156DiagonalForm {N,M} (b:: Vector ) where {N,M} = DiagonalForm {N,M} (Values (b... ))
156- DiagonalForm (b:: Values{N} ) where N = DiagonalForm {N,0} (b)
157+ @pure DiagonalForm (b:: Values{N} ) where N = DiagonalForm {N,0} (b)
158+ @pure DiagonalForm (b:: Tuple ) = DiagonalForm {length(b),0} (Values (b))
157159DiagonalForm (b:: Vector ) = DiagonalForm {length(b),0} (b)
158- DiagonalForm (b:: Tuple ) = DiagonalForm {length(b),0} (Values (b))
159160DiagonalForm (b... ) = DiagonalForm (b)
160161DiagonalForm (s:: String ) = DiagonalForm (Meta. parse (s). args)
161162
162163@pure diagonalform (V:: DiagonalForm{N,M,S} where N) where {M,S} = isdual (V) ? SUB (diagonalform_cache[S]) : diagonalform_cache[S]
163164const diagonalform_cache = Values[]
164- function DiagonalForm {N,M} ( b:: Values{N} ) where {N,M}
165+ @pure function diagsig (M, b:: Values )
165166 a = dyadmode (M)> 0 ? SUB (b) : b
166167 if a ∈ diagonalform_cache
167- DiagonalForm {N,M, findfirst(x->x==a,diagonalform_cache)} ( )
168+ findfirst (x-> x== a,diagonalform_cache)
168169 else
169170 push! (diagonalform_cache,a)
170- DiagonalForm {N,M, length(diagonalform_cache)} ( )
171+ length (diagonalform_cache)
171172 end
172173end
173174
0 commit comments