From b052267195edd0d91234bc66299b3eee27c5445a Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Wed, 1 Jan 2025 20:58:34 +0100 Subject: [PATCH] improve coverage --- NEWS.md | 2 +- src/manifolds/InvertibleMatrices.jl | 23 +++++++++++++++++++++-- test/manifolds/invertible_matrices.jl | 6 +++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 817aa1438..15944038b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,7 @@ 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.10.11] - unreleased +## [0.10.11] - 2025-01-02 ### Added diff --git a/src/manifolds/InvertibleMatrices.jl b/src/manifolds/InvertibleMatrices.jl index e75876d16..f77330254 100644 --- a/src/manifolds/InvertibleMatrices.jl +++ b/src/manifolds/InvertibleMatrices.jl @@ -59,6 +59,25 @@ end embed(::InvertibleMatrices, p) = p embed(::InvertibleMatrices, p, X) = X +function get_coordinates( + ::InvertibleMatrices{ℝ,<:Any}, + p, + X, + ::DefaultOrthonormalBasis{ℝ,TangentSpaceType}, +) + return vec(X) +end + +function get_coordinates!( + ::InvertibleMatrices{ℝ,<:Any}, + Xⁱ, + p, + X, + ::DefaultOrthonormalBasis{ℝ,TangentSpaceType}, +) + return copyto!(Xⁱ, X) +end + function get_embedding(::InvertibleMatrices{𝔽,TypeParameter{Tuple{n}}}) where {n,𝔽} return Euclidean(n, n; field=𝔽) end @@ -68,7 +87,7 @@ function get_embedding(M::InvertibleMatrices{𝔽,Tuple{Int}}) where {𝔽} end function get_vector( - M::InvertibleMatrices{<:Any,ℝ}, + M::InvertibleMatrices{ℝ,<:Any}, p, Xⁱ, ::DefaultOrthonormalBasis{ℝ,TangentSpaceType}, @@ -78,7 +97,7 @@ function get_vector( end function get_vector!( - ::InvertibleMatrices{<:Any,ℝ}, + ::InvertibleMatrices{ℝ,<:Any}, X, p, Xⁱ, diff --git a/test/manifolds/invertible_matrices.jl b/test/manifolds/invertible_matrices.jl index 017a2159a..0b71edc2f 100644 --- a/test/manifolds/invertible_matrices.jl +++ b/test/manifolds/invertible_matrices.jl @@ -1,4 +1,4 @@ -using LinearAlgebra, Manifolds, ManifoldsBase, Test +using LinearAlgebra, Manifolds, ManifoldsBase, Test, Random @testset "Invertible matrices" begin M = InvertibleMatrices(3, ℝ) @@ -26,7 +26,11 @@ using LinearAlgebra, Manifolds, ManifoldsBase, Test @test Weingarten(M, A, A, A) == zero(A) @test is_point(M, rand(M)) + @test is_point(M, rand(Random.MersenneTwister(), M)) @test is_vector(M, A, rand(M; vector_at=A)) + + @test get_coordinates(M, A, A, DefaultOrthonormalBasis()) == vec(A) + @test get_vector(M, A, vec(A), DefaultOrthonormalBasis()) == A end @testset "Complex invertible matrices" begin @test repr(Mc) == "InvertibleMatrices(3, ℂ)"