low_rank_toolbox.krylov.spaces.space_structure

Base class for space structures.

Author: Benjamin Carrel, University of Geneva, 2022-2023

Classes

SpaceStructure(A, X, **extra_args)

Space structure.

class low_rank_toolbox.krylov.spaces.space_structure.SpaceStructure(A, X, **extra_args)[source]

Bases: object

Space structure.

General space structure class. This class is meant to be inherited by other classes that define specific space structures, like Krylov spaces, rational Krylov spaces, etc.

In particular, this class defines the following attributes: - A: the matrix A (typically from a linear system A Y = X). - X: the vector or matrix that defines the basis of the space. - size: the size of the space. - basis: the basis of the space. - extra_args: a dictionary that contains extra arguments that can be passed to the class.

Parameters:
  • A (spmatrix)

  • X (ndarray)

property Ak: ndarray

Shortcut for the reduced matrix A.

Returns:

The reduced matrix (same as reduced_A).

Return type:

ndarray

property Am: ndarray

Shortcut for the reduced matrix A.

Returns:

The reduced matrix (same as reduced_A).

Return type:

ndarray

__init__(A, X, **extra_args)[source]
Parameters:
  • A (spmatrix) – The matrix A of the linear system.

  • X (ndarray) – The basis of the space.

  • extra_args (dict) – A dictionary that contains extra arguments that can be passed to the class.

Return type:

None

augment_basis()[source]

Augment the space with a new basis vector.

This method should be overloaded in child classes to add the next basis vector to the space.

property basis: ndarray

The basis of the space.

This property should be overloaded in child classes.

Returns:

The basis matrix of shape (n, size).

Return type:

ndarray

classmethod check_inputs(A, X)[source]

Validate input parameters.

Parameters:
  • A (spmatrix) – The matrix to validate

  • X (ndarray) – The vector/matrix to validate

Raises:
  • TypeError – If A is not a sparse matrix or X is not a numpy array

  • ValueError – If A is not square, dimensions don’t match, or data contains NaN/Inf

compute_all()[source]

Compute all the basis vectors.

Repeatedly calls augment_basis until max_iter iterations are reached.

property reduced_A: ndarray

The reduced matrix A.

Computes Q^T A Q where Q is the basis of the space.

Returns:

The reduced matrix of shape (size, size).

Return type:

ndarray

property size: int

The size of the space.

This property should be overloaded in child classes.

Returns:

The size of the space.

Return type:

int