24
24
# @pure labels(V::T) where T<:Manifold = labels(V,pre[1],pre[2],pre[3],pre[4])
25
25
26
26
generate (V:: Int ) = generate (SubManifold (V),V)
27
- generate (V:: Manifold{N} ) where N = generate (V,N )
27
+ generate (V:: Manifold ) = generate (V,rank (V) )
28
28
function generate (V,N)
29
29
exp = SubManifold{V}[SubManifold {V,0} (g_zero (UInt))]
30
30
for i ∈ 1 : N
@@ -44,18 +44,17 @@ export @basis, @basis_str, @dualbasis, @dualbasis_str, @mixedbasis, @mixedbasis_
44
44
Generates `Basis` declaration having `Manifold` specified by `V`.
45
45
The first argument provides pseudoscalar specifications, the second argument is the variable name for the `Manifold`, and the third and fourth argument are variable prefixes of the `SubManifold` vector names (and covector basis names).
46
46
"""
47
- function basis (V,sig= vsn[1 ],vec= pre[1 ],cov= pre[2 ],duo= pre[3 ],dif= pre[4 ])
47
+ function alloc (V,sig= vsn[1 ],vec= pre[1 ],cov= pre[2 ],duo= pre[3 ],dif= pre[4 ])
48
48
N = mdims (V)
49
49
if N > algebra_limit
50
- Λ (V) # fill cache
50
+ G = Λ (V) # fill cache
51
51
basis = generate (V)
52
52
sym = labels (V,string .([vec,cov,duo,dif])... )
53
53
else
54
54
basis = Λ (V). b
55
55
sym = labels (V,string .([vec,cov,duo,dif])... )
56
56
end
57
- T = typeof (V)
58
- @inbounds exp = Expr[Expr (:(= ),esc (sig),T<: SubManifold ? V : SubManifold (V)),
57
+ @inbounds exp = Expr[Expr (:(= ),esc (sig),convert (SubManifold,V)),
59
58
Expr (:(= ),esc (Symbol (vec)),basis[1 ])]
60
59
for i ∈ 2 : 1 << N
61
60
@inbounds push! (exp,Expr (:(= ),esc (Symbol (" $(basis[i]) " )),basis[i]))
@@ -64,6 +63,7 @@ function basis(V,sig=vsn[1],vec=pre[1],cov=pre[2],duo=pre[3],dif=pre[4])
64
63
push! (exp,Expr (:(= ),esc (Symbol (vec,' ⃖' )) ,esc (vec)))
65
64
return Expr (:block ,exp... ,Expr (:tuple ,esc (sig),esc .(sym)... ))
66
65
end
66
+ alloc (V:: TensorBundle ,args... ) = alloc (SubManifold (V),args... )
67
67
68
68
"""
69
69
@basis
@@ -76,11 +76,11 @@ Default for `@basis M` is `@basis M V v w ∂ ϵ`.
76
76
macro basis (q,sig= vsn[1 ],vec= pre[1 ],cov= pre[2 ],duo= pre[3 ],dif= pre[4 ])
77
77
T = typeof (q)
78
78
V = T∈ (Symbol,Expr) ? (@eval (__module__,$ q)) : T<: Int ? q : Manifold (q)
79
- basis (V,sig,string .([vec,cov,duo,dif])... )
79
+ alloc (V,sig,string .([vec,cov,duo,dif])... )
80
80
end
81
81
82
82
macro basis_str (str)
83
- basis (Manifold (str))
83
+ alloc (Manifold (str))
84
84
end
85
85
86
86
"""
@@ -92,11 +92,11 @@ The first argument provides pseudoscalar specifications, the second argument is
92
92
Default for `@dualbasis M` is `@dualbasis M VV w ϵ`.
93
93
"""
94
94
macro dualbasis (q,sig= vsn[2 ],cov= pre[2 ],dif= pre[4 ])
95
- basis ((typeof (q)∈ (Symbol,Expr) ? (@eval (__module__,$ q)) : Manifold (q))' ,sig,string .([pre[1 ],cov,pre[3 ],dif])... )
95
+ alloc ((typeof (q)∈ (Symbol,Expr) ? (@eval (__module__,$ q)) : Manifold (q))' ,sig,string .([pre[1 ],cov,pre[3 ],dif])... )
96
96
end
97
97
98
98
macro dualbasis_str (str)
99
- basis (Manifold (str)' ,vsn[2 ])
99
+ alloc (Manifold (str)' ,vsn[2 ])
100
100
end
101
101
102
102
"""
@@ -109,14 +109,14 @@ Default for `@mixedbasis M` is `@mixedbasis M V v w ∂ ϵ`.
109
109
"""
110
110
macro mixedbasis (q,sig= vsn[3 ],vec= pre[1 ],cov= pre[2 ],duo= pre[3 ],dif= pre[4 ])
111
111
V = typeof (q)∈ (Symbol,Expr) ? (@eval (__module__,$ q)) : Manifold (q)
112
- bases = basis (V⊕ V' ,sig,string .([vec,cov,duo,dif])... )
113
- Expr (:block ,bases,basis (V' ,vsn[2 ]),basis (V),bases. args[end ])
112
+ bases = alloc (V⊕ V' ,sig,string .([vec,cov,duo,dif])... )
113
+ Expr (:block ,bases,alloc (V' ,vsn[2 ]),alloc (V),bases. args[end ])
114
114
end
115
115
116
116
macro mixedbasis_str (str)
117
117
V = Manifold (str)
118
- bases = basis (V⊕ V' ,vsn[3 ])
119
- Expr (:block ,bases,basis (V' ,vsn[2 ]),basis (V),bases. args[end ])
118
+ bases = alloc (V⊕ V' ,vsn[3 ])
119
+ Expr (:block ,bases,alloc (V' ,vsn[2 ]),alloc (V),bases. args[end ])
120
120
end
121
121
122
122
@inline function lookup_basis (V,v:: Symbol ):: Union{Simplex,SubManifold}
@@ -144,7 +144,7 @@ Base.length(a::T) where T<:SubAlgebra{V} where V = 1<<mdims(V)
144
144
# # Algebra{N}
145
145
146
146
@computed struct Basis{V} <: SubAlgebra{V}
147
- b:: Values{1<<(typeof(V)<:Int ? V : mdims(V) ),SubManifold{V}}
147
+ b:: Values{1<<mdims(V),SubManifold{V}}
148
148
g:: Dict{Symbol,Int}
149
149
end
150
150
0 commit comments