@@ -204,33 +204,34 @@ end
204
204
205
205
@pure parityreverse (G) = isodd (Int ((G- 1 )* G/ 2 ))
206
206
@pure parityinvolute (G) = isodd (G)
207
- @pure parityconj (G) = parityreverse (G)⊻ parityinvolute (G)
207
+ @pure parityclifford (G) = parityreverse (G)⊻ parityinvolute (G)
208
+ const parityconj = parityreverse
208
209
209
210
# # reverse
210
211
211
212
import Base: reverse, ~
212
- export involute
213
+ export involute, clifford
213
214
214
215
@pure grade_basis (V,B) = B& (one (UInt)<< grade (V)- 1 )
215
216
@pure grade_basis (v,:: SubManifold{V,G,B} where G) where {V,B} = grade_basis (V,B)
216
217
@pure grade (V,B) = count_ones (grade_basis (V,B))
217
218
@pure grade (v,:: SubManifold{V,G,B} where G) where {V,B} = grade (V,B)
218
219
219
- for r ∈ (:reverse ,:involute ,:(Base. conj))
220
+ for r ∈ (:reverse ,:involute ,:(Base. conj), :clifford )
220
221
p = Symbol (:parity ,r== :(Base. conj) ? :conj : r)
221
222
@eval begin
222
223
@pure function $r (b:: SubManifold{V,G,B} ) where {V,G,B}
223
224
$ p (grade (V,B)) ? Simplex {V} (- value (b),b) : b
224
225
end
225
- $ r (b:: Simplex ) = value (b) ≠ 0 ? value (b) * $ r (basis (b)) : g_zero (Manifold (b))
226
+ $ r (b:: Simplex ) = value (b) ≠ 0 ? Simplex ( value (b), $ r (basis (b) )) : g_zero (Manifold (b))
226
227
end
227
228
end
228
229
229
230
@doc """
230
231
~(ω::TensorAlgebra)
231
232
232
233
Reverse of a `MultiVector` element: ~ω = (-1)^(grade(ω)*(grade(ω)-1)/2)*ω
233
- """ reverse
234
+ """ Base . conj
234
235
# reverse(a::UniformScaling{Bool}) = UniformScaling(!a.λ)
235
236
# reverse(a::UniformScaling{T}) where T<:Field = UniformScaling(-a.λ)
236
237
@@ -239,7 +240,7 @@ Reverse of a `MultiVector` element: ~ω = (-1)^(grade(ω)*(grade(ω)-1)/2)*ω
239
240
240
241
Reverse of a `MultiVector` element: ~ω = (-1)^(grade(ω)*(grade(ω)-1)/2)*ω
241
242
"""
242
- @inline Base.:~ (b:: TensorAlgebra ) = reverse (b)
243
+ @inline Base.:~ (b:: TensorAlgebra ) = conj (b)
243
244
# @inline ~(b::UniformScaling) = reverse(b)
244
245
245
246
@doc """
@@ -249,10 +250,10 @@ Involute of a `MultiVector` element: ~ω = (-1)^grade(ω)*ω
249
250
""" involute
250
251
251
252
@doc """
252
- conj (ω::TensorAlgebra)
253
+ clifford (ω::TensorAlgebra)
253
254
254
- Clifford conjugate of a `MultiVector` element: conj (ω) = involute(~ω )
255
- """ conj
255
+ Clifford conjugate of a `MultiVector` element: clifford (ω) = involute(conj(ω) )
256
+ """ clifford
256
257
257
258
odd (t:: T ) where T<: TensorGraded{V,G} where {V,G} = parityinvolute (G) ? t : zero (V)
258
259
even (t:: T ) where T<: TensorGraded{V,G} where {V,G} = parityinvolute (G) ? zero (V) : t
@@ -295,3 +296,19 @@ Base.isless(a,b::T) where T<:TensorTerm{V,0} where V = isless(a,value(b))
295
296
Base.:<= (x:: T ,y:: S ) where {T<: TensorTerm{V,0} ,S<: TensorTerm{W,0} } where {V,W} = isless (x,y) | (x == y)
296
297
Base.:<= (x:: T ,y) where T<: TensorTerm{V,0} where V = isless (x,y) | (x == y)
297
298
Base.:<= (x,y:: T ) where T<: TensorTerm{V,0} where V = isless (x,y) | (x == y)
299
+
300
+ # random samplers
301
+
302
+ orand (T= Float64) = 2 (rand (T).- 0.5 )
303
+ import Random: SamplerType, AbstractRNG
304
+ Base. rand (:: AbstractRNG ,:: SamplerType{Manifold} ) where V = SubManifold (Manifold (rand (1 : 5 )))
305
+ Base. rand (:: AbstractRNG ,:: SamplerType{SubManifold} ) = rand (SubManifold{rand (Manifold)})
306
+ Base. rand (:: AbstractRNG ,:: SamplerType{SubManifold{V}} ) where V = SubManifold {V} (UInt (rand (0 : 1 << ndims (V)- 1 )))
307
+ Base. rand (:: AbstractRNG ,:: SamplerType{SubManifold{V,G}} ) where {V,G} = Λ (V). b[rand (binomsum (ndims (V),G)+ 1 : binomsum (ndims (V),G+ 1 ))]
308
+ Base. rand (:: AbstractRNG ,:: SamplerType{Simplex} ) = rand (Simplex{rand (Manifold)})
309
+ Base. rand (:: AbstractRNG ,:: SamplerType{Simplex{V}} ) where V = orand ()* rand (SubManifold{V})
310
+ Base. rand (:: AbstractRNG ,:: SamplerType{Simplex{V,G}} ) where {V,G} = orand ()* rand (SubManifold{V,G})
311
+ Base. rand (:: AbstractRNG ,:: SamplerType{Simplex{V,G,B}} ) where {V,G,B} = orand ()* B
312
+ Base. rand (:: AbstractRNG ,:: SamplerType{Simplex{V,G,B,T}} ) where {V,G,B,T} = rand (T)* B
313
+ Base. rand (:: AbstractRNG ,:: SamplerType{Simplex{V,G,B,T} where B} ) where {V,G,T} = rand (T)* rand (SubManifold{V,G})
314
+ Base. rand (:: AbstractRNG ,:: SamplerType{Simplex{V,G,B,T} where {G,B}} ) where {V,T} = rand (T)* rand (SubManifold{V})
0 commit comments