guanaqo 1.0.0-alpha.27
Utilities for scientific software
Loading...
Searching...
No Matches
Sparse matrices

Detailed Description

Sparse matrix data structures.

Guanaqo supports the following (sparse) matrix formats:

  • Dense: A plain dense matrix.
  • SparseCSC: Compressed Sparse Column format.
  • SparseCOO: Coordinate list format. Different index types are supported, and indices can be zero-based or one-based. For sparse formats, we also keep track of whether the indices are sorted or not.

The guanaqo::linalg::sparsity::Sparsity class is a type-erased wrapper around these various formats. Conversions between formats are supported by the guanaqo::linalg::sparsity::SparsityConverter<Sparsity,To> class (see Sparsity Conversions). The desired index options (zero/one-based, sorted/unsorted) can be specified using the guanaqo::linalg::sparsity::SparsityConversionRequest struct. While the conversions convert only the sparsity structure by default, they remember the original structure, and can be used to repeatedly convert the values as well. This is useful in optimization solvers, for example, where the sparsity structures of the Hessians and Jacobians are fixed, but the values change at each iteration.

Collaboration diagram for Sparse matrices:

Topics

 Sparsity Conversions
 Sparse matrix conversions.
 Sparsity Utilities
 Sparse matrix utilities for sorting indices, checking uniqueness, etc.

Files

file  sparsity.hpp
 Sparse and dense sparsity descriptors.

Classes

struct  guanaqo::linalg::sparsity::Dense
 Dense matrix structure. More...
struct  guanaqo::linalg::sparsity::SparseCSC< Index, StorageIndex >
 Sparse compressed-column structure (CCS or CSC). More...
struct  guanaqo::linalg::sparsity::SparseCOO< Index >
 Sparse coordinate list structure (COO). More...
struct  guanaqo::linalg::sparsity::Sparsity
 Stores any of the supported sparsity patterns. More...

Typedefs

using guanaqo::linalg::sparsity::SparsityVariant
 Helper for Sparsity.

Enumerations

enum class  guanaqo::linalg::sparsity::Symmetry : uint8_t { guanaqo::linalg::sparsity::Symmetry::Unsymmetric = 0 , guanaqo::linalg::sparsity::Symmetry::Upper = 1 , guanaqo::linalg::sparsity::Symmetry::Lower = 2 }
 Describes the symmetry of matrices. More...

Functions

const char * guanaqo::linalg::sparsity::enum_name (Symmetry s)
bool guanaqo::linalg::sparsity::is_dense (const Sparsity &sp)
 Returns true if the sparsity pattern represents a dense matrix.
length_t guanaqo::linalg::sparsity::get_nnz (const Sparsity &sp)
 Get the number of structurally nonzero elements.
Symmetry guanaqo::linalg::sparsity::get_symmetry (const Sparsity &sp)
 Returns the symmetry of the sparsity pattern.
length_t guanaqo::linalg::sparsity::num_rows (const Sparsity &sp)
 Returns the number of rows of the sparsity pattern.
length_t guanaqo::linalg::sparsity::num_cols (const Sparsity &sp)
 Returns the number of rows of the sparsity pattern.

Class Documentation

◆ guanaqo::linalg::sparsity::Dense

struct guanaqo::linalg::sparsity::Dense
Collaboration diagram for guanaqo::linalg::sparsity::Dense:
Class Members
length_t rows = 0
length_t cols = 0
Symmetry symmetry = Symmetry::Unsymmetric

Typedef Documentation

◆ SparsityVariant

Enumeration Type Documentation

◆ Symmetry

enum class guanaqo::linalg::sparsity::Symmetry : uint8_t
strong

#include <guanaqo/linalg/sparsity.hpp>

Describes the symmetry of matrices.

Enumerator
Unsymmetric 

No symmetry.

Upper 

Symmetric, upper-triangular part is stored.

Lower 

Symmetric, lower-triangular part is stored.

Definition at line 20 of file sparsity.hpp.

Function Documentation

◆ enum_name()

const char * guanaqo::linalg::sparsity::enum_name ( Symmetry s)
inline

#include <guanaqo/linalg/sparsity.hpp>

Definition at line 26 of file sparsity.hpp.

◆ is_dense()

bool guanaqo::linalg::sparsity::is_dense ( const Sparsity & sp)
inline

#include <guanaqo/linalg/sparsity.hpp>

Returns true if the sparsity pattern represents a dense matrix.

Definition at line 139 of file sparsity.hpp.

◆ get_nnz()

length_t guanaqo::linalg::sparsity::get_nnz ( const Sparsity & sp)
inline

#include <guanaqo/linalg/sparsity.hpp>

Get the number of structurally nonzero elements.

Definition at line 148 of file sparsity.hpp.

◆ get_symmetry()

Symmetry guanaqo::linalg::sparsity::get_symmetry ( const Sparsity & sp)
inline

#include <guanaqo/linalg/sparsity.hpp>

Returns the symmetry of the sparsity pattern.

Definition at line 157 of file sparsity.hpp.

◆ num_rows()

length_t guanaqo::linalg::sparsity::num_rows ( const Sparsity & sp)
inline

#include <guanaqo/linalg/sparsity.hpp>

Returns the number of rows of the sparsity pattern.

Definition at line 162 of file sparsity.hpp.

◆ num_cols()

length_t guanaqo::linalg::sparsity::num_cols ( const Sparsity & sp)
inline

#include <guanaqo/linalg/sparsity.hpp>

Returns the number of rows of the sparsity pattern.

Definition at line 167 of file sparsity.hpp.