Giter Site home page Giter Site logo

chakravala / directsum.jl Goto Github PK

View Code? Open in Web Editor NEW
49.0 4.0 3.0 166 KB

Tangent bundle, vector space and Submanifold definition

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

License: GNU Affero General Public License v3.0

Julia 100.00%
type-system abstract-algebra differential-geometry linear-algebra category-theory manifold manifolds tensor-algebra math tensors

directsum.jl's Issues

Trouble creating an array of unit vectors when one of them has negative scalar coefficient

I can do:

@basis S"∞∅+++"
pts = (-v1, v1)

But when I try and make an array:

@basis S"∞∅+++"
pts = [-v1, v1]

I get:

MethodError: convert(::Type{Simplex{⟨∞∅+++⟩,1,v₁,Number}}, ::SubManifold{⟨∞∅+++⟩,1,0x0000000000000004}) is ambiguous. Candidates:
  convert(::Type{T}, x::Number) where T<:Number in Base at number.jl:7
  convert(::Type{Simplex{V,G,B,X}}, t::Y) where {V, G, B, X, Y} in DirectSum at /home/micah/.julia/packages/DirectSum/Ofduh/src/operations.jl:439
Possible fix, define
  convert(::Type{Simplex{V,G,B,X}}, ::Y) where {V, G, B, X, Y<:Number}

Stacktrace:
 [1] setindex!(::Array{Simplex{⟨∞∅+++⟩,1,v₁,Number},1}, ::SubManifold{⟨∞∅+++⟩,1,0x0000000000000004}, ::Int64) at ./array.jl:826
 [2] copyto!(::Array{Simplex{⟨∞∅+++⟩,1,v₁,Number},1}, ::Tuple{Simplex{⟨∞∅+++⟩,1,v₁,Int64},SubManifold{⟨∞∅+++⟩,1,0x0000000000000004}}) at ./abstractarray.jl:724
 [3] vect(::Simplex{⟨∞∅+++⟩,1,v₁,Int64}, ::Vararg{Any,N} where N) at ./array.jl:151
 [4] top-level scope at In[7]:2

Info about installed package versions:

  Resolving package versions...
  Installed RecipesBase ─ v0.8.0
  Installed Polynomials ─ v0.6.1
   Updating `~/.julia/environments/v1.4/Project.toml`
  [4df31cd9] + Grassmann v0.5.6
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [861a8166] + Combinatorics v1.0.0
  [459fdd68] + ComputedFieldTypes v0.1.0
  [22fd7b30] + DirectSum v0.5.4
  [4df31cd9] + Grassmann v0.5.6
  [edad4870] + Leibniz v0.0.5
  [f27b6e38] + Polynomials v0.6.1
  [3cdcf5f2] + RecipesBase v0.8.0

Generic constructor fails for Signature "-+"

The geometric product works like expected for the commonly used algebra with signature "-+++":

julia> using Grassmann

julia> basis"-+++"
(⟨-+++⟩, v, v₁, v₂, v₃, v₄, v₁₂, v₁₃, v₁₄, v₂₃, v₂₄, v₃₄, v₁₂₃, v₁₂₄, v₁₃₄, v₂₃₄, v₁₂₃₄)

julia> v1*v1
-1v

However, it does not work for algebras with more uncommon signatures like "-+" or "-++":

julia> basis"-+"
(⟨-,+⟩, v, v₁, v₂, v₁₂)

julia> v1*v1
ERROR: MethodError: no method matching abs(::Symbol)
Closest candidates are:
  abs(::Bool) at bool.jl:91
  abs(::Float16) at float.jl:520
  abs(::Float32) at float.jl:521
  ...
Stacktrace:
 [1] parityinner(::UInt64, ::UInt64, ::DiagonalForm{2,0,1,0}) at .julia/packages/Grassmann/H9Zog/src/parity.jl:96
 [2] *(::Basis{⟨-,+⟩,1,0x0000000000000001}, ::Basis{⟨-,+⟩,1,0x0000000000000001}) at .julia/packages/Grassmann/H9Zog/src/algebra.jl:150
 [3] top-level scope at none:0

julia> basis"-++"
(⟨-,++⟩, v, v₁, v₂, v₁₂)

julia> v1*v1
ERROR: MethodError: no method matching abs(::Symbol)
Closest candidates are:
  abs(::Bool) at bool.jl:91
  abs(::Float16) at float.jl:520
  abs(::Float32) at float.jl:521
  ...
Stacktrace:
 [1] parityinner(::UInt64, ::UInt64, ::DiagonalForm{2,0,2,0}) at .julia/packages/Grassmann/H9Zog/src/parity.jl:96
 [2] *(::Basis{⟨-,++⟩,1,0x0000000000000001}, ::Basis{⟨-,++⟩,1,0x0000000000000001}) at .julia/packages/Grassmann/H9Zog/src/algebra.jl:150
 [3] top-level scope at none:0

