OpenVDB 10.0.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
SparseStencilMatrix< ValueType_, STENCIL_SIZE > Class Template Reference

Sparse, square matrix representing a 3D stencil operator of size STENCIL_SIZE. More...

#include <openvdb/math/ConjGradient.h>

Classes

class  ConstRow
 Read-only accessor to a row of this matrix. More...
 
class  ConstValueIter
 Iterator over the stored values in a row of this matrix. More...
 
struct  IsFiniteOp
 
struct  MatrixCopyOp
 
class  RowEditor
 Read/write accessor to a row of this matrix. More...
 

Public Types

using ValueType = ValueType_
 
using VectorType = Vector< ValueType >
 
using Ptr = SharedPtr< SparseStencilMatrix >
 

Public Member Functions

 SparseStencilMatrix (SizeType n)
 Construct an n x n matrix with at most STENCIL_SIZE nonzero elements per row.
 
 SparseStencilMatrix (const SparseStencilMatrix &)
 Deep copy the given matrix.
 
SizeType numRows () const
 Return the number of rows in this matrix.
 
SizeType size () const
 
void setValue (SizeType row, SizeType col, const ValueType &)
 Set the value at the given coordinates.
 
const ValueTypegetValue (SizeType row, SizeType col) const
 Return the value at the given coordinates.
 
const ValueTypeoperator() (SizeType row, SizeType col) const
 
ConstRow getConstRow (SizeType row) const
 Return a read-only view onto the given row of this matrix.
 
RowEditor getRowEditor (SizeType row)
 Return a read/write view onto the given row of this matrix.
 
template<typename Scalar >
void scale (const Scalar &s)
 Multiply all elements in the matrix by s;.
 
template<typename Scalar >
SparseStencilMatrixoperator*= (const Scalar &s)
 
template<typename VecValueType >
void vectorMultiply (const Vector< VecValueType > &inVec, Vector< VecValueType > &resultVec) const
 Multiply this matrix by inVec and return the result in resultVec.
 
template<typename VecValueType >
void vectorMultiply (const VecValueType *inVec, VecValueType *resultVec) const
 Multiply this matrix by the vector represented by the array inVec and return the result in resultVec.
 
template<typename OtherValueType >
bool eq (const SparseStencilMatrix< OtherValueType, STENCIL_SIZE > &other, ValueType eps=Tolerance< ValueType >::value()) const
 Return true if this matrix is equivalent to the given matrix to within the specified tolerance.
 
bool isFinite () const
 Return true if every element of this matrix has a finite value.
 
std::string str () const
 Return a string representation of this matrix.
 

Static Public Attributes

static const ValueType sZeroValue = zeroVal<ValueType>()
 

Detailed Description

template<typename ValueType_, SizeType STENCIL_SIZE>
class openvdb::v10_0::math::pcg::SparseStencilMatrix< ValueType_, STENCIL_SIZE >

Sparse, square matrix representing a 3D stencil operator of size STENCIL_SIZE.

The implementation is a variation on compressed row storage (CRS).

Member Typedef Documentation

◆ Ptr

template<typename ValueType_ , SizeType STENCIL_SIZE>
using Ptr = SharedPtr<SparseStencilMatrix>

◆ ValueType

template<typename ValueType_ , SizeType STENCIL_SIZE>
using ValueType = ValueType_

◆ VectorType

template<typename ValueType_ , SizeType STENCIL_SIZE>
using VectorType = Vector<ValueType>

Constructor & Destructor Documentation

◆ SparseStencilMatrix() [1/2]

template<typename ValueType , SizeType STENCIL_SIZE>
SparseStencilMatrix ( SizeType  n)
inline

Construct an n x n matrix with at most STENCIL_SIZE nonzero elements per row.

◆ SparseStencilMatrix() [2/2]

template<typename ValueType , SizeType STENCIL_SIZE>
SparseStencilMatrix ( const SparseStencilMatrix< ValueType_, STENCIL_SIZE > &  other)
inline

Deep copy the given matrix.

Member Function Documentation

◆ eq()

template<typename ValueType , SizeType STENCIL_SIZE>
template<typename OtherValueType >
bool eq ( const SparseStencilMatrix< OtherValueType, STENCIL_SIZE > &  other,
ValueType  eps = Tolerance<ValueType>::value() 
) const
inline

Return true if this matrix is equivalent to the given matrix to within the specified tolerance.

◆ getConstRow()

template<typename ValueType , SizeType STENCIL_SIZE>
SparseStencilMatrix< ValueType, STENCIL_SIZE >::ConstRow getConstRow ( SizeType  row) const
inline

Return a read-only view onto the given row of this matrix.

◆ getRowEditor()

template<typename ValueType , SizeType STENCIL_SIZE>
SparseStencilMatrix< ValueType, STENCIL_SIZE >::RowEditor getRowEditor ( SizeType  row)
inline

Return a read/write view onto the given row of this matrix.

◆ getValue()

template<typename ValueType , SizeType STENCIL_SIZE>
const ValueType & getValue ( SizeType  row,
SizeType  col 
) const
inline

Return the value at the given coordinates.

Warning
It is not safe to get values from a row while another thread is setting values in that row.

◆ isFinite()

template<typename ValueType , SizeType STENCIL_SIZE>
bool isFinite ( ) const
inline

Return true if every element of this matrix has a finite value.

◆ numRows()

template<typename ValueType_ , SizeType STENCIL_SIZE>
SizeType numRows ( ) const
inline

Return the number of rows in this matrix.

◆ operator()()

template<typename ValueType , SizeType STENCIL_SIZE>
const ValueType & operator() ( SizeType  row,
SizeType  col 
) const
inline

◆ operator*=()

template<typename ValueType_ , SizeType STENCIL_SIZE>
template<typename Scalar >
SparseStencilMatrix & operator*= ( const Scalar &  s)
inline

◆ scale()

template<typename ValueType , SizeType STENCIL_SIZE>
template<typename Scalar >
void scale ( const Scalar &  s)
inline

Multiply all elements in the matrix by s;.

◆ setValue()

template<typename ValueType , SizeType STENCIL_SIZE>
void setValue ( SizeType  row,
SizeType  col,
const ValueType val 
)
inline

Set the value at the given coordinates.

Warning
It is not safe to set values in the same row simultaneously from multiple threads.

◆ size()

template<typename ValueType_ , SizeType STENCIL_SIZE>
SizeType size ( ) const
inline

◆ str()

template<typename ValueType , SizeType STENCIL_SIZE>
std::string str ( ) const
inline

Return a string representation of this matrix.

◆ vectorMultiply() [1/2]

template<typename ValueType , SizeType STENCIL_SIZE>
template<typename VecValueType >
void vectorMultiply ( const Vector< VecValueType > &  inVec,
Vector< VecValueType > &  resultVec 
) const
inline

Multiply this matrix by inVec and return the result in resultVec.

Exceptions
ArithmeticErrorif either inVec or resultVec is not of size N, where N x N is the size of this matrix.

◆ vectorMultiply() [2/2]

template<typename ValueType , SizeType STENCIL_SIZE>
template<typename VecValueType >
void vectorMultiply ( const VecValueType *  inVec,
VecValueType *  resultVec 
) const
inline

Multiply this matrix by the vector represented by the array inVec and return the result in resultVec.

Warning
Both inVec and resultVec must have at least N elements, where N x N is the size of this matrix.

Member Data Documentation

◆ sZeroValue

template<typename ValueType , SizeType STENCIL_SIZE>
const ValueType sZeroValue = zeroVal<ValueType>()
static