Skip to content

Commit

Permalink
remove bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Oct 8, 2023
1 parent d77c997 commit 58b39bd
Show file tree
Hide file tree
Showing 16 changed files with 203 additions and 1,472 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ module ManifoldsBaseRecursiveArrayToolsExt
if isdefined(Base, :get_extension)
using ManifoldsBase
using RecursiveArrayTools
using ManifoldsBase:
AbstractBasis,
FiberBundle,
FiberBundleBasisData,
FiberBundleProductVectorTransport,
ProductBasisData,
TangentSpaceType
using ManifoldsBase: AbstractBasis, ProductBasisData, TangentSpaceType
using ManifoldsBase: number_of_components
using Random

Expand Down Expand Up @@ -41,13 +35,7 @@ else
# https://github.com/JuliaArrays/ArrayInterface.jl/pull/387
using ..ManifoldsBase
using ..RecursiveArrayTools
using ..ManifoldsBase:
AbstractBasis,
FiberBundle,
FiberBundleBasisData,
FiberBundleProductVectorTransport,
ProductBasisData,
TangentSpaceType
using ..ManifoldsBase: AbstractBasis, ProductBasisData, TangentSpaceType
using ..ManifoldsBase: number_of_components
using ..Random

Expand Down Expand Up @@ -77,6 +65,5 @@ else
end

include("ProductManifoldRecursiveArrayToolsExt.jl")
include("FiberBundleRecursiveArrayToolsExt.jl")

end
91 changes: 12 additions & 79 deletions src/Fiber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,7 @@ An abstract type for fiber types.
abstract type FiberType end

"""
BundleFibers(fiber::FiberType, M::AbstractManifold)
Type representing a family of fibers of a fiber bundle over `M`
with vectorfiber of type `fiber`. In contrast with `FiberBundle`, operations
on `BundleFibers` expect point-like and fiber-like parts to be
passed separately instead of being bundled together. It can be thought of
as a representation of fibers from a fiber bundle but without
storing the point at which a fiber is attached (which is specified
separately in various functions).
"""
struct BundleFibers{TF<:FiberType,TM<:AbstractManifold}
fiber::TF
manifold::TM
end

"""
FiberAtPoint{
Fiber{
𝔽,
TFiber<:BundleFibers{<:FiberType,<:AbstractManifold{𝔽}},
TX,
Expand All @@ -38,80 +22,29 @@ isometric to the [`Euclidean`](https://juliamanifolds.github.io/Manifolds.jl/lat
# Constructor
FiberAtPoint(fiber::BundleFibers, p)
Fiber(fiber_type::FiberType, manifold::AbstractManifold, p)
A fiber of type `fiber` at point `p` from the manifold `fiber.manifold`.
A fiber of type `fiber_type` at point `p` from the manifold `manifold`.
"""
struct FiberAtPoint{𝔽,TFiber<:BundleFibers{<:FiberType,<:AbstractManifold{𝔽}},TX} <:
AbstractManifold{𝔽}
fiber::TFiber
struct Fiber{𝔽,TFiber<:FiberType,TM<:AbstractManifold{𝔽},TX} <: AbstractManifold{𝔽}
fiber_type::TFiber
manifold::TM
point::TX
end

"""
allocate_result(B::BundleFibers, f, x...)
Allocates an array for the result of function `f` that is
an element of the fiber space of type `B.fiber` on manifold `B.manifold`
and arguments `x...` for implementing the non-modifying operation
using the modifying operation.
"""
@inline function allocate_result(B::BundleFibers, f::TF, x...) where {TF}
if length(x) == 0
# TODO: this may be incorrect when point and tangent vector representation are
# different for the manifold but there is no easy and generic way around that
return allocate_result(B.manifold, f)
else
T = allocate_result_type(B, f, x)
return allocate(x[1], T)
end
end

"""
allocate_result_type(B::BundleFibers, f, args::NTuple{N,Any}) where N
base_manifold(B::Fiber) = B.manifold

Return type of element of the array that will represent the result of
function `f` for representing an operation with result in the fiber `fiber`
for manifold `M` on given arguments (passed at a tuple).
"""
@inline function allocate_result_type(
::BundleFibers,
f::TF,
args::NTuple{N,Any},
) where {TF,N}
return typeof(mapreduce(eti -> one(number_eltype(eti)), +, args))
end

base_manifold(B::BundleFibers) = base_manifold(B.manifold)
base_manifold(B::FiberAtPoint) = base_manifold(B.fiber)

function fiber_dimension(B::BundleFibers)
return fiber_dimension(B.manifold, B.fiber)
end

function Base.show(io::IO, fiber::BundleFibers)
return print(io, "BundleFibers($(fiber.fiber), $(fiber.manifold))")
end
function Base.show(io::IO, ::MIME"text/plain", vs::FiberAtPoint)
function Base.show(io::IO, ::MIME"text/plain", vs::Fiber)
summary(io, vs)
println(io, "\nFiber:")
pre = " "
sf = sprint(show, "text/plain", vs.fiber; context = io, sizehint = 0)
sf = sprint(show, "text/plain", vs.fiber_type; context = io, sizehint = 0)
sf = replace(sf, '\n' => "\n$(pre)")
println(io, pre, sf)
sm = sprint(show, "text/plain", vs.manifold; context = io, sizehint = 0)
sm = replace(sm, '\n' => "\n$(pre)")
println(io, pre, sf, sm)
println(io, "Base point:")
sp = sprint(show, "text/plain", vs.point; context = io, sizehint = 0)
sp = replace(sp, '\n' => "\n$(pre)")
return print(io, pre, sp)
end

"""
zero_vector(B::BundleFibers, p)
Compute the zero vector from the vector space of type `B.fiber` at point `p`
from manifold `B.manifold`.
"""
function zero_vector(B::BundleFibers, p)
X = allocate_result(B, zero_vector, p)
return zero_vector!(B, X, p)
end
Loading

0 comments on commit 58b39bd

Please sign in to comment.