PSCF v1.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Util::RaggedMatrix< Data > Class Template Reference

A 2D array in which different rows can have different lengths. More...

#include <RaggedMatrix.h>

Inheritance diagram for Util::RaggedMatrix< Data >:
Util::DRaggedMatrix< Data >

Public Member Functions

virtual ~RaggedMatrix ()
 Destructor. More...
 
int capacity1 ()
 Get number of rows. More...
 
int capacity2 (int i)
 Get number of elements in row number i. More...
 
Data const & operator() (int i, int j) const
 Return element (i,j) of matrix by const reference. More...
 
Data & operator() (int i, int j)
 Return element (i,j) of matrix by reference. More...
 

Protected Member Functions

 RaggedMatrix ()
 Default constructor. More...
 

Protected Attributes

Data * data_
 One-dimensional C array of all elements. More...
 
Data ** rows_
 Array of pointers to rows. More...
 
int * capacity2_
 Array containing number of elements in each row. More...
 
int capacity1_
 Number of rows (range of first index). More...
 
int capacity_
 Total number of elements. More...
 

Detailed Description

template<typename Data>
class Util::RaggedMatrix< Data >

A 2D array in which different rows can have different lengths.

A RaggedMatrix object A is a two-dimensional array in which the operator A(i,j) returns a reference to element j of row i, and in which different rows have different lengths. Class RaggedMatrix cannot be instantiated, and functions like an abstract base class.

The memory for a RaggedMatrix is stored in a one-dimensional C array.

Definition at line 29 of file RaggedMatrix.h.

Constructor & Destructor Documentation

◆ ~RaggedMatrix()

template<typename Data >
Util::RaggedMatrix< Data >::~RaggedMatrix
virtual

Destructor.

Definition at line 129 of file RaggedMatrix.h.

◆ RaggedMatrix()

template<typename Data >
Util::RaggedMatrix< Data >::RaggedMatrix
inlineprotected

Default constructor.

Constructor (protected).

Protected to prevent direct instantiation.

Definition at line 117 of file RaggedMatrix.h.

Member Function Documentation

◆ capacity1()

template<typename Data >
int Util::RaggedMatrix< Data >::capacity1
inline

Get number of rows.

Returns
Number of rows (i.e., range of first array index)

Definition at line 136 of file RaggedMatrix.h.

◆ capacity2()

template<typename Data >
int Util::RaggedMatrix< Data >::capacity2 ( int  i)
inline

Get number of elements in row number i.

Parameters
irow index
Returns
Number of elements in row i.

Definition at line 143 of file RaggedMatrix.h.

◆ operator()() [1/2]

template<typename Data >
Data const & Util::RaggedMatrix< Data >::operator() ( int  i,
int  j 
) const
inline

Return element (i,j) of matrix by const reference.

Parameters
irow index.
jcolumn index.
Returns
element (i, j)

Definition at line 151 of file RaggedMatrix.h.

◆ operator()() [2/2]

template<typename Data >
Data & Util::RaggedMatrix< Data >::operator() ( int  i,
int  j 
)
inline

Return element (i,j) of matrix by reference.

Parameters
irow index.
jcolumn index.
Returns
element (i, j)

Definition at line 165 of file RaggedMatrix.h.

Member Data Documentation

◆ data_

template<typename Data >
Data* Util::RaggedMatrix< Data >::data_
protected

One-dimensional C array of all elements.

Definition at line 79 of file RaggedMatrix.h.

◆ rows_

template<typename Data >
Data** Util::RaggedMatrix< Data >::rows_
protected

Array of pointers to rows.

Definition at line 82 of file RaggedMatrix.h.

◆ capacity2_

template<typename Data >
int* Util::RaggedMatrix< Data >::capacity2_
protected

Array containing number of elements in each row.

Definition at line 85 of file RaggedMatrix.h.

◆ capacity1_

template<typename Data >
int Util::RaggedMatrix< Data >::capacity1_
protected

Number of rows (range of first index).

Definition at line 88 of file RaggedMatrix.h.

◆ capacity_

template<typename Data >
int Util::RaggedMatrix< Data >::capacity_
protected

Total number of elements.

Definition at line 91 of file RaggedMatrix.h.


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