v2.0.0
Loading...
Searching...
No Matches
FIFFLIB::FiffSparseMatrix Class Reference

FIFF sparse matrix storage backed by Eigen. More...

#include <fiff_sparse_matrix.h>

Public Types

using SPtr = QSharedPointer<FiffSparseMatrix>
using ConstSPtr = QSharedPointer<const FiffSparseMatrix>
using UPtr = std::unique_ptr<FiffSparseMatrix>
using ConstUPtr = std::unique_ptr<const FiffSparseMatrix>

Public Member Functions

 FiffSparseMatrix ()
 FiffSparseMatrix (Eigen::SparseMatrix< float > &&mat, FIFFLIB::fiff_int_t coding=FIFFTS_MC_RCS)
 FiffSparseMatrix (const FiffSparseMatrix &mat)=default
 FiffSparseMatrix (FiffSparseMatrix &&mat)=default
FiffSparseMatrixoperator= (const FiffSparseMatrix &)=default
FiffSparseMatrixoperator= (FiffSparseMatrix &&)=default
 ~FiffSparseMatrix ()=default
Eigen::SparseMatrix< float > & eigen ()
const Eigen::SparseMatrix< float > & eigen () const
 operator const Eigen::SparseMatrix< float > & () const
int rows () const
int cols () const
int nonZeros () const
FiffSparseMatrix::UPtr mne_add_upper_triangle_rcs ()
FiffSparseMatrix::UPtr pickLowerTriangleRcs () const
bool is_empty () const
Eigen::SparseMatrix< double > toEigenSparse () const

Static Public Member Functions

static std::vector< int > fiff_get_matrix_sparse_dims (const FIFFLIB::FiffTag::UPtr &tag)
static FiffSparseMatrix::UPtr fiff_get_float_sparse_matrix (const FIFFLIB::FiffTag::UPtr &tag)
static FiffSparseMatrix::UPtr create_sparse_rcs (int nrow, int ncol, int *nnz, int **colindex, float **vals)
static FiffSparseMatrix fromEigenSparse (const Eigen::SparseMatrix< double > &mat)
static FiffSparseMatrix fromEigenSparse (const Eigen::SparseMatrix< float > &mat)

Public Attributes

FIFFLIB::fiff_int_t coding

Detailed Description

FIFF sparse matrix storage backed by Eigen.

FIFF sparse matrix — wraps Eigen::SparseMatrix<float>.

Internally stores data in a single Eigen::SparseMatrix<float>. The coding member records whether the FIFF source was CCS or RCS (used only during serialization / deserialization).

Definition at line 85 of file fiff_sparse_matrix.h.

Member Typedef Documentation

◆ ConstSPtr

Const shared pointer type for FiffSparseMatrix.

Definition at line 89 of file fiff_sparse_matrix.h.

◆ ConstUPtr

Const unique pointer type for FiffSparseMatrix.

Definition at line 91 of file fiff_sparse_matrix.h.

◆ SPtr

Shared pointer type for FiffSparseMatrix.

Definition at line 88 of file fiff_sparse_matrix.h.

◆ UPtr

Unique pointer type for FiffSparseMatrix.

Definition at line 90 of file fiff_sparse_matrix.h.

Constructor & Destructor Documentation

◆ FiffSparseMatrix() [1/4]

FiffSparseMatrix::FiffSparseMatrix ( )

Constructs an empty FiffSparseMatrix.

Definition at line 145 of file fiff_sparse_matrix.cpp.

◆ FiffSparseMatrix() [2/4]

FiffSparseMatrix::FiffSparseMatrix ( Eigen::SparseMatrix< float > && mat,
FIFFLIB::fiff_int_t coding = FIFFTS_MC_RCS )
explicit

Constructs a FiffSparseMatrix wrapping an existing Eigen sparse matrix.

Parameters
[in]matEigen sparse matrix to wrap (moved in).
[in]codingFIFF storage coding (FIFFTS_MC_RCS or FIFFTS_MC_CCS).

Definition at line 152 of file fiff_sparse_matrix.cpp.

◆ FiffSparseMatrix() [3/4]

FIFFLIB::FiffSparseMatrix::FiffSparseMatrix ( const FiffSparseMatrix & mat)
default

Default copy constructor.

◆ FiffSparseMatrix() [4/4]

FIFFLIB::FiffSparseMatrix::FiffSparseMatrix ( FiffSparseMatrix && mat)
default

Default move constructor.

◆ ~FiffSparseMatrix()

FIFFLIB::FiffSparseMatrix::~FiffSparseMatrix ( )
default

Default destructor.

Member Function Documentation

◆ cols()

int FIFFLIB::FiffSparseMatrix::cols ( ) const
inline

Number of columns.

Definition at line 166 of file fiff_sparse_matrix.h.

◆ create_sparse_rcs()

FiffSparseMatrix::UPtr FiffSparseMatrix::create_sparse_rcs ( int nrow,
int ncol,
int * nnz,
int ** colindex,
float ** vals )
static

Create a sparse RCS matrix from row-based data.

Parameters
[in]nrowNumber of rows.
[in]ncolNumber of columns.
[in]nnzNumber of non-zero elements on each row.
[in]colindexColumn indices of non-zero elements on each row.
[in]valsValues of non-zero elements on each row.
Returns
A unique pointer to the newly constructed FiffSparseMatrix, or nullptr on error.

