Skip to content

Commit

Permalink
implemented compatibility for MiniQhull delaunay
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Jun 20, 2020
1 parent 215f26a commit d1b800b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,7 +1,7 @@
name = "Grassmann"
uuid = "4df31cd9-4c27-5bea-88d0-e6a7146666d8"
authors = ["Michael Reed"]
version = "0.5.12"
version = "0.5.13"

[deps]
AbstractTensors = "a8e43f4a-99b7-5565-8bf1-0165161caaea"
Expand Down
6 changes: 6 additions & 0 deletions src/Grassmann.jl
Expand Up @@ -368,6 +368,12 @@ function __init__()
end
end
#@require Makie="ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" nothing
@require MiniQhull="978d7f02-9e05-4691-894f-ae31a51d76ca" begin
function MiniQhull.delaunay(p::ChainBundle)
T = MiniQhull.delaunay(Matrix(submesh(p)'))
ChainBundle([Chain{p,1,Int}(Int.(T[1:3,k])) for k 1:size(T,2)])
end
end
@require MATLAB="10e44e05-a98a-55b3-a45b-ba969058deb6" begin
const matlab_cache = (Array{T,2} where T)[]
function matlab(p::Array{T,2} where T,B)
Expand Down
9 changes: 5 additions & 4 deletions src/composite.jl
Expand Up @@ -340,17 +340,15 @@ end
:(Chain{V,1}(getindex.($(Expr(:call,:./,out,:(t[1]$(y[end])))),1))))
end

Base.:\(t::Chain{V,1,<:Chain{V,1}},v::Chain{V,1}) where V = value(t)\v

@generated function Base.in(v::Chain{V,1},t::Chain{V,1,<:Chain{V,1}}) where V
@generated function Base.in(v::Chain{V,1},t::SVector{N,<:Chain{V,1}} where N) where V
N = ndims(V)-1
x,y,xy = Grassmann.Cramer(N)
out = Expr(:call,:SVector,:(s==signbit((v$(y[end]))[1])),[:(s==signbit(($(x[i])v$(y[end-i]))[1])) for i 1:N-1]...,:(s==signbit(($(x[end])v)[1])))
return Expr(:block,:((x1,y1)=(t[1],t[end])),xy...,:(s=signbit((t[1]$(y[end]))[1])),
Expr(:call,:prod,out))
end

@generated function Base.inv(t::Chain{V,1,<:Chain{V,1}}) where V
@generated function Base.inv(t::SVector{N,<:Chain{V,1}} where N) where V
N = ndims(V)-1
x,y,xy = Grassmann.Cramer(N)
out = if iseven(N)
Expand All @@ -361,6 +359,9 @@ end
return Expr(:block,:((x1,y1)=(t[1],t[end])),xy...,:(_transpose(.⋆($(Expr(:call,:./,out,:((t[1]$(y[end]))[1])))))))
end

Base.:\(t::Chain{V,1,<:Chain{V,1}},v::Chain{V,1}) where V = value(t)\v
Base.in(v::Chain{V,1},t::Chain{V,1,<:Chain{V,1}}) where V = v value(t)
Base.inv(t::Chain{V,1,<:Chain{V,1}}) where V = inv(value(t))
INV(m::Chain{V,1,<:Chain{V,1}}) where V = Chain{V,1,Chain{V,1}}(inv(SMatrix(m)))

export detsimplex, initmesh, refinemesh, refinemesh!, select, submesh
Expand Down
2 changes: 1 addition & 1 deletion src/multivectors.jl
Expand Up @@ -73,7 +73,7 @@ Chain{V,1,Chain{W,1}}(m::SMatrix{M,N}) where {V,W,M,N} = Chain{V,1}(Chain{W,1}.(

transpose_row(t::SVector{N,<:Chain{V}},i) where {N,V} = Chain{V,1}(getindex.(t,i))
transpose_row(t::Chain{V,1,<:Chain},i) where V = transpose_row(value(t),i)
@generated _transpose(t::SVector{N,<:Chain{V,1}}) where {N,V} = :(Chain{V,1}(transpose_row.(Ref(t),$(SVector{ndims(V)}(indices(V))))))
@generated _transpose(t::SVector{N,<:Chain{V,1}}) where {N,V} = :(Chain{V,1}(transpose_row.(Ref(t),$(SVector{ndims(V)}(1:ndims(V))))))
Base.transpose(t::Chain{V,1,<:Chain{V,1}}) where V = _transpose(value(t))

function show(io::IO, m::Chain{V,G,T}) where {V,G,T}
Expand Down

0 comments on commit d1b800b

Please sign in to comment.