本文整理汇总了C++中DMat::rowEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ DMat::rowEnd方法的具体用法?C++ DMat::rowEnd怎么用?C++ DMat::rowEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DMat
的用法示例。
在下文中一共展示了DMat::rowEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: subtractMultipleTo
void subtractMultipleTo(DMat<RT>& C,
const DMat<RT>& A,
const DMat<RT>& B)
// C = C - A*B
{
typedef typename RT::ElementType ElementType;
typedef typename DMat<RT>::ConstIterator ConstIterator;
M2_ASSERT(A.numColumns() == B.numRows());
M2_ASSERT(A.numRows() == C.numRows());
M2_ASSERT(B.numColumns() == C.numColumns());
ElementType* result = C.array();
ElementType tmp;
A.ring().init(tmp);
// WARNING: this routine expects the result matrix to be in ROW MAJOR ORDER
for (size_t i = 0; i<A.numRows(); i++)
for (size_t j = 0; j<B.numColumns(); j++)
{
ConstIterator i1 = A.rowBegin(i);
ConstIterator iend = A.rowEnd(i);
ConstIterator j1 = B.columnBegin(j);
while (i1 != iend)
{
A.ring().mult(tmp, *i1, *j1);
A.ring().subtract(*result, *result, tmp);
++i1;
++j1;
}
result++;
}
A.ring().clear(tmp);
}
示例2: mult
void mult(const DMat<RT>& A,
const DMat<RT>& B,
DMat<RT>& result_product)
{
//printf("entering dmat mult\n");
typedef typename RT::ElementType ElementType;
typedef typename DMat<RT>::ConstIterator ConstIterator;
M2_ASSERT(A.numColumns() == B.numRows());
M2_ASSERT(A.numRows() == result_product.numRows());
M2_ASSERT(B.numColumns() == result_product.numColumns());
ElementType* result = result_product.array();
ElementType tmp;
A.ring().init(tmp);
// WARNING: this routine expects the result matrix to be in ROW MAJOR ORDER
for (size_t i = 0; i<A.numRows(); i++)
for (size_t j = 0; j<B.numColumns(); j++)
{
ConstIterator i1 = A.rowBegin(i);
ConstIterator iend = A.rowEnd(i);
ConstIterator j1 = B.columnBegin(j);
while (i1 != iend)
{
A.ring().mult(tmp, *i1, *j1);
A.ring().add(*result, *result, tmp);
++i1;
++j1;
}
result++;
}
A.ring().clear(tmp);
}