Public Types | Public Member Functions | Private Attributes | List of all members
vnl_crs_index Class Reference

Represents the configuration of a sparse matrix but not the data. More...

#include <vnl_crs_index.h>

Public Types

typedef std::pair< int, int > idx_pair
 
typedef std::vector< idx_pairsparse_vector
 

Public Member Functions

 vnl_crs_index ()
 Constructor - default. More...
 
 vnl_crs_index (const std::vector< std::vector< bool > > &mask)
 Constructor - from a binary mask. More...
 
 ~vnl_crs_index ()=default
 Destructor. More...
 
int num_rows () const
 number of rows in the sparse matrix. More...
 
int num_cols () const
 number of columns in the sparse matrix. More...
 
int num_non_zero () const
 number of non-zero elements. More...
 
sparse_vector sparse_row (int i) const
 returns row i as a vector of index-column pairs. More...
 
sparse_vector sparse_col (int j) const
 returns column j as a vector of index-row pairs. More...
 
int operator() (int i, int j) const
 return the index at location (i,j). More...
 

Private Attributes

unsigned int num_cols_
 The number of columns in the matrix. More...
 
std::vector< int > col_idx_
 The column for each non-zero element. More...
 
std::vector< int > row_ptr_
 The index of the first non-zero element in each row. More...
 

Detailed Description

Represents the configuration of a sparse matrix but not the data.

This is essentially a sparse matrix of indices into a data vector Compressed row storage is used for representation This class is useful when working with several sparse matrices that share a common sparse structure.

Definition at line 26 of file vnl_crs_index.h.

Member Typedef Documentation

◆ idx_pair

typedef std::pair<int,int> vnl_crs_index::idx_pair

Definition at line 29 of file vnl_crs_index.h.

◆ sparse_vector

typedef std::vector<idx_pair> vnl_crs_index::sparse_vector

Definition at line 30 of file vnl_crs_index.h.

Constructor & Destructor Documentation

◆ vnl_crs_index() [1/2]

vnl_crs_index::vnl_crs_index ( )
inline

Constructor - default.

Definition at line 33 of file vnl_crs_index.h.

◆ vnl_crs_index() [2/2]

vnl_crs_index::vnl_crs_index ( const std::vector< std::vector< bool > > &  mask)

Constructor - from a binary mask.

Definition at line 10 of file vnl_crs_index.cxx.

◆ ~vnl_crs_index()

vnl_crs_index::~vnl_crs_index ( )
default

Destructor.

Member Function Documentation

◆ num_cols()

int vnl_crs_index::num_cols ( ) const
inline

number of columns in the sparse matrix.

Definition at line 45 of file vnl_crs_index.h.

◆ num_non_zero()

int vnl_crs_index::num_non_zero ( ) const
inline

number of non-zero elements.

Definition at line 48 of file vnl_crs_index.h.

◆ num_rows()

int vnl_crs_index::num_rows ( ) const
inline

number of rows in the sparse matrix.

Definition at line 42 of file vnl_crs_index.h.

◆ operator()()

int vnl_crs_index::operator() ( int  i,
int  j 
) const

return the index at location (i,j).

returns -1 if the entry is 0

Definition at line 31 of file vnl_crs_index.cxx.

◆ sparse_col()

vnl_crs_index::sparse_vector vnl_crs_index::sparse_col ( int  j) const

returns column j as a vector of index-row pairs.

Note
because of CRS this method is a bit less efficient than sparse_row

Definition at line 69 of file vnl_crs_index.cxx.

◆ sparse_row()

vnl_crs_index::sparse_vector vnl_crs_index::sparse_row ( int  i) const

returns row i as a vector of index-column pairs.

Definition at line 56 of file vnl_crs_index.cxx.

Member Data Documentation

◆ col_idx_

std::vector<int> vnl_crs_index::col_idx_
private

The column for each non-zero element.

Definition at line 65 of file vnl_crs_index.h.

◆ num_cols_

unsigned int vnl_crs_index::num_cols_
private

The number of columns in the matrix.

Definition at line 63 of file vnl_crs_index.h.

◆ row_ptr_

std::vector<int> vnl_crs_index::row_ptr_
private

The index of the first non-zero element in each row.

Definition at line 67 of file vnl_crs_index.h.


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