Skip to content

Commit

Permalink
Faster get_basis_orthonormal (#118)
Browse files Browse the repository at this point in the history
* faster get_orthonormal_basis

* formatting

* bump version
  • Loading branch information
mateuszbaran authored Jul 20, 2022
1 parent 1f022f9 commit e509370
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ManifoldsBase"
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.13.13"
version = "0.13.14"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
51 changes: 28 additions & 23 deletions src/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,11 @@ function get_basis_orthonormal(M::AbstractManifold, p, N::AbstractNumbers; kwarg
B = DefaultOrthonormalBasis(N)
dim = number_of_coordinates(M, B)
Eltp = number_eltype(p)
p0 = zero(Eltp)
p1 = one(Eltp)
return CachedBasis(
B,
[
get_vector(M, p, [ifelse(i == j, one(Eltp), zero(Eltp)) for j in 1:dim], B) for
i in 1:dim
],
[get_vector(M, p, [ifelse(i == j, p1, p0) for j in 1:dim], B) for i in 1:dim],
)
end

Expand Down Expand Up @@ -621,28 +620,28 @@ requires either a dual basis or the cached basis to be selfdual, for example ort
See also: [`get_coordinates`](@ref), [`get_basis`](@ref)
"""
function get_vector(M::AbstractManifold, p, c, B::AbstractBasis)
@inline function get_vector(M::AbstractManifold, p, c, B::AbstractBasis)
return _get_vector(M, p, c, B)
end

function _get_vector(M::AbstractManifold, p, c, B::VeeOrthogonalBasis)
@inline function _get_vector(M::AbstractManifold, p, c, B::VeeOrthogonalBasis)
return get_vector_vee(M, p, c, number_system(B))
end
function get_vector_vee(M::AbstractManifold, p, c, N)
@inline function get_vector_vee(M::AbstractManifold, p, c, N)
return get_vector(M, p, c, DefaultOrthogonalBasis(N))
end

function _get_vector(M::AbstractManifold, p, c, B::DefaultBasis)
@inline function _get_vector(M::AbstractManifold, p, c, B::DefaultBasis)
return get_vector_default(M, p, c, number_system(B))
end
function get_vector_default(M::AbstractManifold, p, c, N)
@inline function get_vector_default(M::AbstractManifold, p, c, N)
return get_vector(M, p, c, DefaultOrthogonalBasis(N))
end

function _get_vector(M::AbstractManifold, p, c, B::DefaultOrthogonalBasis)
@inline function _get_vector(M::AbstractManifold, p, c, B::DefaultOrthogonalBasis)
return get_vector_orthogonal(M, p, c, number_system(B))
end
function get_vector_orthogonal(M::AbstractManifold, p, c, N)
@inline function get_vector_orthogonal(M::AbstractManifold, p, c, N)
return get_vector_orthonormal(M, p, c, N)
end

Expand All @@ -655,7 +654,7 @@ function get_vector_orthonormal(M::AbstractManifold, p, c, N)
return get_vector!(M, Y, p, c, B)
end

function _get_vector(M::AbstractManifold, p, c, B::DiagonalizingOrthonormalBasis)
@inline function _get_vector(M::AbstractManifold, p, c, B::DiagonalizingOrthonormalBasis)
return get_vector_diagonalizing(M, p, c, B)
end
function get_vector_diagonalizing(
Expand All @@ -668,7 +667,7 @@ function get_vector_diagonalizing(
return get_vector!(M, Y, p, c, B)
end

function _get_vector(M::AbstractManifold, p, c, B::CachedBasis)
@inline function _get_vector(M::AbstractManifold, p, c, B::CachedBasis)
return get_vector_cached(M, p, c, B)
end
_get_vector_cache_broadcast(::Any) = Val(true)
Expand All @@ -691,40 +690,46 @@ function get_vector_cached(M::AbstractManifold, p, X, B::CachedBasis)
end
return Xt
end
function get_vector!(M::AbstractManifold, Y, p, c, B::AbstractBasis)
@inline function get_vector!(M::AbstractManifold, Y, p, c, B::AbstractBasis)
return _get_vector!(M, Y, p, c, B)
end

function _get_vector!(M::AbstractManifold, Y, p, c, B::VeeOrthogonalBasis)
@inline function _get_vector!(M::AbstractManifold, Y, p, c, B::VeeOrthogonalBasis)
return get_vector_vee!(M, Y, p, c, number_system(B))
end
get_vector_vee!(M, Y, p, c, N) = get_vector!(M, Y, p, c, DefaultOrthogonalBasis(N))
@inline get_vector_vee!(M, Y, p, c, N) = get_vector!(M, Y, p, c, DefaultOrthogonalBasis(N))

function _get_vector!(M::AbstractManifold, Y, p, c, B::DefaultBasis)
@inline function _get_vector!(M::AbstractManifold, Y, p, c, B::DefaultBasis)
return get_vector_default!(M, Y, p, c, number_system(B))
end
function get_vector_default!(M::AbstractManifold, Y, p, c, N)
@inline function get_vector_default!(M::AbstractManifold, Y, p, c, N)
return get_vector!(M, Y, p, c, DefaultOrthogonalBasis(N))
end

function _get_vector!(M::AbstractManifold, Y, p, c, B::DefaultOrthogonalBasis)
@inline function _get_vector!(M::AbstractManifold, Y, p, c, B::DefaultOrthogonalBasis)
return get_vector_orthogonal!(M, Y, p, c, number_system(B))
end
function get_vector_orthogonal!(M::AbstractManifold, Y, p, c, N)
@inline function get_vector_orthogonal!(M::AbstractManifold, Y, p, c, N)
return get_vector!(M, Y, p, c, DefaultOrthonormalBasis(N))
end

function _get_vector!(M::AbstractManifold, Y, p, c, B::DefaultOrthonormalBasis)
@inline function _get_vector!(M::AbstractManifold, Y, p, c, B::DefaultOrthonormalBasis)
return get_vector_orthonormal!(M, Y, p, c, number_system(B))
end
function get_vector_orthonormal! end

function _get_vector!(M::AbstractManifold, Y, p, c, B::DiagonalizingOrthonormalBasis)
@inline function _get_vector!(
M::AbstractManifold,
Y,
p,
c,
B::DiagonalizingOrthonormalBasis,
)
return get_vector_diagonalizing!(M, Y, p, c, B)
end
function get_vector_diagonalizing! end

function _get_vector!(M::AbstractManifold, Y, p, c, B::CachedBasis)
@inline function _get_vector!(M::AbstractManifold, Y, p, c, B::CachedBasis)
return get_vector_cached!(M, Y, p, c, B)
end
function get_vector_cached!(M::AbstractManifold, Y, p, X, B::CachedBasis)
Expand Down

2 comments on commit e509370

@mateuszbaran
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/64589

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.14 -m "<description of version>" e50937069b4da5f3c7c52f5513390ab09720cbea
git push origin v0.13.14

Please sign in to comment.