Skip to contents

Class for the manifold of symmetric positive definite (SPD) matrices.

See also

Other symmetric positive definite matrix classes: SPDMatrix()

Author

Yann Thanwerdas

Super classes

rgeomstats::PythonClass -> rgeomstats::Manifold -> rgeomstats::OpenSet -> SPDMatrices

Public fields

n

An integer value specifying the number of rows and columns of the matrices.

Methods

Inherited methods


Method new()

The SPDMatrices class constructor.

Usage

SPDMatrices$new(n, ..., py_cls = NULL)

Arguments

n

An integer value specifying the number of rows and columns of the matrices.

...

Extra arguments to be passed to parent class constructors. See OpenSet and Manifold classes.

py_cls

A Python object of class SPDMatrices. Defaults to NULL in which case it is instantiated on the fly using the other input arguments.

Returns

An object of class SPDMatrices.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3
}


Method cholesky_factor()

Computes Cholesky factor for a symmetric positive definite matrix.

Usage

SPDMatrices$cholesky_factor(mat)

Arguments

mat

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices.

Returns

A numeric array of the same shape storing the corresponding Cholesky factors.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$cholesky_factor(A)
}


Method differential_cholesky_factor()

Computes the differential of the Cholesky factor map.

Usage

SPDMatrices$differential_cholesky_factor(tangent_vec, base_point)

Arguments

tangent_vec

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices at corresponding base points.

base_point

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices specifying base points for the input tangent vectors.

Returns

A numeric array of shape \([\dots \times n \times n]\) storing the differentials of the corresponding Cholesky factor maps.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_cholesky_factor(diag(1, 3), A)
}


Method expm()

Computes the matrix exponential for a symmetric matrix.

Usage

SPDMatrices$expm(mat)

Arguments

mat

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices.

Returns

A numeric array of the same shape storing the corresponding matrix exponentials.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$expm(diag(-1, 3))
}


Method differential_exp()

Computes the differential of the matrix exponential.

Usage

SPDMatrices$differential_exp(tangent_vec, base_point)

Arguments

tangent_vec

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices at corresponding base points.

base_point

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices specifying base points for the input tangent vectors.

Returns

A numeric array of shape \([\dots \times n \times]\) storing the differentials of matrix exponential at corresponding base points applied to corresponding tangent vectors.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_exp(diag(1, 3), A)
}


Method inverse_differential_exp()

Computes the inverse of the differential of the matrix exponential.

Usage

SPDMatrices$inverse_differential_exp(tangent_vec, base_point)

Arguments

tangent_vec

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices at corresponding base points.

base_point

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices specifying base points for the input tangent vectors.

Returns

A numeric array of shape \([\dots \times n \times]\) storing the inverse of the differentials of matrix exponential at corresponding base points applied to corresponding tangent vectors.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$inverse_differential_exp(diag(1, 3), A)
}


Method logm()

Computes the matrix logarithm of an SPD matrix.

Usage

SPDMatrices$logm(mat)

Arguments

mat

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices.

Returns

A numeric array of the same shape storing the logarithms of the input SPD matrices.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$logm(diag(1, 3))
}


Method differential_log()

Computes the differential of the matrix logarithm.

Usage

SPDMatrices$differential_log(tangent_vec, base_point)

Arguments

tangent_vec

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices at corresponding base points.

base_point

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices specifying base points for the input tangent vectors.

Returns

A numeric array of shape \([\dots \times n \times]\) storing the differentials of matrix logarithm at corresponding base points applied to corresponding tangent vectors.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_log(diag(1, 3), A)
}


Method inverse_differential_log()

Computes the inverse of the differential of the matrix logarithm.

Usage

SPDMatrices$inverse_differential_log(tangent_vec, base_point)

Arguments

tangent_vec

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices at corresponding base points.

base_point

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices specifying base points for the input tangent vectors.

Returns

A numeric array of shape \([\dots \times n \times]\) storing the inverse of the differentials of matrix logarithm at corresponding base points applied to corresponding tangent vectors.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$inverse_differential_log(diag(1, 3), A)
}


Method powerm()

Computes the matrix power of an SPD matrix.

Usage

SPDMatrices$powerm(mat, power)

Arguments

mat

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices.

power

A numeric value or vector specifying the desired power(s).

Returns

A numeric array of the same shape as mat storing the corresponding matrix powers computed as: $$A^p = \exp(p \log(A)).$$ If power is a vector, a list of such arrays is returned.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$powerm(diag(1, 3), 2)
}


Method differential_power()

Computes the differential of the matrix power function.

Usage

SPDMatrices$differential_power(power, tangent_vec, base_point)

Arguments

power

An integer value specifying the desired power.

tangent_vec

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices at corresponding base points.

base_point

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices specifying base points for the input tangent vectors.

Returns

A numeric array of shape \([\dots \times n \times]\) storing the differential of the power function $$A^p = \exp(p \log(A))$$ at corresponding base points applied to corresponding tangent vectors.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_power(2, diag(1, 3), A)
}


Method inverse_differential_power()

Computes the inverse of the differential of the matrix power function.

Usage

SPDMatrices$inverse_differential_power(power, tangent_vec, base_point)

Arguments

power

An integer value specifying the desired power.

tangent_vec

A numeric array of shape \([\dots \times n \times n]\) specifying one or more symmetric matrices at corresponding base points.

base_point

A numeric array of shape \([\dots \times n \times n]\) specifying one or more SPD matrices specifying base points for the input tangent vectors.

Returns

A numeric array of shape \([\dots \times n \times]\) storing the inverse of the differential of the power function $$A^p = \exp(p \log(A))$$ at corresponding base points applied to corresponding tangent vectors.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$inverse_differential_power(2, diag(1, 3), A)
}


Method clone()

The objects of this class are cloneable with this method.

Usage

SPDMatrices$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `SPDMatrices$new`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3
}

## ------------------------------------------------
## Method `SPDMatrices$cholesky_factor`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$cholesky_factor(A)
}

## ------------------------------------------------
## Method `SPDMatrices$differential_cholesky_factor`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_cholesky_factor(diag(1, 3), A)
}

## ------------------------------------------------
## Method `SPDMatrices$expm`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$expm(diag(-1, 3))
}

## ------------------------------------------------
## Method `SPDMatrices$differential_exp`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_exp(diag(1, 3), A)
}

## ------------------------------------------------
## Method `SPDMatrices$inverse_differential_exp`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$inverse_differential_exp(diag(1, 3), A)
}

## ------------------------------------------------
## Method `SPDMatrices$logm`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$logm(diag(1, 3))
}

## ------------------------------------------------
## Method `SPDMatrices$differential_log`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_log(diag(1, 3), A)
}

## ------------------------------------------------
## Method `SPDMatrices$inverse_differential_log`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$inverse_differential_log(diag(1, 3), A)
}

## ------------------------------------------------
## Method `SPDMatrices$powerm`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$powerm(diag(1, 3), 2)
}

## ------------------------------------------------
## Method `SPDMatrices$differential_power`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$differential_power(2, diag(1, 3), A)
}

## ------------------------------------------------
## Method `SPDMatrices$inverse_differential_power`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  V <- cbind(
    c(sqrt(2) / 2, -sqrt(2) / 2, 0),
    c(sqrt(2) / 2, sqrt(2) / 2, 0),
    c(0, 0, 1)
  )
  A <- V %*% diag(1:3) %*% t(V)
  spd3$inverse_differential_power(2, diag(1, 3), A)
}