SOFA API  1c8b807d
Open source framework for multi-physics simuation
sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType > Class Template Reference

#include <SparseMatrixProduct.h>

Inheritance diagram for sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >:

Detailed Description

template<class Lhs, class Rhs, class ResultType>
class sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >

Given two matrices, compute the product of both matrices. The first time the algorithm runs, it computes the "intersection" between both matrices. This intersection can be reused to compute the product. If, later, both input matrices changed their values, but not their sparsity pattern, the "intersection" remains valid. The same intersection can be used to compute the product as long as the sparsity pattern does not change. This strategy is faster than calling the regular matrix product algorithm (but not if the size of the intersection is huge).

To compute the product, the method computeProduct must be called.

Based on: Saupin, G., Duriez, C. and Grisoni, L., 2007, November. Embedded multigrid approach for real-time volumetric deformation. In International Symposium on Visual Computing (pp. 149-159). Springer, Berlin, Heidelberg. and Saupin, G., 2008. Vers la simulation interactive réaliste de corps déformables virtuels (Doctoral dissertation, Lille 1).

Classes

struct  Intersection
 

Public Attributes

const LhsCleanedm_lhs { nullptr }
 Left side of the product A*B. More...
 
const RhsCleanedm_rhs { nullptr }
 Right side of the product A*B. More...
 

Protected Attributes

ProductResult m_productResult
 
bool m_hasComputedIntersection { false }
 Result of LHS * RHS. More...
 
Intersection m_intersectionAB
 

Public Member Functions

void computeProduct (bool forceComputeIntersection=false)
 
void computeRegularProduct ()
 
const ResultType & getProductResult () const
 
void invalidateIntersection ()
 
 SparseMatrixProduct (Lhs *lhs, Rhs *rhs)
 
 SparseMatrixProduct ()=default
 
virtual ~SparseMatrixProduct ()=default
 

Protected Member Functions

void computeIntersection ()
 
virtual void computeProductFromIntersection ()
 

Attribute details

◆ m_hasComputedIntersection

template<class Lhs , class Rhs , class ResultType >
bool sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::m_hasComputedIntersection { false }
protected

Result of LHS * RHS.

◆ m_intersectionAB

template<class Lhs , class Rhs , class ResultType >
Intersection sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::m_intersectionAB
protected

◆ m_lhs

template<class Lhs , class Rhs , class ResultType >
const LhsCleaned* sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::m_lhs { nullptr }

Left side of the product A*B.

◆ m_productResult

template<class Lhs , class Rhs , class ResultType >
ProductResult sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::m_productResult
protected

◆ m_rhs

template<class Lhs , class Rhs , class ResultType >
const RhsCleaned* sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::m_rhs { nullptr }

Right side of the product A*B.

Constructor details

◆ SparseMatrixProduct() [1/2]

template<class Lhs , class Rhs , class ResultType >
sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::SparseMatrixProduct ( Lhs *  lhs,
Rhs *  rhs 
)
inline

◆ SparseMatrixProduct() [2/2]

template<class Lhs , class Rhs , class ResultType >
sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::SparseMatrixProduct ( )
default

◆ ~SparseMatrixProduct()

template<class Lhs , class Rhs , class ResultType >
virtual sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::~SparseMatrixProduct ( )
virtualdefault

Function details

◆ computeIntersection()

template<class Lhs , class Rhs , class ResultType >
void sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::computeIntersection
protected

◆ computeProduct()

template<class Lhs , class Rhs , class ResultType >
void sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::computeProduct ( bool  forceComputeIntersection = false)

◆ computeProductFromIntersection()

template<class Lhs , class Rhs , class ResultType >
void sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::computeProductFromIntersection
protectedvirtual

◆ computeRegularProduct()

template<class Lhs , class Rhs , class ResultType >
void sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::computeRegularProduct

◆ getProductResult()

template<class Lhs , class Rhs , class ResultType >
const ResultType& sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::getProductResult ( ) const
inline

◆ invalidateIntersection()

template<class Lhs , class Rhs , class ResultType >
void sofa::linearalgebra::SparseMatrixProduct< Lhs, Rhs, ResultType >::invalidateIntersection