Naming conventions in DirectSum for v0.3+

This issue is intended to help keep track of naming conventions for v0.3+

Deprecations

  • dualbits -> diffmask
  • dualcheck -> diffcheck
  • dualtype -> mixedmode
  • hasi2o -> hasinf2origin
  • haso2i -> hasorigin2inf
  • VectorSpace -> VectorBundle
  • PROD ->
  • SUB -> -
  • ndigits -> digits_fast

Consider sig,vio,vsn,pre,bit2int,doc2m,digs,subs,sups for change

Trouble with @basis macro and D constructor

Newbie here, so I apologize if this is user error.

I was attempting to copy the example with PGAs here: https://discourse.bivector.net/t/implementing-pga-with-galgebra/81/2 when I hit a snag.

Trying to initialize the basis throws an error:

julia> @basis D"1,1,1,0"
ERROR: LoadError: LoadError: MethodError: no method matching isdual(::Int64)
Closest candidates are:
  isdual(::T) where T<:TensorAlgebra at C:\Users\tedco\.juliapro\JuliaPro_v1.4.1-1\packages\DirectSum\He1ee\src\generic.jl:44
Stacktrace:
 [1] DiagonalForm{4,0,Signatures,Vars,Diff,Name} where Name where Diff where Vars where Signatures(::StaticArrays.SArray{Tuple{4},Int64,1,4}) at C:\Users\tedco\.juliapro\JuliaPro_v1.4.1-1\packages\DirectSum\He1ee\src\DirectSum.jl:121
 [2] DiagonalForm{4,0,Signatures,Vars,Diff,Name} where Name where Diff where Vars where Signatures(::Array{Any,1}) at C:\Users\tedco\.juliapro\JuliaPro_v1.4.1-1\packages\DirectSum\He1ee\src\DirectSum.jl:111 [3] DiagonalForm(::Array{Any,1}) at C:\Users\tedco\.juliapro\JuliaPro_v1.4.1-1\packages\DirectSum\He1ee\src\DirectSum.jl:113
 [4] DiagonalForm(::String) at C:\Users\tedco\.juliapro\JuliaPro_v1.4.1-1\packages\DirectSum\He1ee\src\DirectSum.jl:116
 [5] @D_str(::LineNumberNode, ::Module, ::Any) at C:\Users\tedco\.juliapro\JuliaPro_v1.4.1-1\packages\DirectSum\He1ee\src\DirectSum.jl:276
 [6] eval(::Module, ::Any) at .\boot.jl:331
 [7] @basis(::LineNumberNode, ::Module, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\tedco\.juliapro\JuliaPro_v1.4.1-1\packages\DirectSum\He1ee\src\basis.jl:74 (repeats 2 times)
in expression starting at none:1
in expression starting at none:1

I'm using Grassmann v0.5.10 in Julia v1.4.1. No other packages are loaded.

Trying other signatures (e.g. D"1,1,1") throws the same error, so I don't think it's anything particular to the degenerate metric.

Submanifold index arrays should be typed

I received this error:

Linear operators for D=1: Error During Test at /Users/eschnett/src/jl/RayTraceGR/test/runtests.jl:52
  Got exception outside of a @test
  MethodError: no method matching one(::Type{Any})
  Closest candidates are:
    one(::Type{Union{Missing, T}}) where T at missing.jl:105
    one(!Matched::Type{Missing}) at missing.jl:103
    one(!Matched::BitArray{2}) at bitarray.jl:422
    ...
  Stacktrace:
   [1] one(::Type{Any}) at ./missing.jl:105
   [2] reduce_empty(::typeof(*), ::Type{T} where T) at ./reduce.jl:308
   [3] reduce_empty(::typeof(Base.mul_prod), ::Type{T} where T) at ./reduce.jl:316
   [4] mapreduce_empty(::typeof(identity), ::Function, ::Type{T} where T) at ./reduce.jl:335
   [5] _mapreduce(::typeof(identity), ::typeof(Base.mul_prod), ::IndexLinear, ::Array{Any,1}) at ./reduce.jl:392
   [6] _mapreduce_dim at ./reducedim.jl:312 [inlined]
   [7] #mapreduce#580 at ./reducedim.jl:307 [inlined]
   [8] mapreduce at ./reducedim.jl:307 [inlined]
   [9] _prod at ./reducedim.jl:657 [inlined]
   [10] _prod(::Array{Any,1}, ::Colon) at ./reducedim.jl:656
   [11] #prod#585 at ./reducedim.jl:652 [inlined]
   [12] prod at ./reducedim.jl:652 [inlined]
   [13] parityinterior(::SubManifold{⟨+⟩,1,0x0000000000000001}, ::UInt64, ::UInt64) at /Users/eschnett/.julia/dev/Grassmann/src/parity.jl:77
   [14] interior(::UInt64, ::UInt64, ::SubManifold{⟨+⟩,1,0x0000000000000001}) at /Users/eschnett/.julia/dev/Grassmann/src/parity.jl:168
   [15] skewaddblade!_pre(::SubManifold{⟨+⟩,1,0x0000000000000001}, ::SizedArray{Tuple{1},Any,1,1}, ::UInt64, ::UInt64, ::Expr) at /Users/eschnett/.julia/dev/Grassmann/src/algebra.jl:258
   [16] #s335#570 at /Users/eschnett/.julia/dev/Grassmann/src/products.jl:373 [inlined]
   [17] #s335#570(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at ./none:0
   [18] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:526
   [19] dot(::Chain{v₁,1,Chain{v₁,1,Rational{Int128},1},1}, ::Chain{v₁,1,Rational{Int128},1}) at /Users/eschnett/.julia/packages/AbstractTensors/6BQWx/src/AbstractTensors.jl:132
   [20] top-level scope at /Users/eschnett/src/jl/RayTraceGR/test/runtests.jl:64
   [21] top-level scope at /Users/eschnett/src/julia-1.4/usr/share/julia/stdlib/v1.4/Test/src/Test.jl:1186
   [22] include(::String) at ./client.jl:439
   [23] top-level scope at none:6
   [24] eval(::Module, ::Any) at ./boot.jl:331
   [25] exec_options(::Base.JLOptions) at ./client.jl:264
   [26] _start() at ./client.jl:484

Tracking things down, the problem comes from an empty list of indices used in parity.jl line 77:

    ind = indices(B,N); g = prod(V[ind])

V[ind] is an empty array of type Vector{Any}, so prod cannot determine the neutral element. (I am using 1-dimensional manifolds, which is probably a bit of a special case.)

I believe the solution is to add explicit Int declarations to the array comprehensions in lines 198, 199 of DirectSum.jl in DirectSum:

@inline getindex(vs::SubManifold,i::Vector) = [getindex(vs,j) for j  i]
@inline getindex(vs::SubManifold,i::UnitRange{Int}) = [getindex(vs,j) for j  i]

This change resolves the problem for me.

Ambiguous Base.:(==) in the doc of ℝ

julia> using Grassmann

julia> ℝ
⟨+⟩

help?>"" can be typed by \bbR<tab>

search: ℝ ℝ9 ℝ8 ℝ7 ℝ6 ℝ5 ℝ4 ℝ3 ℝ2 ℝ1 ℝ0

ERROR: MethodError: ==(::Type{Signature{1, 0, 0x0000000000000000, 0, 0, 1}}, ::Type{Union{}}) is ambiguous. Candidates:
  ==(::Type{A}, ::Type{B}) where {A<:Signature, B<:SubManifold} in DirectSum at E:\.julia\packages\DirectSum\aSUXQ\src\DirectSum.jl:290 
  ==(::Type{A}, ::Type{B}) where {A<:Signature, B<:DiagonalForm} in DirectSum at E:\.julia\packages\DirectSum\aSUXQ\src\DirectSum.jl:290
  ==(::Type{A}, ::Type{B}) where {A<:Signature, B<:Signature} in DirectSum at E:\.julia\packages\DirectSum\aSUXQ\src\DirectSum.jl:290   
Possible fix, define
  ==(::Type{A}, ::Type{Union{}}) where A<:Signature
Stacktrace:
 [1] fieldcount(t::Any)      
   @ Base .\reflection.jl:710
 [2] fieldnames(t::DataType) 
   @ Base .\reflection.jl:176
 [3] summarize(io::IOBuffer, T::DataType, binding::Base.Docs.Binding)
   @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\docview.jl:276
 [4] summarize(io::IOBuffer, T::Any, binding::Base.Docs.Binding)
   @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\docview.jl:309
 [5] summarize(binding::Base.Docs.Binding, sig::Type)
   @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\docview.jl:248
 [6] doc(binding::Base.Docs.Binding, sig::Type)
   @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\docview.jl:182
 [7] doc(binding::Base.Docs.Binding)
   @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\docview.jl:160
 [8] top-level scope
   @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\docview.jl:401

(@v1.6) pkg> st Grassmann
      Status `E:\.julia\environments\v1.6\Project.toml`
  [4df31cd9] Grassmann v0.7.3

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) W-10885M CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_CUDA_USE_BINARYBUILDER = false
  JULIA_DEPOT_PATH = E:\.julia
  JULIA_NUM_THREADS = 8
  JULIA_EDITOR = code

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.