本文整理汇总了C++中PolyRing类的典型用法代码示例。如果您正苦于以下问题:C++ PolyRing类的具体用法?C++ PolyRing怎么用?C++ PolyRing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PolyRing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: monic
RingElem monic(ConstRefRingElem f)
{
const PolyRing Rx = owner(f);
RingElem ans(Rx);
Rx->myMonic(raw(ans), raw(f));
return ans;
}
示例2:
void ReducerPackDedup<Q>::MultipleWithPos::addCurrentCoefficient(
const PolyRing& ring,
Coefficient& coeff
) {
Coefficient tmp;
ring.coefficientMult(multiple.coef, pos.coef(), tmp);
ring.coefficientAddTo(coeff, tmp);
}
示例3: IndetPower
RingElem IndetPower(const PolyRing& P, long var, long exp) // error if exp < 0
{
P->myCheckIndetIndex(var, "IndetPower(P, var, exp)");
if (exp < 0) CoCoA_ERROR(ERR::NegExp, "IndetPower(P, var, exp)");
RingElem ans(P, 1);
P->myIndetPower(raw(ans), var, exp);
return ans;
}
示例4:
void TournamentReducer::MultipleWithPos::destroy(const PolyRing& ring) {
ring.freeMonomial(current);
ring.freeMonomial(const_cast<ConstMonomial&>(multiple.monom).castAwayConst());
// Call the destructor to destruct the iterators into std::vector.
// In debug mode MSVC puts those in a linked list and the destructor
// has to be called since it takes an iterator off the list. We had
// memory corruption problems before doing this.
this->~MultipleWithPos();
}
示例5:
void ReducerPack<Q>::MultipleWithPos::destroy(const PolyRing& ring) {
ring.monoid().freeRaw(*current);
ring.monoid().freeRaw(*multiple.mono);
// Call the destructor to destruct the iterators into std::vector.
// In debug mode MSVC puts those in a linked list and the destructor
// has to be called since it takes an iterator off the list. There were
// memory corruption problems in debug mode before doing this on MSVC.
this->~MultipleWithPos();
}
示例6: deriv
RingElem deriv(ConstRefRingElem f, ConstRefRingElem x)
{
if (owner(x) != owner(f)) CoCoA_ERROR(ERR::MixedRings, "deriv(f, x)");
if (IsFractionField(owner(f))) return DerivFrF(f,x);
// From here on we are in the "polynomial" case.
if (!IsIndet(x)) CoCoA_ERROR(ERR::NotIndet, "deriv(f,x)");
const PolyRing Rx = owner(f);
RingElem ans(Rx);
Rx->myDeriv(raw(ans), raw(f), raw(x));
return ans;
}
示例7: program
void program()
{
// This test is for testing printing functions
GlobalManager CoCoAFoundations;
PolyRing R = NewPolyRing(RingQQ(), symbols("a","b")); // QQ[a,b]
ring K = NewFractionField(R); // QQ(a,b)
PolyRing Kxy = NewPolyRing(K, symbols("x", "y"));
RingHom f = CanonicalHom(R,K);
RingHom g = CanonicalHom(K,Kxy);
RingHom h = g(f);
RingElem a = RingElem(R, symbol("a"));
RingElem b = RingElem(R, symbol("b"));
RingElem Inv_a = 1/f(a);
RingElem x = RingElem(Kxy, symbol("x"));
RingElem Inv_a_x = g(Inv_a)*x;
// std::cout << 2*a/3-1 << std::endl;
// std::cout << 2*h(a)*x-1 << std::endl;
{ ostringstream s; s << a/2; TEST_ASSERT(s.str() == "(1/2)*a"); }
{ ostringstream s; s << -a/3; TEST_ASSERT(s.str() == "(-1/3)*a"); }
{ ostringstream s; s << -x/3; TEST_ASSERT(s.str() == "(-1/3)*x"); }
{ ostringstream s; s << h(-a)*x*x + h(1-a)*x + h(1-a);
TEST_ASSERT(s.str() == "-a*x^2 +(-a +1)*x -a +1"); }
{ ostringstream s; s << x - h(a*b); TEST_ASSERT(s.str() == "x -a*b"); }
{ ostringstream s; s << -x; TEST_ASSERT(s.str() == "-x"); }
{ ostringstream s; s << -x+1; TEST_ASSERT(s.str() == "-x +1"); }
{ ostringstream s; s << x-1; TEST_ASSERT(s.str() == "x -1"); }
{ ostringstream s; s << x- h(a); TEST_ASSERT(s.str() == "x -a"); }
{ ostringstream s; s << 1/f(a); TEST_ASSERT(s.str() == "1/a"); }
{ ostringstream s; s << 1/h(a); TEST_ASSERT(s.str() == "1/a"); }
{ ostringstream s; s << g(1/f(a))*x; TEST_ASSERT(s.str() == "(1/a)*x"); }
{ ostringstream s; s << h(a)*x; TEST_ASSERT(s.str() == "a*x"); }
{ ostringstream s; s << x/(-1); TEST_ASSERT(s.str() == "-x"); }
{ ostringstream s; s << x-one(Kxy)/2; TEST_ASSERT(s.str() == "x -1/2"); }
{ ostringstream s; s << x-h(a/2); TEST_ASSERT(s.str() == "x -a/2"); }
{ ostringstream s; s << x-h(a)/2; TEST_ASSERT(s.str() == "x -a/2"); }
{ ostringstream s; s << x-h(a+1)/2; TEST_ASSERT(s.str() == "x +(-a -1)/2"); }
{ R->myOutputSelfLong(std::cout); }
{ std::cout << std::endl; }
{ NewPolyRing(R, SymbolRange("x",1,3))->myOutputSelfLong(std::cout); }
{ std::cout << std::endl; }
{ NewPolyRing(NewFractionField(R), SymbolRange("x",1,3))->myOutputSelfLong(std::cout); }
{ std::cout << std::endl; }
{ NewPolyRing(NewQuotientRing(R,ideal(ReadExpr(R,"a^2-2"))), SymbolRange("x",1,3))->myOutputSelfLong(std::cout); }
{ std::cout << std::endl; }
// std::cout << x-h(a)/2 << std::endl;
}
示例8: EvalHom
RingHom EvalHom(const PolyRing& Rx, const BigRat& q) // Maps f in R[x] into f(q) in R
{
if (NumIndets(Rx) != 1) CoCoA_ERROR(ERR::BadArg, "EvalHom(Rx,N)");
const ring& R = CoeffRing(Rx);
const vector<RingElem> IndetImage(1, RingElem(R,q));
return Rx->myHomCtor(R, IdentityHom(R), IndetImage);
}
示例9: while
void ReducerPackDedup<Q>::MultipleWithPos::destroy(const PolyRing& ring) {
MultipleWithPos* entry = this;
do {
ring.monoid().freeRaw(*entry->current);
ring.monoid().freeRaw(*entry->multiple.mono);
MultipleWithPos* next = entry->chain;
MATHICGB_ASSERT(next != 0);
// Call the destructor to destruct the iterators into std::vector.
// In debug mode MSVC puts those in a linked list and the destructor
// has to be called since it takes an iterator off the list. There were
// memory corruption problems in debug mode on MSVC before doing this.
entry->~MultipleWithPos();
entry = next;
} while (entry != this);
}
示例10: mRatioSorted
MATHICGB_NAMESPACE_BEGIN
SigPolyBasis::SigPolyBasis(
const PolyRing& R0,
int monoLookupType,
int monTableType,
bool preferSparseReducers
):
mMonoLookupFactory
(MonoLookup::makeFactory(R0.monoid(), monoLookupType)),
mRatioSorted(RatioOrder(mSigLeadRatio, R0.monoid())),
mMinimalMonoLookup(mMonoLookupFactory->make(preferSparseReducers, true)),
mBasis(R0, mMonoLookupFactory->make(preferSparseReducers, true)),
mPreferSparseReducers(preferSparseReducers)
{
mTmp = mBasis.ring().allocMonomial();
const_cast<MonoLookup&>(mBasis.monoLookup()).setSigBasis(*this);
mMinimalMonoLookup->setSigBasis(*this);
}
示例11: ClearDenom
RingElem ClearDenom(ConstRefRingElem f)
{
if (!IsPolyRing(owner(f)))
CoCoA_ERROR(ERR::NotElemPolyRing, "ClearDenom(f)");
const PolyRing Qx = owner(f);
const ring Q = CoeffRing(Qx);
if (!IsFractionField(Q))
CoCoA_ERROR(ERR::NotTrueGCDDomain, "CoeffRing inside ClearDenom(f)");
const ring R = BaseRing(Q);
if (!IsTrueGCDDomain(R))
CoCoA_ERROR(ERR::NotTrueGCDDomain, "BaseRing of CoeffRing inside ClearDenom(f)");
// if (IsField(R)) // see documentation (Bugs section)
// CoCoA_ERROR(ERR::NotTrueGCDDomain, "content(f)");
if (IsZero(f)) return zero(Qx);
RingElem ans(Qx);
Qx->myClearDenom(raw(ans), raw(f));
return ans;
}
示例12: content
RingElem content(ConstRefRingElem f)
{
if (!IsPolyRing(owner(f)))
CoCoA_ERROR(ERR::NotElemPolyRing, "content(f)");
const PolyRing Rx = owner(f);
const ring R = CoeffRing(Rx);
if (IsFractionFieldOfGCDDomain(R))
{
if (IsZero(f)) return zero(R);
RingElem ans(R);
Rx->myContentFrF(raw(ans), raw(f));
return ans;
}
if (IsTrueGCDDomain(R))
{
if (IsZero(f)) return zero(R);
RingElem ans(R);
Rx->myContent(raw(ans), raw(f));
return ans;
}
CoCoA_ERROR(ERR::NotTrueGCDDomain, "content(f)");
return zero(R); // never reached, just to keep compiler quiet
}
示例13: PolyRingHom
// Rx is the domain, S is the codomain
RingHom PolyRingHom(const PolyRing& Rx, const ring& S, RingHom CoeffHom, const std::vector<RingElem>& IndetImages)
{
const char* const FnName = "PolyRingHom(Rx,S,CoeffHom,IndetImages)";
if (domain(CoeffHom) != CoeffRing(Rx))
CoCoA_ERROR(ERR::MixedCoeffRings, FnName);
if (IsPolyRing(S) && codomain(CoeffHom) == CoeffRing(S))
CoeffHom = CoeffEmbeddingHom(S)(CoeffHom);
if (codomain(CoeffHom) != S)
CoCoA_ERROR(ERR::BadCodomain, FnName);
if (NumIndets(Rx) != len(IndetImages))
CoCoA_ERROR(ERR::BadPolyRingHomImages, FnName);
for (long i=0; i < NumIndets(Rx); ++i)
if (owner(IndetImages[i]) != S)
CoCoA_ERROR(ERR::BadPolyRingHomImages, FnName);
return Rx->myHomCtor(S, CoeffHom, IndetImages);
}
示例14: PolyAlgebraHom
RingHom PolyAlgebraHom(const PolyRing& Rx, const ring& Ry, const std::vector<RingElem>& IndetImages)
{
const char* const FnName = "PolyAlgebraHom(Rx,Ry,IndetImages)";
// Check that IndetImages are sensible...
if (NumIndets(Rx) != len(IndetImages))
CoCoA_ERROR(ERR::BadPolyRingHomImages, FnName);
for (long i=0; i < NumIndets(Rx); ++i)
if (owner(IndetImages[i]) != Ry)
CoCoA_ERROR(ERR::BadPolyRingHomImages, FnName);
// // Special case: codomain is coeff ring.
// if (Ry == CoeffRing(Rx))
// return Rx->myHomCtor(Ry, IdentityHom(Ry), IndetImages);
// // General case: codomain must be a poly ring with same coeffs
// if (!IsPolyRing(Ry))
// CoCoA_ERROR(ERR::BadCodomain, FnName);
// if (CoeffRing(Rx) != CoeffRing(Ry))
// CoCoA_ERROR(ERR::MixedCoeffRings, FnName);
// return Rx->myHomCtor(Ry, CoeffEmbeddingHom(Ry), IndetImages);
return Rx->myHomCtor(Ry, CanonicalHom(CoeffRing(Rx),Ry), IndetImages);
}
示例15: ilio
void ilio(Mat &M, PolyElement &f, MatDom &MD, PolyRing &R) {
IliopoulosDom sfi(R);
size_t n = M.coldim();
Mat A(MD.field(), n, n);
MD.copy(A, M);
FactorVector l;
l.resize(n);
Timer timer;
timer.start();
sfi.smithForm(l, A, f);
timer.stop();
cout << "Iliopolous Time: " << timer << endl;
if (VERBOSE) {
for (size_t i = 0; i < l.size(); i++) {
R.write(cout, l[i]) << endl;
}
cout << endl;
}
}