本文整理汇总了C++中DMat::entry方法的典型用法代码示例。如果您正苦于以下问题:C++ DMat::entry方法的具体用法?C++ DMat::entry怎么用?C++ DMat::entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DMat
的用法示例。
在下文中一共展示了DMat::entry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addTo
void addTo(DMat<RT>& A, MatrixWindow wA, const DMat<RT>& B, MatrixWindow wB)
{
assert(wA.sameSize(wB));
long rA = wA.begin_row;
long rB = wB.begin_row;
for (; rA < wA.end_row; ++rA, ++rB)
{
long cA = wA.begin_column;
long cB = wB.begin_column;
for (; cA < wA.end_column; ++cA, ++cB)
{
auto& a = A.entry(rA, cA);
A.ring().add(a, a, B.entry(rB, cB));
}
}
}
示例2: assert
double ResF4toM2Interface::setDegreeZeroMap(SchreyerFrame& C,
DMat<RingType>& result,
int slanted_degree,
int lev)
// 'result' should be previously initialized, but will be resized.
// return value: -1 means (slanted_degree, lev) is out of range, and the zero matrix was returned.
// otherwise: the fraction of non-zero elements is returned.
{
// As above, get the size of the matrix, and 'newcols'
// Now we loop through the elements of degree 'slanted_degree + lev' at level 'lev'
const RingType& R = result.ring();
if (not (lev > 0 and lev <= C.maxLevel()))
{
result.resize(0,0);
return -1;
}
assert(lev > 0 and lev <= C.maxLevel());
int degree = slanted_degree + lev;
auto& thislevel = C.level(lev);
int ncols = 0;
for (auto p=thislevel.begin(); p != thislevel.end(); ++p)
{
if (p->mDegree == degree) ncols++;
}
auto& prevlevel = C.level(lev-1);
int* newcomps = new int[prevlevel.size()];
int nrows = 0;
for (int i=0; i<prevlevel.size(); i++)
if (prevlevel[i].mDegree == degree)
newcomps[i] = nrows++;
else
newcomps[i] = -1;
result.resize(nrows, ncols);
int col = 0;
long nnonzeros = 0;
for (auto p=thislevel.begin(); p != thislevel.end(); ++p)
{
if (p->mDegree != degree) continue;
auto& f = p->mSyzygy;
auto end = poly_iter(C.ring(), f, 1);
auto i = poly_iter(C.ring(), f);
for ( ; i != end; ++i)
{
long comp = C.monoid().get_component(i.monomial());
if (newcomps[comp] >= 0)
{
R.set_from_long(result.entry(newcomps[comp], col), C.gausser().coeff_to_int(i.coefficient()));
nnonzeros++;
}
}
++col;
}
double frac_nonzero = (nrows*ncols);
frac_nonzero = static_cast<double>(nnonzeros) / frac_nonzero;
delete[] newcomps;
return frac_nonzero;
}