本文整理汇总了C++中SiconosMatrix::zero方法的典型用法代码示例。如果您正苦于以下问题:C++ SiconosMatrix::zero方法的具体用法?C++ SiconosMatrix::zero怎么用?C++ SiconosMatrix::zero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiconosMatrix
的用法示例。
在下文中一共展示了SiconosMatrix::zero方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sub
void sub(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
{
if (numB == 0 || numA == 0) // if A or B(C) is Block
{
C *= -1.0;
C += A;
}
else
{
if (numC == 0) // if C is Block
{
C = A;
C -= B;
}
else // if C is a SimpleMatrix
{
if (numA == numB && numA != 0) // A and B are of the same type and NOT block
{
if (numA == 1)
*C.dense() = *A.dense() - *B.dense();
else if (numA == 2)
*C.triang() = *A.triang() - *B.triang();
else if (numA == 3)
*C.sym() = *A.sym() - *B.sym();
else if (numA == 4)
*C.sparse() = *A.sparse() - *B.sparse();
else //if(numA==5)
*C.banded() = *A.banded() - *B.banded();
}
else if (numA != 0 && numB != 0 && numA != numB) // A and B of different types and none is block
{
if (numC != 1) // => numB == 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)
*C.dense() = *A.dense() - *B.dense();
else if (numA == 2)
*C.dense() = *A.triang() - *B.dense();
else if (numA == 3)
*C.dense() = *A.sym() - *B.dense();
else if (numA == 4)
*C.dense() = *A.sparse() - *B.dense();
else if (numA == 5)
*C.dense() = *A.banded() - *B.dense();
else if (numA == 6)
*C.dense() = *A.zero() - *B.dense();
else //if(numA==7)
*C.dense() = *A.identity() - *B.dense();
}
else // A and/or B is Block
{
C = A;
C -= B;
}
C.resetLU();
}
}
}
else // No common memory between C and A or B.
{
if (numB == 6) // B = 0
C = A;
else // B different from 0
{
if (numC == 0) // if C is Block
{
C = A;
C -= B;
}
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();
//.........这里部分代码省略.........