本文整理汇总了C++中Polynomial::hasSameNumVars方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::hasSameNumVars方法的具体用法?C++ Polynomial::hasSameNumVars怎么用?C++ Polynomial::hasSameNumVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::hasSameNumVars方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: poissonBracket
/// the Poisson bracket of two polynomials in this algebra
Polynomial ClassicalLieAlgebra::poissonBracket(const Polynomial& polA,
const Polynomial& polB) const {
if (!(hasElt(polA) && hasElt(polB)))
throw LieAlgebraSizeMismatchError();
assert(polA.hasSameNumVars(polB));
Polynomial pb(zero());
Polynomial pbA(zero());
Polynomial pbB(zero());
for (Index d = 0; d < dof_; ++d) {
pbA = (polA.diff(iQ(d)) * polB.diff(iP(d)));
pbB = (polA.diff(iP(d)) * polB.diff(iQ(d)));
pb += (pbA - pbB);
}
return pb;
}
示例2: PolynomialSizeMismatchError
Polynomial operator*(const Polynomial& a, const Polynomial& b) {
if (!a.hasSameNumVars(b))
throw PolynomialSizeMismatchError();
Polynomial res(a.numVars_);
PowersToCoeffMap::const_iterator apc;
PowersToCoeffMap::const_iterator bpc;
for (apc = a.terms_.begin(); apc != a.terms_.end(); ++apc) {
assert(isValidCoeff(apc->second));
for (bpc = b.terms_.begin(); bpc != b.terms_.end(); ++bpc) {
assert(isValidCoeff(bpc->second));
res.addMonomial((apc->first) * (bpc->first),
(apc->second) * (bpc->second));
}
}
return res;
}