本文整理汇总了C++中FacVec类的典型用法代码示例。如果您正苦于以下问题:C++ FacVec类的具体用法?C++ FacVec怎么用?C++ FacVec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FacVec类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeDegree
long ComputeDegree(const ZZ_pX& h, const ZZ_pXModulus& F)
// f = F.f is assumed to be an "equal degree" polynomial
// h = X^p mod f
// the common degree of the irreducible factors of f is computed
{
if (F.n == 1 || IsX(h)) return 1;
FacVec fvec;
FactorInt(fvec, F.n);
return RecComputeDegree(fvec.length()-1, h, F, fvec);
}
示例2: FactorInt
void FactorInt(FacVec& fvec, long n)
{
if (n <= 1) LogicError("internal error: FactorInt(FacVec,long n) with n<=1");
if (NTL_OVERFLOW(n, 1, 0))
ResourceError("internal error: FactorInt(FacVec,long n) with n too large");
long NumFactors;
long q;
fvec.SetLength(2*NextPowerOfTwo(n));
NumFactors = 0;
q = 2;
while (n != 1) {
if (n%q == 0) {
fvec[NumFactors].q = q;
n = n/q;
fvec[NumFactors].a = 1;
fvec[NumFactors].val = q;
while (n%q == 0) {
n = n/q;
(fvec[NumFactors].a)++;
fvec[NumFactors].val *= q;
}
fvec[NumFactors].link = -1;
NumFactors++;
}
q++;
}
fvec.SetLength(2*NumFactors-1);
long lo = 0;
long hi = NumFactors - 1;
while (lo < hi) {
FindMin(fvec, lo, hi);
FindMin(fvec, lo+1, hi);
hi++;
fvec[hi].link = lo;
fvec[hi].val = fvec[lo].val * fvec[lo+1].val;
lo += 2;
}
}
示例3: BuildIrred
void BuildIrred(ZZ_pEX& f, long n)
{
if (n <= 0)
LogicError("BuildIrred: n must be positive");
if (NTL_OVERFLOW(n, 1, 0)) ResourceError("overflow in BuildIrred");
if (n == 1) {
SetX(f);
return;
}
FacVec fvec;
FactorInt(fvec, n);
RecBuildIrred(f, fvec.length()-1, fvec);
}
示例4: DetIrredTest
long DetIrredTest(const ZZ_pEX& f)
{
if (deg(f) <= 0) return 0;
if (deg(f) == 1) return 1;
ZZ_pEXModulus F;
build(F, f);
ZZ_pEX h;
FrobeniusMap(h, F);
ZZ_pEX s;
PowerCompose(s, h, F.n, F);
if (!IsX(s)) return 0;
FacVec fvec;
FactorInt(fvec, F.n);
return RecIrredTest(fvec.length()-1, h, F, fvec);
}