chakravala / Grassmann.jl

⟨Grassmann-Clifford-Hodge⟩ multilinear differential geometric algebra

Home Page:https://grassmann.crucialflow.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Symbolic computation fails due to += dispatch

citron opened this issue · comments

Am I wrong or is it a bug ?

using Reduce
using Grassmann
@basis S"∞∅+++"
p = :x*v1 + :y*v2 + :z*v3
P = v∅ + p + 0.5 * p^2 * v∞

ERROR: LoadError: MethodError: no method matching +(::Expr, ::Float64)
Closest candidates are:
+(::Any, ::Any, !Matched::Any, !Matched::Any...) at operators.jl:529
+(!Matched::Bool, ::T<:AbstractFloat) where T<:AbstractFloat at bool.jl:104
+(!Matched::Float64, ::Float64) at float.jl:395
...
Stacktrace:
[1] macro expansion at .julia/packages/StaticArrays/3KEjZ/src/mapreduce.jl:41 [inlined]
[2] _map at .julia/packages/StaticArrays/3KEjZ/src/mapreduce.jl:21 [inlined]
[3] map at .julia/packages/StaticArrays/3KEjZ/src/mapreduce.jl:14 [inlined]
[4] +(::Array{Any,1}, ::StaticArrays.SizedArray{Tuple{5},Any,1,1}) at /home/gacquewi/.julia/packages/StaticArrays/3KEjZ/src/linalg.jl:11
[5] +(::MChain{Any,⟨∞∅+++⟩,1,5}, ::MultiVector{Any,⟨∞∅+++⟩,32}) at .julia/packages/Grassmann/cEoGT/src/algebra.jl:1310
[6] +(::Basis{⟨∞∅+++⟩,1,0x0000000000000002}, ::MChain{Any,⟨∞∅+++⟩,1,5}, ::MultiVector{Any,⟨∞∅+++⟩,32}) at ./operators.jl:529
[7] top-level scope at wgCGAbug.jl:5
[8] include at ./boot.jl:328 [inlined]
[9] include_relative(::Module, ::String) at ./loading.jl:1094
[10] include(::Module, ::String) at ./Base.jl:31
[11] exec_options(::Base.JLOptions) at ./client.jl:295
[12] _start() at ./client.jl:464
in expression starting at wgCGAbug.jl:5

Indeed, that has been fixed in the latest commit

julia> p = :x*v1 + :y*v2 + :z*v3
0.0v∞ + 0.0v∅ + xv₁ + yv₂ + zv₃

julia> P = v∅ + p + 0.5 * p^2 * v∞
0.0 + ((y ^ 2 + z ^ 2 + x ^ 2) / 2)v∞ + 1.0v∅ + xv₁ + yv₂ + zv₃

julia> (p)
0.0 + ((y ^ 2 + z ^ 2 + x ^ 2) / 2)v∞ + 1.0v∅ + xv₁ + yv₂ + zv₃

julia> (P)
0.0 + xv₁ + yv₂ + zv₃

Note that in the latest version you can also just use ↑,↓ for that also.

You desserve a big big hug :)
Thanks a lot !
May you please forge a Grassmann v0.3.2 package ?