本文整理汇总了C++中SiconosMatrix::resetLU方法的典型用法代码示例。如果您正苦于以下问题:C++ SiconosMatrix::resetLU方法的具体用法?C++ SiconosMatrix::resetLU怎么用?C++ SiconosMatrix::resetLU使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiconosMatrix
的用法示例。
在下文中一共展示了SiconosMatrix::resetLU方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expm
void expm(SiconosMatrix& A, SiconosMatrix& Exp, bool computeAndAdd)
{
// Implemented only for dense matrices.
// Note FP : Maybe it works for others but it has not been
// tested here --> to be done
// Do not work with sparse.
A.resetLU();
Exp.resetLU();
assert(Exp.num() == 1 || A.num() == 1);
if(computeAndAdd)
*Exp.dense() += expm_pad(*A.dense());
else
*Exp.dense() = expm_pad(*A.dense());
}
示例2: add
void add(const SiconosMatrix & A, const SiconosMatrix& B, SiconosMatrix& C)
{
// To compute C = A + B in an "optimized" way (in comparison with operator +)
if ((A.size(0) != B.size(0)) || (A.size(1) != B.size(1)))
SiconosMatrixException::selfThrow("Matrix addition: inconsistent sizes");
if ((A.size(0) != C.size(0)) || (A.size(1) != C.size(1)))
SiconosMatrixException::selfThrow("Matrix addition: inconsistent sizes");
unsigned int numA = A.getNum();
unsigned int numB = B.getNum();
unsigned int numC = C.getNum();
// === if C is zero or identity => read-only ===
if (numC == 6 || numC == 7)
SiconosMatrixException::selfThrow("Matrix addition ( add(A,B,C) ): wrong type for resulting matrix C (read-only: zero or identity).");
// === common memory between A, B, C ===
if (&A == &C) // A and C have common memory
{
C += B;
}
else if (&B == &C) // B and C have common memory
{
C += A;
}
else // No common memory between C and A or B.
{
if (numA == 6) // A = 0
C = B ;
else if (numB == 6) // B = 0
C = A;
else // A and B different from 0
{
if (numC == 0) // if C is Block
{
if (numA != 0) // A simple, whatever is B
{
C = A;
C += B;
}
else // A Block
{
C = B;
C += A;
}
}
else // if C is a SimpleMatrix
{
if (numA == numB && numA != 0) // A and B are of the same type and NOT block
{
if (numC == numA)
{
if (numA == 1)
noalias(*C.dense()) = *A.dense() + *B.dense();
else if (numA == 2)
noalias(*C.triang()) = *A.triang() + *B.triang();
else if (numA == 3)
noalias(*C.sym()) = *A.sym() + *B.sym();
else if (numA == 4)
noalias(*C.sparse()) = *A.sparse() + *B.sparse();
else //if(numA==5)
noalias(*C.banded()) = *A.banded() + *B.banded();
}
else // C and A of different types.
{
if (numC != 1)
SiconosMatrixException::selfThrow("Matrix addition ( add(A,B,C) ): wrong type for resulting matrix C.");
// Only dense matrices are allowed for output.
if (numA == 1)
noalias(*C.dense()) = *A.dense() + *B.dense();
else if (numA == 2)
noalias(*C.dense()) = *A.triang() + *B.triang();
else if (numA == 3)
noalias(*C.dense()) = *A.sym() + *B.sym();
else if (numA == 4)
noalias(*C.dense()) = *A.sparse() + *B.sparse();
else //if(numA==5)
noalias(*C.dense()) = *A.banded() + *B.banded();
}
C.resetLU();
}
else if (numA != 0 && numB != 0 && numA != numB) // A and B of different types and none is block
{
if (numC != 1)
SiconosMatrixException::selfThrow("Matrix addition ( add(A,B,C) ): wrong type for resulting matrix C.");
// Only dense matrices are allowed for output.
if (numA == 1)
switch (numB)
{
case 2:
noalias(*C.dense()) = *A.dense() + *B.triang();
break;
case 3:
noalias(*C.dense()) = *A.dense() + *B.sym();
break;
case 4:
noalias(*C.dense()) = *A.dense() + *B.sparse();
//.........这里部分代码省略.........