ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
ADOLC::Sparse::SparseMatrix Class Reference

Owning sparse matrix container in coordinate-format. More...

#include <sparsematrix.h>

Public Types

using value_type = CoordinateFormatTripled
 
using storage_type = std::vector< value_type >
 

Public Member Functions

 ~SparseMatrix ()=default
 
 SparseMatrix ()=default
 Construct an empty sparse matrix.
 
 SparseMatrix (storage_type &&entries) noexcept
 Construct from already prepared coordinate-format entries.
 
template<size_t N>
 SparseMatrix (const std::array< CoordinateFormatTripled, N > &entries) noexcept
 Construct from an already prepared array of coordinate-format entries.
 
 SparseMatrix (size_t size)
 Construct a sparse matrix with storage for size entries.
 
 SparseMatrix (const SparseMatrix &other)=default
 
SparseMatrix & operator= (const SparseMatrix &other)=default
 
 SparseMatrix (SparseMatrix &&other) noexcept=default
 
SparseMatrix & operator= (SparseMatrix &&other) noexcept=default
 
storage_type & entries ()
 Get mutable access to the underlying entry storage.
 
const storage_type & entries () const
 Get read-only access to the underlying entry storage.
 
size_t size () const
 Get the number of stored nonzeros.
 
bool empty () const
 Check whether no entries are stored.
 
void resize (size_t size)
 Resize the number of stored entries.
 
void clear ()
 Remove all entries while keeping vector ownership.
 
void push_back (CoordinateFormatTripled value)
 Append one entry at the end of the sparse matrix.
 
unsigned int rowIndex (size_t idx) const
 Get the row index of one stored entry.
 
unsigned int colIndex (size_t idx) const
 Get the column index of one stored entry.
 
double value (size_t idx) const
 Get the numerical value of one stored entry.
 
value_type & operator[] (size_t idx)
 Mutable indexed access to one sparse entry.
 
const value_type & operator[] (size_t idx) const
 Read-only indexed access to one sparse entry.
 

Detailed Description

Owning sparse matrix container in coordinate-format.

SparseMatrix stores the recovered nonzeros of a sparse matrix as a contiguous array of CoordinateFormatTripled entries. The C++ sparse drivers use this representation directly, while the legacy C drivers adapt it back to separate rind, cind, and values arrays.

Member Typedef Documentation

◆ storage_type

◆ value_type

Constructor & Destructor Documentation

◆ ~SparseMatrix()

ADOLC::Sparse::SparseMatrix::~SparseMatrix ( )
default

◆ SparseMatrix() [1/6]

ADOLC::Sparse::SparseMatrix::SparseMatrix ( )
default

Construct an empty sparse matrix.

◆ SparseMatrix() [2/6]

ADOLC::Sparse::SparseMatrix::SparseMatrix ( storage_type &&  entries)
inlineexplicitnoexcept

Construct from already prepared coordinate-format entries.

Ownership of the entry vector is transferred into the sparse matrix.

Parameters
entriesCoordinate-format entries.

◆ SparseMatrix() [3/6]

template<size_t N>
ADOLC::Sparse::SparseMatrix::SparseMatrix ( const std::array< CoordinateFormatTripled, N > &  entries)
inlineexplicitnoexcept

Construct from an already prepared array of coordinate-format entries.

The entries of the array are copied.

Parameters
entriesArray of size N with coordinate-format entries.

◆ SparseMatrix() [4/6]

ADOLC::Sparse::SparseMatrix::SparseMatrix ( size_t  size)
inlineexplicit

Construct a sparse matrix with storage for size entries.

Entries are value-initialized and may later be overwritten through operator[].

Parameters
sizeNumber of coordinate-format entries to allocate.

◆ SparseMatrix() [5/6]

ADOLC::Sparse::SparseMatrix::SparseMatrix ( const SparseMatrix &  other)
default

◆ SparseMatrix() [6/6]

ADOLC::Sparse::SparseMatrix::SparseMatrix ( SparseMatrix &&  other)
defaultnoexcept

Member Function Documentation

◆ clear()

void ADOLC::Sparse::SparseMatrix::clear ( )
inline

Remove all entries while keeping vector ownership.

◆ colIndex()

unsigned int ADOLC::Sparse::SparseMatrix::colIndex ( size_t  idx) const
inline

Get the column index of one stored entry.

Parameters
idxEntry position.

◆ empty()

bool ADOLC::Sparse::SparseMatrix::empty ( ) const
inline

Check whether no entries are stored.

◆ entries() [1/2]

storage_type & ADOLC::Sparse::SparseMatrix::entries ( )
inline

Get mutable access to the underlying entry storage.

◆ entries() [2/2]

const storage_type & ADOLC::Sparse::SparseMatrix::entries ( ) const
inline

Get read-only access to the underlying entry storage.

◆ operator=() [1/2]

SparseMatrix & ADOLC::Sparse::SparseMatrix::operator= ( const SparseMatrix &  other)
default

◆ operator=() [2/2]

SparseMatrix & ADOLC::Sparse::SparseMatrix::operator= ( SparseMatrix &&  other)
defaultnoexcept

◆ operator[]() [1/2]

value_type & ADOLC::Sparse::SparseMatrix::operator[] ( size_t  idx)
inline

Mutable indexed access to one sparse entry.

Parameters
idxEntry position.

◆ operator[]() [2/2]

const value_type & ADOLC::Sparse::SparseMatrix::operator[] ( size_t  idx) const
inline

Read-only indexed access to one sparse entry.

Parameters
idxEntry position.

◆ push_back()

void ADOLC::Sparse::SparseMatrix::push_back ( CoordinateFormatTripled  value)
inline

Append one entry at the end of the sparse matrix.

Parameters
valueEntry to append.

◆ resize()

void ADOLC::Sparse::SparseMatrix::resize ( size_t  size)
inline

Resize the number of stored entries.

Parameters
sizeNew number of coordinate-format entries.

◆ rowIndex()

unsigned int ADOLC::Sparse::SparseMatrix::rowIndex ( size_t  idx) const
inline

Get the row index of one stored entry.

Parameters
idxEntry position.

◆ size()

size_t ADOLC::Sparse::SparseMatrix::size ( ) const
inline

Get the number of stored nonzeros.

◆ value()

double ADOLC::Sparse::SparseMatrix::value ( size_t  idx) const
inline

Get the numerical value of one stored entry.

Parameters
idxEntry position.

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