Hermitian positive definite matrices
Manifolds.HermitianPositiveDefinite β Type
HermitianPositiveDefinite{π½,T} <: AbstractDecoratorManifold{π½}The manifold of Hermitian positive definite matrices
\[\mathcal H(n) := \bigl\{ p β π½^{nΓn}\ \big|\ p = p^{\mathrm{H}} \text{ and } a^{\mathrm{H}}pa > 0 \text{ for all } a β π½^{n}\backslash\{0\} \bigr\}\]
over the field $π½ β \{β, β\}$, where usually $π½=β$. For the case $π½=β$ this manifold is the manifold of symmetric positive definite matrices, see SymmetricPositiveDefinite.
The tangent space at $pβ\mathcal H(n)$ reads
\[ T_p\mathcal H(n) = \bigl\{ X \in π½^{nΓn} \big|\ X=X^\mathrm{H} \bigr\},\]
i.e. the set of Hermitian matrices, which are the symmetric matrices for $π½=β$.
The default metric is the AffineInvariantMetric.
Constructor
HermitianPositiveDefinite(n, π½=β; parameter::Symbol=:type)generates the manifold of Hermitian positive definite matrices $\mathcal H(n) \subset π½^{nΓn}$.
For the real case see the symmetric positive definite matrices.
Functions
Base.convert β Method
convert(::Type{AbstractMatrix}, p::MatrixSqrtManifoldPoint)return the point p as a matrix. The matrix is either stored within the MatrixSqrtManifoldPoint or reconstructed from p.eigen.
Base.rand β Method
rand(M::HermitianPositiveDefinite{β}; vector_at=nothing, tangent_distr=:Gaussian, Ο::Real=1/sqrt(n))Generate a random Hermitian positive definite matrix on the complex HermitianPositiveDefinite manifold M, or, if vector_at is a point $p$, a random tangent vector at $p$. The parameter Ο has no effect on a point.
For tangent_distr = :Gaussian the coordinates of the tangent vector in the DefaultOrthonormalBasis of $T_p\mathcal H(n)$ are independent and normally distributed with standard deviation Ο. For tangent_distr = :Rician the tangent vector is $RR^{\mathrm{H}}$ with $R = L + \sqrt{Ο}U$, where $L$ is the lower triangular Cholesky factor of $p$ and $U$ is upper triangular with independent complex standard normal entries; here Ο defaults to $1/\lVert p\rVert_{\mathrm{F}}$ instead.
ManifoldsBase.check_point β Method
check_point(M::HermitianPositiveDefinite, p; kwargs...)checks, whether p is a valid point on the HermitianPositiveDefinite M, i.e. is a matrix $p β π½^{nΓn}$ over the field $π½ β \{β,β\}$ of M, is Hermitian ($p^{\mathrm{H}} = p$, which is symmetric, $p^{\mathrm{T}} = p$, for $π½=β$) and positive definite, that is $a^{\mathrm{H}}pa > 0$ for all $a β π½^{n}\backslash\{0\}$. The tolerance for the second to last test can be set using the kwargs....
ManifoldsBase.check_vector β Method
check_vector(M::HermitianPositiveDefinite, p, X; kwargs... )Check whether X is a tangent vector to p on the HermitianPositiveDefinite M. After check_point(M,p), X has to be of the same dimension as p and a Hermitian matrix $X β π½^{nΓn}$, $X^{\mathrm{H}} = X$ (a symmetric matrix, $X^{\mathrm{T}} = X$, for $π½=β$), i.e. this stores tangent vectors as elements of the corresponding Lie group. The tolerance for the last test can be set using the kwargs....
ManifoldsBase.injectivity_radius β Method
injectivity_radius(M::HermitianPositiveDefinite[, p])
injectivity_radius(M::MetricManifold{HermitianPositiveDefinite,AffineInvariantMetric}[, p])Return the injectivity radius of the HermitianPositiveDefinite. Since M is a Hadamard manifold with respect to the AffineInvariantMetric, see [Smi05], Section II-B and Section III-C, the injectivity radius is globally $β$.
ManifoldsBase.is_flat β Method
is_flat(M::HermitianPositiveDefinite)Return true if the HermitianPositiveDefinite M is one-dimensional, i.e. for $n = 1$, and false otherwise.
ManifoldsBase.manifold_dimension β Method
manifold_dimension(M::HermitianPositiveDefinite{β})returns the dimension of HermitianPositiveDefinite M $=\mathcal H(n), n β β$, over $π½ = β$, i.e.
\[\dim \mathcal H(n) = n^2,\]
the real dimension of the Hermitian matrices. For the real case see manifold_dimension.
ManifoldsBase.project β Method
project(M::HermitianPositiveDefinite, p, X)project a matrix from the embedding onto the tangent space $T_p\mathcal H(n)$ of the HermitianPositiveDefinite matrices, i.e. the set of Hermitian matrices, by taking the Hermitian part $\frac{1}{2}(X + X^{\mathrm{H}})$.
ManifoldsBase.representation_size β Method
representation_size(M::HermitianPositiveDefinite)Return the size of an array representing an element on the HermitianPositiveDefinite manifold M, i.e. $nΓn$, the size of such a Hermitian positive definite matrix on $\mathcal M = \mathcal H(n)$.
ManifoldsBase.zero_vector β Method
zero_vector(M::HermitianPositiveDefinite, p)
zero_vector!(M::HermitianPositiveDefinite, X, p)returns the zero tangent vector in the tangent space of the Hermitian positive definite matrix p on the HermitianPositiveDefinite manifold M. It can be returned in place of X.
The affine invariant metric
HermitianPositiveDefinite is equipped with the AffineInvariantMetric, so any call of the following functions with H=HermitianPositiveDefinite(3) yields the same as with MetricManifold(H,AffineInvariantMetric()). The curvature tensor, the basis diagonalizing it, the minimal sectional curvature and the volume density are only available for the real case, see the symmetric positive definite matrices.
Base.exp β Method
exp(M::HermitianPositiveDefinite, p, X)
exp(M::MetricManifold{<:HermitianPositiveDefinite,AffineInvariantMetric}, p, X)Compute the exponential map from p with tangent vector X on the HermitianPositiveDefinite M with its default MetricManifold having the AffineInvariantMetric. The formula reads
\[\exp_p X = p^{\frac{1}{2}}\operatorname{Exp}(p^{-\frac{1}{2}} X p^{-\frac{1}{2}})p^{\frac{1}{2}},\]
where $\operatorname{Exp}$ denotes the matrix exponential, see [Smi05], Eq. (67).
Base.log β Method
log(M::HermitianPositiveDefinite, p, q)
log(M::MetricManifold{HermitianPositiveDefinite,AffineInvariantMetric}, p, q)Compute the logarithmic map from p to q on the HermitianPositiveDefinite as a MetricManifold with AffineInvariantMetric. The formula reads
\[\log_p q = p^{\frac{1}{2}}\operatorname{Log}(p^{-\frac{1}{2}}qp^{-\frac{1}{2}})p^{\frac{1}{2}},\]
where $\operatorname{Log}$ denotes the matrix logarithm, see [Smi05], Eq. (69); it is the inverse of the exponential map.
ManifoldDiff.riemannian_Hessian β Method
riemannian_Hessian(M::HermitianPositiveDefinite, p, G, H, X)The Riemannian Hessian can be computed as stated in Eq. (7.3) [Ngu23], which covers the real and the complex case. Let $\nabla f(p)$ denote the Euclidean gradient G, $\nabla^2 f(p)[X]$ the Euclidean Hessian H, and $\operatorname{sym}(X) = \frac{1}{2}\bigl(X^{\mathrm{H}}+X\bigr)$ the Hermitian part of $X$, which is its symmetric part for $π½=β$. Then the formula reads
\[ \operatorname{Hess}f(p)[X] = p\operatorname{sym}(β^2 f(p)[X])p + \operatorname{sym}\bigl( X\operatorname{sym}\bigl(β f(p)\bigr)p)\]
Manifolds.manifold_volume β Method
manifold_volume(::HermitianPositiveDefinite)Return volume of the HermitianPositiveDefinite manifold, i.e. infinity.
ManifoldsBase.change_metric β Method
change_metric(M::HermitianPositiveDefinite, E::EuclideanMetric, p, X)Given a tangent vector $X β T_p\mathcal H(n)$ with respect to the EuclideanMetric g_E, this function changes into the AffineInvariantMetric (default) metric on the HermitianPositiveDefinite M.
To be precise we are looking for $c\colon T_p\mathcal H(n) β T_p\mathcal H(n)$ such that for all $Y,Z β T_p\mathcal H(n)$ it holds
\[β¨Y,Zβ© = \operatorname{Re}\operatorname{tr}(Y^{\mathrm{H}}Z) = \operatorname{tr}(YZ) = \operatorname{tr}(p^{-1}c(Y)p^{-1}c(Z)) = g_p(c(Y),c(Z)).\]
Since $g_p(Y,Z) = \operatorname{tr}(p^{-1}Yp^{-1}Z) = \operatorname{tr}\bigl((p^{-\frac{1}{2}}Yp^{-\frac{1}{2}})(p^{-\frac{1}{2}}Zp^{-\frac{1}{2}})\bigr)$ by the cyclic property of the trace is the Frobenius inner product of $p^{-\frac{1}{2}}Yp^{-\frac{1}{2}}$ and $p^{-\frac{1}{2}}Zp^{-\frac{1}{2}}$, see [BH06], Eq. (5), the map $c(X) = p^{\frac{1}{2}}Xp^{\frac{1}{2}}$ is computed, which is Hermitian whenever $X$ is.
ManifoldsBase.change_representer β Method
change_representer(M::HermitianPositiveDefinite, E::EuclideanMetric, p, X)Compute the representer of the linear function given by $X β T_p\mathcal M$ with respect to the (default) AffineInvariantMetric on the HermitianPositiveDefinite M. Here X represents the linear function on the tangent space at p with respect to the EuclideanMetric g_E.
To be precise we are looking for $ZβT_p\mathcal H(n)$ such that for all $YβT_p\mathcal H(n)$ it holds
\[β¨X,Yβ© = \operatorname{Re}\operatorname{tr}(X^{\mathrm{H}}Y) = \operatorname{tr}(XY) = \operatorname{tr}(p^{-1}Zp^{-1}Y) = g_p(Z,Y)\]
and hence $Z = pXp$.
ManifoldsBase.distance β Method
distance(M::HermitianPositiveDefinite, p, q)
distance(M::MetricManifold{HermitianPositiveDefinite,AffineInvariantMetric}, p, q)Compute the distance on the HermitianPositiveDefinite manifold between p and q, as a MetricManifold with AffineInvariantMetric. The formula reads
\[d_{\mathcal H(n)}(p,q) = \lVert \operatorname{Log}(p^{-\frac{1}{2}}qp^{-\frac{1}{2}})\rVert_{\mathrm{F}},\]
where $\operatorname{Log}$ denotes the matrix logarithm and $\lVertβ \rVert_{\mathrm{F}}$ denotes the matrix Frobenius norm, see [BH06], Proposition 3, Eq. (17).
ManifoldsBase.get_basis β Method
[Ξ,ΞΊ] = get_basis(M::HermitianPositiveDefinite{β}, p, B::DefaultOrthonormalBasis)
[Ξ,ΞΊ] = get_basis(M::MetricManifold{β,<:HermitianPositiveDefinite{β},AffineInvariantMetric}, p, B::DefaultOrthonormalBasis)Return a default ONB for the tangent space $T_p\mathcal H(n)$ of the complex HermitianPositiveDefinite with respect to the AffineInvariantMetric.
\[ g_p(X,Y) = \operatorname{tr}(p^{-1} X p^{-1} Y) = \operatorname{Re}\operatorname{tr}\bigl( (p^{-\frac{1}{2}} X p^{-\frac{1}{2}})^{\mathrm{H}} (p^{-\frac{1}{2}} Y p^{-\frac{1}{2}}) \bigr),\]
that is, the Frobenius inner product of $p^{-\frac{1}{2}} X p^{-\frac{1}{2}}$ and $p^{-\frac{1}{2}} Y p^{-\frac{1}{2}}$, since the trace is cyclic and both are Hermitian. The basis constructed here is hence based on the following ONB for the Hermitian matrices with respect to the Frobenius inner product. Let
\[\Delta_{i,j} = (a_{k,l})_{k,l=1}^n \quad \text{ with } a_{k,l} = \begin{cases} 1 & \mbox{ for } k=l \text{ if } i=j\\ \frac{1}{\sqrt{2}} & \mbox{ for } k=i, l=j \text{ or } k=j, l=i\\ 0 & \text{ else,} \end{cases} \qquad i=1,\ldots,n, j=i,\ldots,n,\]
and
\[\Delta^{\mathrm{i}}_{i,j} = (b_{k,l})_{k,l=1}^n \quad \text{ with } b_{k,l} = \begin{cases} \frac{\mathrm{i}}{\sqrt{2}} & \mbox{ for } k=i, l=j\\ -\frac{\mathrm{i}}{\sqrt{2}} & \mbox{ for } k=j, l=i\\ 0 & \text{ else,} \end{cases} \qquad i=1,\ldots,n, j=i+1,\ldots,n,\]
where $\Delta^{\mathrm{i}}_{i,j}$ directly follows $\Delta_{i,j}$ in the ordering of the basis.
We then form the ONB by
\[ \Xi_{i,j} = p^{\frac{1}{2}}\Delta_{i,j}p^{\frac{1}{2}} \qquad\text{ and }\qquad \Xi^{\mathrm{i}}_{i,j} = p^{\frac{1}{2}}\Delta^{\mathrm{i}}_{i,j}p^{\frac{1}{2}}.\]
ManifoldsBase.get_coordinates β Method
get_coordinates(::HermitianPositiveDefinite{β}, p, X, ::DefaultOrthonormalBasis)Using the basis from get_basis the coordinates with respect to this ONB are the inner products with its basis vectors $\Xi_{i,j}$ and $\Xi^{\mathrm{i}}_{i,j}$,
\[ c_k = g_p(X, \Xi_{i,j}) = \operatorname{tr}(p^{-1} X p^{-1} \Xi_{i,j}), \qquad c_{k+1} = g_p(X, \Xi^{\mathrm{i}}_{i,j}) = \operatorname{tr}(p^{-1} X p^{-1} \Xi^{\mathrm{i}}_{i,j}),\]
where $k$ is the linearized index of the $i=1,\ldots,n, j=i,\ldots,n$ in the ordering of the basis, and the second coordinate only exists for $i<j$.
ManifoldsBase.get_vector β Method
get_vector(::HermitianPositiveDefinite{β}, p, c, ::DefaultOrthonormalBasis)Using the basis from get_basis the vector reconstruction with respect to this ONB can be simplified to
\[ X = p^{\frac{1}{2}} \Biggl( \sum_{i=1,j=i}^n c_k \Delta_{i,j} + \sum_{i=1,j=i+1}^n c_{k+1} \Delta^{\mathrm{i}}_{i,j} \Biggr) p^{\frac{1}{2}}\]
where $k$ is the linearized index of the $i=1,\ldots,n, j=i,\ldots,n$ in the ordering of the basis.
ManifoldsBase.inner β Method
inner(M::HermitianPositiveDefinite, p, X, Y)
inner(M::MetricManifold{HermitianPositiveDefinite,AffineInvariantMetric}, p, X, Y)Compute the inner product of X, Y in the tangent space of p on the HermitianPositiveDefinite manifold M, as a MetricManifold with AffineInvariantMetric. The formula reads
\[g_p(X,Y) = \operatorname{tr}(p^{-1} X p^{-1} Y),\]
see [Smi05], Eq. (4). The trace is real for Hermitian $X$ and $Y$, since by the cyclic property of the trace it equals $\operatorname{tr}\bigl((p^{-\frac{1}{2}}Xp^{-\frac{1}{2}})(p^{-\frac{1}{2}}Yp^{-\frac{1}{2}})\bigr)$, the trace of a product of two Hermitian matrices.
ManifoldsBase.is_flat β Method
is_flat(M::MetricManifold{π½,<:HermitianPositiveDefinite{π½},AffineInvariantMetric})Return true if the HermitianPositiveDefinite with AffineInvariantMetric is one-dimensional, i.e. for $n = 1$, and false otherwise.
ManifoldsBase.parallel_transport_to β Method
parallel_transport_to(M::HermitianPositiveDefinite, p, X, q)
parallel_transport_to(M::MetricManifold{HermitianPositiveDefinite,AffineInvariantMetric}, p, X, y)Compute the parallel transport of X from the tangent space at p to the tangent space at q on the HermitianPositiveDefinite as a MetricManifold with the AffineInvariantMetric. The formula reads
\[\mathcal P_{qβp}X = p^{\frac{1}{2}} \operatorname{Exp}\bigl( \frac{1}{2}p^{-\frac{1}{2}}\log_p(q)p^{-\frac{1}{2}} \bigr) p^{-\frac{1}{2}}X p^{-\frac{1}{2}} \operatorname{Exp}\bigl( \frac{1}{2}p^{-\frac{1}{2}}\log_p(q)p^{-\frac{1}{2}} \bigr) p^{\frac{1}{2}},\]
where $\operatorname{Exp}$ denotes the matrix exponential and log the logarithmic map on HermitianPositiveDefinite (again with respect to the AffineInvariantMetric), see [Smi05], Eq. (104), the parallel translation along the geodesic from $p$ in direction $D$, evaluated at $t = 1$ with $D = \log_p q$.
ManifoldsBase.sectional_curvature_max β Method
sectional_curvature_max(M::HermitianPositiveDefinite)Return the upper bound 0 of the sectional curvature of the HermitianPositiveDefinite M.
With the AffineInvariantMetric the sectional curvature is non-positive, see [Smi05], Eq. (28).
Statistics
Statistics.mean β Method
mean(
M::HermitianPositiveDefinite,
x::AbstractVector,
[w::AbstractWeights,]
method = GeodesicInterpolation();
kwargs...,
)Compute the Riemannian mean of x using GeodesicInterpolation.
Efficient representation
When a point p is used in several occasions, it might be beneficial to store the eigenvalues and vectors of p and optionally its square root and the inverse of the square root. The MatrixSqrtManifoldPoint can be used for exactly that.
Manifolds.MatrixSqrtManifoldPoint β Type
MatrixSqrtManifoldPoint{P,Q,R,E} <: AbstractManifoldPointA point represented by a matrix $p$ together with its eigenvalue decomposition.
The matrix $p β π½^{nΓn}$ is over a field $π½ β \{β,β\}$; besides its eigenvalue decomposition the point optionally stores $p$ itself, its matrix square root $p^{\frac{1}{2}}$ and the inverse $p^{-\frac{1}{2}}$ of the square root, to avoid their repeated computation.
This is for example used on the HermitianPositiveDefinite manifold.
Fields
p::Pthe matrix representation of the point ormissingeigen::Ethe eigenvalue decompositioneigen(Hermitian(p))ofpsqrt::Qthe matrix square root ofpormissingsqrt_inv::Rthe inverse of the matrix square root ofpormissing
Only the field eigen is always stored. Each of the other three fields can be set to missing (its field type is then Missing) to indicate that it is not stored; it is then computed from eigen when required, but still not stored.
Constructor
MatrixSqrtManifoldPoint(p::AbstractMatrix; store_p=true, store_sqrt=true, store_sqrt_inv=true)Create a MatrixSqrtManifoldPoint from the Hermitian positive definite matrix p, where you can optionally store p, sqrt and sqrt_inv.
and there are three internal functions to be able to use MatrixSqrtManifoldPoint interchangeably with the default representation as a matrix.
Manifolds.hpd_sqrt β Function
hpd_sqrt(p::AbstractMatrix)
hpd_sqrt(p::MatrixSqrtManifoldPoint)return $p^{\frac{1}{2}}$ by either computing it (if it is missing or for the AbstractMatrix) or returning the stored value from within the MatrixSqrtManifoldPoint.
This method assumes that p represents a Hermitian positive definite matrix.
Manifolds.hpd_sqrt_inv β Function
hpd_sqrt_inv(p::MatrixSqrtManifoldPoint)return $p^{-\frac{1}{2}}$ by either computing it (if it is missing or for the AbstractMatrix) or returning the stored value from within the MatrixSqrtManifoldPoint.
This method assumes that p represents a Hermitian positive definite matrix.
Manifolds.hpd_sqrt_and_sqrt_inv β Function
hpd_sqrt_and_sqrt_inv(p::AbstractMatrix)
hpd_sqrt_and_sqrt_inv(p::MatrixSqrtManifoldPoint)Return $p^{\frac{1}{2}}$ and $p^{-\frac{1}{2}}$ by either computing them (if they are missing or for the AbstractMatrix) or returning their stored value from within the MatrixSqrtManifoldPoint.
Compared to calling single methods hpd_sqrt and hpd_sqrt_inv this method only computes the eigenvectors once for the case of the AbstractMatrix or if both are missing.
This method assumes that p represents a Hermitian positive definite matrix.
Literature
- [BH06]
- R.Β Bhatia and J.Β Holbrook. Riemannian geometry and matrix geometric means. LinearΒ AlgebraΒ andΒ itsΒ Applications 413, 594β618 (2006).
- [Ngu23]
- D.Β Nguyen. Operator-Valued Formulas for Riemannian Gradient and Hessian and Families of Tractable Metrics in Riemannian Optimization. JournalΒ ofΒ OptimizationΒ TheoryΒ andΒ Applications 198, 135β164 (2023), arXiv:2009.10159.
- [Smi05]
- S.Β T.Β Smith. Covariance, Subspace, and Intrinsic CramΓ©rβRao Bounds. IEEEΒ TransactionsΒ onΒ SignalΒ Processing 53, 1610β1630 (2005).