本文整理汇总了C++中sp::SiconosVector::sparse方法的典型用法代码示例。如果您正苦于以下问题:C++ SiconosVector::sparse方法的具体用法?C++ SiconosVector::sparse怎么用?C++ SiconosVector::sparse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp::SiconosVector
的用法示例。
在下文中一共展示了SiconosVector::sparse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: private_addprod
void private_addprod(double a, SPC::SiconosMatrix A, unsigned int startRow, unsigned int startCol, SPC::SiconosVector x, SP::SiconosVector y)
{
assert(!(A->isPLUFactorized()) && "A is PLUFactorized in prod !!");
if (A->isBlock())
SiconosMatrixException::selfThrow("private_addprod(A,start,x,y) error: not yet implemented for block matrix.");
// we take a submatrix subA of A, starting from row startRow to row (startRow+sizeY) and between columns startCol and (startCol+sizeX).
// Then computation of y = subA*x + y.
unsigned int numA = A->getNum();
unsigned int numY = y->getNum();
unsigned int numX = x->getNum();
unsigned int sizeX = x->size();
unsigned int sizeY = y->size();
if (numX != numY)
SiconosMatrixException::selfThrow("private_addprod(A,start,x,y) error: not yet implemented for x and y of different types.");
if (numY == 1 && numX == 1)
{
assert(y->dense() != x->dense());
if (numA == 1)
noalias(*y->dense()) += a * prod(ublas::subrange(*A->dense(), startRow, startRow + sizeY, startCol, startCol + sizeX), *x->dense());
else if (numA == 2)
noalias(*y->dense()) += a * prod(ublas::subrange(*A->triang(), startRow, startRow + sizeY, startCol, startCol + sizeX), *x->dense());
else if (numA == 3)
noalias(*y->dense()) += a * prod(ublas::subrange(*A->sym(), startRow, startRow + sizeY, startCol, startCol + sizeX), *x->dense());
else if (numA == 4)
noalias(*y->dense()) += a * prod(ublas::subrange(*A->sparse(), startRow, startRow + sizeY, startCol, startCol + sizeX), *x->dense());
else //if(numA==5)
noalias(*y->dense()) += a * prod(ublas::subrange(*A->banded(), startRow, startRow + sizeY, startCol, startCol + sizeX), *x->dense());
}
else // x and y sparse
{
if (numA == 4)
*y->sparse() += a * prod(ublas::subrange(*A->sparse(), startRow, startRow + sizeY, startCol, startCol + sizeX), *x->sparse());
else
SiconosMatrixException::selfThrow("private_addprod(A,start,x,y) error: not yet implemented for x, y sparse and A not sparse.");
}
}