Turi Create  4.0
spmat Class Reference

#include <toolkits/util/spmat.hpp>

Public Member Functions

 spmat (size_t num_rows=0)
 
const std::map< size_t, size_t > & get_row (size_t i)
 
size_t get (const size_t i, const size_t j)
 
size_t num_rows () const
 
void trim (const size_t i)
 
void increment (const size_t &a, const size_t &b, const size_t &v)
 
Eigen::MatrixXi as_matrix ()
 

Detailed Description

A simple utility class for representing sparse matrices of counts. It exposes getting particular elements, incrementing elements by a value, and removing zero elements from the internal data structure. It is row-based, so only exposes get_row and num_rows.

Definition at line 22 of file spmat.hpp.

Constructor & Destructor Documentation

◆ spmat()

spmat::spmat ( size_t  num_rows = 0)
inline

Create a sparse matrix with a fixed number of rows.

Definition at line 28 of file spmat.hpp.

Member Function Documentation

◆ as_matrix()

Eigen::MatrixXi spmat::as_matrix ( )
inline

Convert to Eigen matrix.

Definition at line 84 of file spmat.hpp.

◆ get()

size_t spmat::get ( const size_t  i,
const size_t  j 
)
inline

Get the count at element(i,j).

Definition at line 42 of file spmat.hpp.

◆ get_row()

const std::map<size_t, size_t>& spmat::get_row ( size_t  i)
inline

Get a vector of nonzero elements in a single row.

Definition at line 35 of file spmat.hpp.

◆ increment()

void spmat::increment ( const size_t &  a,
const size_t &  b,
const size_t &  v 
)
inline

Increment the element (a, b) by v.

Definition at line 72 of file spmat.hpp.

◆ num_rows()

size_t spmat::num_rows ( ) const
inline

Get the number of rows.

Definition at line 53 of file spmat.hpp.

◆ trim()

void spmat::trim ( const size_t  i)
inline

Delete zeros in a single row

Definition at line 58 of file spmat.hpp.


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