diff --git a/NEWS.md b/NEWS.md index f303ecfc..05342320 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.15.12] 03/08/2024 + +### Changed + +* Improved performance of power manifold creation and some cases of `get_component` on product manifold. + ## [0.15.11] 28/07/2024 ### Added diff --git a/ext/ManifoldsBaseRecursiveArrayToolsExt/ProductManifoldRecursiveArrayToolsExt.jl b/ext/ManifoldsBaseRecursiveArrayToolsExt/ProductManifoldRecursiveArrayToolsExt.jl index 86ba2956..4ee61b84 100644 --- a/ext/ManifoldsBaseRecursiveArrayToolsExt/ProductManifoldRecursiveArrayToolsExt.jl +++ b/ext/ManifoldsBaseRecursiveArrayToolsExt/ProductManifoldRecursiveArrayToolsExt.jl @@ -148,7 +148,7 @@ Access the element(s) at index `i` of a point `p` on a [`ProductManifold`](@ref) linear indexing. See also [Array Indexing](https://docs.julialang.org/en/v1/manual/arrays/#man-array-indexing-1) in Julia. """ -Base.@propagate_inbounds function Base.getindex( +@inline Base.@propagate_inbounds function Base.getindex( p::ArrayPartition, M::ProductManifold, i::Union{Integer,Colon,AbstractVector,Val}, diff --git a/src/ManifoldsBase.jl b/src/ManifoldsBase.jl index b5a43ef7..ff21a94c 100644 --- a/src/ManifoldsBase.jl +++ b/src/ManifoldsBase.jl @@ -38,6 +38,16 @@ include("exp_log_geo.jl") include("projections.jl") include("metric.jl") +if isdefined(Base, Symbol("@constprop")) + macro aggressive_constprop(ex) + return esc(:(Base.@constprop :aggressive $ex)) + end +else + macro aggressive_constprop(ex) + return esc(ex) + end +end + """ allocate(a) allocate(a, dims::Integer...) diff --git a/src/PowerManifold.jl b/src/PowerManifold.jl index 037b9032..68bacbb5 100644 --- a/src/PowerManifold.jl +++ b/src/PowerManifold.jl @@ -100,7 +100,7 @@ function _parameter_symbol( return :type end -function PowerManifold( +@aggressive_constprop function PowerManifold( M::AbstractManifold{𝔽}, ::TPR, size::Integer...; @@ -109,7 +109,7 @@ function PowerManifold( size_w = wrap_type_parameter(parameter, size) return PowerManifold{𝔽,typeof(M),typeof(size_w),TPR}(M, size_w) end -function PowerManifold( +@aggressive_constprop function PowerManifold( M::PowerManifold{𝔽,TM,TSize,TPR}, size::Integer...; parameter::Symbol = _parameter_symbol(M), @@ -117,7 +117,7 @@ function PowerManifold( size_w = wrap_type_parameter(parameter, (get_parameter(M.size)..., size...)) return PowerManifold{𝔽,TM,typeof(size_w),TPR}(M.manifold, size_w) end -function PowerManifold( +@aggressive_constprop function PowerManifold( M::PowerManifold{𝔽,TM}, ::TPR, size::Integer...; diff --git a/src/ProductManifold.jl b/src/ProductManifold.jl index 3a4d42bd..8e3b3c39 100644 --- a/src/ProductManifold.jl +++ b/src/ProductManifold.jl @@ -445,7 +445,7 @@ end Get the `i`th component of a point `p` on a [`ProductManifold`](@ref) `M`. """ -function get_component(M::ProductManifold, p, i) +@inline function get_component(M::ProductManifold, p, i) return submanifold_component(M, p, i) end