Definition at line 244 of file fiff_sparse_matrix.cpp.

◆ eigen() [1/2]

Eigen::SparseMatrix< float > & FIFFLIB::FiffSparseMatrix::eigen ( )
inline

Mutable access to the underlying Eigen sparse matrix.

Returns
Reference to the internal Eigen::SparseMatrix<float>.

Definition at line 145 of file fiff_sparse_matrix.h.

◆ eigen() [2/2]

const Eigen::SparseMatrix< float > & FIFFLIB::FiffSparseMatrix::eigen ( ) const
inline

Const access to the underlying Eigen sparse matrix.

Returns
Const reference to the internal Eigen::SparseMatrix<float>.

Definition at line 151 of file fiff_sparse_matrix.h.

◆ fiff_get_float_sparse_matrix()

FiffSparseMatrix::UPtr FiffSparseMatrix::fiff_get_float_sparse_matrix ( const FIFFLIB::FiffTag::UPtr & tag)
static

Conversion of tag data into the standard sparse representation.

Parameters
[in]tagThe tag containing sparse matrix data.
Returns
A unique pointer to the newly constructed FiffSparseMatrix, or nullptr on error.

Definition at line 168 of file fiff_sparse_matrix.cpp.

◆ fiff_get_matrix_sparse_dims()

std::vector< int > FiffSparseMatrix::fiff_get_matrix_sparse_dims ( const FIFFLIB::FiffTag::UPtr & tag)
static

Interpret dimensions and nz from matrix data.

Parameters
[in]tagThe tag containing sparse matrix data.
Returns
A vector with the matrix dimension info, or empty on error.

Definition at line 161 of file fiff_sparse_matrix.cpp.

◆ fromEigenSparse() [1/2]

FiffSparseMatrix FiffSparseMatrix::fromEigenSparse ( const Eigen::SparseMatrix< double > & mat)
static

Create a FiffSparseMatrix from an Eigen::SparseMatrix<double>. The data is cast to float for internal storage.

Parameters
[in]matThe Eigen sparse matrix to convert.
Returns
The equivalent FiffSparseMatrix.

Definition at line 313 of file fiff_sparse_matrix.cpp.

◆ fromEigenSparse() [2/2]

FiffSparseMatrix FiffSparseMatrix::fromEigenSparse ( const Eigen::SparseMatrix< float > & mat)
static

Create a FiffSparseMatrix from an Eigen::SparseMatrix<float>.

Parameters
[in]matThe Eigen sparse matrix to wrap.
Returns
The equivalent FiffSparseMatrix.

Definition at line 327 of file fiff_sparse_matrix.cpp.

◆ is_empty()

bool FIFFLIB::FiffSparseMatrix::is_empty ( ) const
inline

Check whether this sparse matrix is empty (no non-zero elements).

Returns
true if the matrix has no data.

Definition at line 270 of file fiff_sparse_matrix.h.

◆ mne_add_upper_triangle_rcs()

FiffSparseMatrix::UPtr FiffSparseMatrix::mne_add_upper_triangle_rcs ( )

Add the upper triangle to a lower-triangular sparse RCS matrix.

Returns
A unique pointer to the newly constructed FiffSparseMatrix with both triangles.

Definition at line 281 of file fiff_sparse_matrix.cpp.

◆ nonZeros()

int FIFFLIB::FiffSparseMatrix::nonZeros ( ) const
inline

Number of stored non-zero elements.

Definition at line 171 of file fiff_sparse_matrix.h.

◆ operator const Eigen::SparseMatrix< float > &()

FIFFLIB::FiffSparseMatrix::operator const Eigen::SparseMatrix< float > & ( ) const
inline

Implicit conversion to const Eigen::SparseMatrix<float>&.

Definition at line 156 of file fiff_sparse_matrix.h.

◆ operator=() [1/2]

FiffSparseMatrix & FIFFLIB::FiffSparseMatrix::operator= ( const FiffSparseMatrix & )
default

Default copy-assignment operator.

◆ operator=() [2/2]

FiffSparseMatrix & FIFFLIB::FiffSparseMatrix::operator= ( FiffSparseMatrix && )
default

Default move-assignment operator.

◆ pickLowerTriangleRcs()

FiffSparseMatrix::UPtr FiffSparseMatrix::pickLowerTriangleRcs ( ) const

Extract only the lower triangle (including diagonal) from a square RCS matrix.

Returns
A unique pointer to the newly constructed FiffSparseMatrix with lower-triangle elements.

Definition at line 341 of file fiff_sparse_matrix.cpp.

◆ rows()

int FIFFLIB::FiffSparseMatrix::rows ( ) const
inline

Number of rows.

Definition at line 161 of file fiff_sparse_matrix.h.

◆ toEigenSparse()

Eigen::SparseMatrix< double > FIFFLIB::FiffSparseMatrix::toEigenSparse ( ) const
inline

Convert to Eigen::SparseMatrix<double> (cast from float).

Returns
A double-precision copy of the internal sparse matrix.

Definition at line 275 of file fiff_sparse_matrix.h.

Member Data Documentation

◆ coding

FIFFLIB::fiff_int_t FIFFLIB::FiffSparseMatrix::coding

FIFF coding type (FIFFTS_MC_RCS or FIFFTS_MC_CCS). Used for serialization only.

Definition at line 260 of file fiff_sparse_matrix.h.


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