lucid  0.0.1
Lifting-based Uncertain Control Invariant Dynamics
Loading...
Searching...
No Matches
lucid::GramMatrix Class Reference

Gram Matrix obtained from a kernel function. More...

#include <GramMatrix.h>

Public Member Functions

template<class Derived>
 GramMatrix (const Kernel &kernel, const MatrixBase< Derived > &initial_states)
 Compute the Gram matrix from the kernel and the initial states.
 
template<class Derived>
 GramMatrix (const Kernel &kernel, const MatrixBase< Derived > &initial_states, std::vector< Matrix > &gradient)
 Compute the Gram matrix from the kernel and the initial states.
 
template<class Derived>
 GramMatrix (const Kernel &kernel, const MatrixBase< Derived > &initial_states, std::vector< Matrix > *const gradient)
 Compute the Gram matrix from the kernel and the initial states.
 
void compute_coefficients (const Matrix &transition_states)
 Given the initial state \( x \in \mathcal{X} \), compute the coefficients \( \alpha \in \mathbb{R}^n \).
 
GramMatrixadd_diagonal_term (Scalar diagonal_term)
 Add a diagonal term to the Gram matrix.
 
template<class Derived>
Matrix operator* (const MatrixBase< Derived > &A) const
 Right multiply the Gram matrix with another matrix, \( KA \).
 
template<class Derived>
Matrix inverse_mult (const MatrixBase< Derived > &A) const
 Right multiply the inverse of the Gram matrix with another matrix, \( K^{-1}A \).
 
const Matrix & gram_matrix () const
 Get read-only access to the internal matrix structure of the Gramm matrix.
 
Dimension rows () const
 Get read-only access to the number of rows of the Gramm matrix.
 
Dimension cols () const
 Get read-only access to the number of columns of the Gramm matrix.
 

Private Attributes

Matrix gram_matrix_
 Gram matrix.
 
Eigen::LLT< Matrix, Eigen::Lower > decomposition_
 Cached Cholesky decomposition of the Gram matrix.
 

Detailed Description

Gram Matrix obtained from a kernel function.

Given a vector space \( \texttip{\mathcal{X}}{Polish sample vector space} \) and a kernel function \( k: \mathcal{X} \times \mathcal{X} \to \mathbb{R} \), the Gram matrix is defined as the matrix \( K \in \mathbb{R}^{n \times n} \) where \( K_{ij} = k(x_i, x_j) \) or, equivalently,

\[K = \begin{bmatrix} k(x_1, x_1) & k(x_1, x_2) & \cdots & k(x_1, x_n) \\ k(x_2, x_1) & k(x_2, x_2) & \cdots & k(x_2, x_n) \\ \vdots & \vdots & \ddots & \vdots \\ k(x_n, x_1) & k(x_n, x_2) & \cdots & k(x_n, x_n) \end{bmatrix} . \]

Constructor & Destructor Documentation

◆ GramMatrix() [1/3]

template<class Derived>
lucid::GramMatrix::GramMatrix ( const Kernel & kernel,
const MatrixBase< Derived > & initial_states )
inline

Compute the Gram matrix from the kernel and the initial states.

The initial states should be an \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) matrix where \( \texttip{d}{Dimension of the vector space} \) is the dimension of the vector space \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \) and \( n \) is the number of states used to compute the Gram matrix, i.e.

\[\text{initial_states} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} . \]

with \( x_i \in \mathcal{X} \) for \( 1 \le i \le s \).

Parameters
kernelrkhs kernel used to compute the Gram matrix
initial_states\( N \) initial states used to compute the Gram matrix

◆ GramMatrix() [2/3]

template<class Derived>
lucid::GramMatrix::GramMatrix ( const Kernel & kernel,
const MatrixBase< Derived > & initial_states,
std::vector< Matrix > & gradient )
inline

Compute the Gram matrix from the kernel and the initial states.

The initial states should be an \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) matrix where \( \texttip{d}{Dimension of the vector space} \) is the dimension of the vector space \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \) and \( n \) is the number of states used to compute the Gram matrix, i.e.

\[\text{initial_states} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} . \]

with \( x_i \in \mathcal{X} \) for \( 1 \le i \le n \). Moreover, compute and store the gradient.

Parameters
kernelrkhs kernel used to compute the Gram matrix
initial_states\( N \) initial states used to compute the Gram matrix
[out]gradientgradient of the kernel with the current parameters

◆ GramMatrix() [3/3]

template<class Derived>
lucid::GramMatrix::GramMatrix ( const Kernel & kernel,
const MatrixBase< Derived > & initial_states,
std::vector< Matrix > *const gradient )
inline

Compute the Gram matrix from the kernel and the initial states.

The initial states should be an \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) matrix where \( \texttip{d}{Dimension of the vector space} \) is the dimension of the vector space \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \) and \( n \) is the number of states used to compute the Gram matrix, i.e.

\[\text{initial_states} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} . \]

with \( x_i \in \mathcal{X} \) for \( 1 \le i \le n \). Moreover, compute and store the gradient if it is not nullptr.

Parameters
kernelrkhs kernel used to compute the Gram matrix
initial_states\( N \) initial states used to compute the Gram matrix
[out]gradientgradient of the kernel with the current parameters If nullptr, the gradient will not be* computed

Member Function Documentation

◆ add_diagonal_term()

GramMatrix & lucid::GramMatrix::add_diagonal_term ( Scalar diagonal_term)

Add a diagonal term to the Gram matrix.

Useful when dealing with ill-conditioned matrices or regularization.

Parameters
diagonal_termterm to add to the diagonal
Returns
reference to the object

◆ cols()

Dimension lucid::GramMatrix::cols ( ) const
inlinenodiscard

Get read-only access to the number of columns of the Gramm matrix.

Returns
number of columns of the Gramm matrix

◆ compute_coefficients()

void lucid::GramMatrix::compute_coefficients ( const Matrix & transition_states)

Given the initial state \( x \in \mathcal{X} \), compute the coefficients \( \alpha \in \mathbb{R}^n \).

The coefficients will be stored to be used later to interpolate the transition function on an arbitrary state.

Parameters
transition_states\( n \) row vector states obtained after applying the transition function to each initial state

◆ gram_matrix()

const Matrix & lucid::GramMatrix::gram_matrix ( ) const
inlinenodiscard

Get read-only access to the internal matrix structure of the Gramm matrix.

Returns
internal matrix structure of the Gramm matrix

◆ inverse_mult()

template<class Derived>
Matrix lucid::GramMatrix::inverse_mult ( const MatrixBase< Derived > & A) const
inlinenodiscard

Right multiply the inverse of the Gram matrix with another matrix, \( K^{-1}A \).

Template Parameters
Derivedtype of the other matrix
Parameters
Amatrix to multiply with the Gram matrix
Returns
result of the multiplication

◆ operator*()

template<class Derived>
Matrix lucid::GramMatrix::operator* ( const MatrixBase< Derived > & A) const
inline

Right multiply the Gram matrix with another matrix, \( KA \).

Template Parameters
Derivedtype of the other matrix
Parameters
Amatrix to multiply with the Gram matrix
Returns
result of the multiplication

◆ rows()

Dimension lucid::GramMatrix::rows ( ) const
inlinenodiscard

Get read-only access to the number of rows of the Gramm matrix.

Returns
number of rows of the Gramm matrix

The documentation for this class was generated from the following files: