本文整理汇总了C++中IsOne函数的典型用法代码示例。如果您正苦于以下问题:C++ IsOne函数的具体用法?C++ IsOne怎么用?C++ IsOne使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsOne函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: IterIrredTest
NTL_START_IMPL
long IterIrredTest(const GF2X& f)
{
long df = deg(f);
if (df <= 0) return 0;
if (df == 1) return 1;
GF2XModulus F;
build(F, f);
GF2X h;
SetX(h);
SqrMod(h, h, F);
long i, d, limit, limit_sqr;
GF2X g, X, t, prod;
SetX(X);
i = 0;
g = h;
d = 1;
limit = 2;
limit_sqr = limit*limit;
set(prod);
while (2*d <= df) {
add(t, g, X);
MulMod(prod, prod, t, F);
i++;
if (i == limit_sqr) {
GCD(t, f, prod);
if (!IsOne(t)) return 0;
set(prod);
limit++;
limit_sqr = limit*limit;
i = 0;
}
d = d + 1;
if (2*d <= deg(f)) {
SqrMod(g, g, F);
}
}
if (i > 0) {
GCD(t, f, prod);
if (!IsOne(t)) return 0;
}
return 1;
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:59,代码来源:GF2XFactoring.cpp
示例2: IsZero
bool Matrix4x4::isIdentity() const
{
bool result = false;
if( IsOne(m_Internal->matrix[0][0]) && IsZero(m_Internal->matrix[1][0]) && IsZero(m_Internal->matrix[2][0]) && IsZero(m_Internal->matrix[3][0]) &&
IsZero(m_Internal->matrix[0][0]) && IsOne(m_Internal->matrix[1][0]) && IsZero(m_Internal->matrix[2][0]) && IsZero(m_Internal->matrix[3][0]) &&
IsZero(m_Internal->matrix[0][0]) && IsZero(m_Internal->matrix[1][0]) && IsOne(m_Internal->matrix[2][0]) && IsZero(m_Internal->matrix[3][0]) &&
IsZero(m_Internal->matrix[0][0]) && IsZero(m_Internal->matrix[1][0]) && IsZero(m_Internal->matrix[2][0]) && IsOne(m_Internal->matrix[3][0]))
{
result = true;
}
return result;
}
开发者ID:ssell,项目名称:OcularEngine,代码行数:14,代码来源:Matrix4x4.cpp
示例3: RTCResult
Boolean RTCResult(int Iter, double rNorm, double bNorm, IterIdType IterId)
/* get result of RTC */
{
Boolean Result;
if (LASResult() == LASOK) {
if (rNorm < RTCEps * bNorm || (IsZero(bNorm) && IsOne(1.0 + rNorm)))
Result = True;
else
Result = False;
LastNoIter = Iter;
if (!IsZero(bNorm))
LastAcc = rNorm / bNorm;
else
LastAcc = 1.0;
if (RTCAuxProc != NULL)
(*RTCAuxProc)(Iter, rNorm, bNorm, IterId);
} else {
Result = True;
}
return(Result);
}
开发者ID:jumpinsky,项目名称:diff_equations,代码行数:25,代码来源:rtc.c
示例4: IsOne
long operator==(const GF2X& a, long b)
{
if (b & 1)
return IsOne(a);
else
return IsZero(a);
}
开发者ID:tell,项目名称:ntl-unix,代码行数:7,代码来源:GF2X.cpp
示例5: factor_r
// recursive factoring (precondition: n composite)
// currently only uses ECM
void factor_r(vec_pair_ZZ_long& factors, const ZZ& _n,
const ZZ& bnd, double failure_prob, bool verbose) {
ZZ q;
ZZ n(_n);
do {
// attempt to factor n
if (bnd>0)
ECM(q,n,bnd,failure_prob,verbose);
else
ECM(q,n,ZZ::zero(),0,verbose);
if (IsOne(q)) {
// give up
addFactor(factors,n);
return;
}
// compute other factor
div(n,n,q);
if (n<q) swap(n,q);
// q is small factor, n is large factor
if (ProbPrime_notd(q))
addFactor(factors,q);
else
factor_r(factors,q,bnd,failure_prob,verbose);
// check if n is still composite
if (ProbPrime_notd(n)) {
addFactor(factors,n);
return;
}
} while (true);
}
开发者ID:onechip,项目名称:ecm,代码行数:36,代码来源:ZZFactoring.cpp
示例6: TrialDivision
// trial division primitive
void TrialDivision(vec_pair_ZZ_long& factors, ZZ& q, const ZZ& n, long bnd) {
factors.SetLength(0);
if (&q!=&n) q=n;
if (bnd==0) {
bnd=10000; // should probably be higher
}
PrimeSeq s;
ZZ d;
for (long p=s.next(); (p>0 && p<=bnd); p=s.next()) {
if (DivRem(d,q,p)==0) {
long e=1;
q=d;
while (DivRem(d,q,p)==0) {
++e;
q=d;
}
addFactor(factors,to_ZZ(p),e);
if (IsOne(q))
return;
}
if (d<=p) {
// q must be prime
addFactor(factors,q);
set(q);
return;
}
}
}
开发者ID:onechip,项目名称:ecm,代码行数:31,代码来源:ZZFactoring.cpp
示例7: CanZass
void CanZass(vec_pair_ZZ_pEX_long& factors, const ZZ_pEX& f, long verbose)
{
if (!IsOne(LeadCoeff(f)))
LogicError("CanZass: bad args");
double t;
vec_pair_ZZ_pEX_long sfd;
vec_ZZ_pEX x;
if (verbose) { cerr << "square-free decomposition..."; t = GetTime(); }
SquareFreeDecomp(sfd, f);
if (verbose) cerr << (GetTime()-t) << "\n";
factors.SetLength(0);
long i, j;
for (i = 0; i < sfd.length(); i++) {
if (verbose) {
cerr << "factoring multiplicity " << sfd[i].b
<< ", deg = " << deg(sfd[i].a) << "\n";
}
SFCanZass(x, sfd[i].a, verbose);
for (j = 0; j < x.length(); j++)
append(factors, cons(x[j], sfd[i].b));
}
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:30,代码来源:ZZ_pEXFactoring.cpp
示例8: ECM
void ECM(ZZ& q, const ZZ& N, long ncurves, long B1, long B2, long D,
bool verbose) {
// initialize ZZ_p
ZZ_pBak bak;
bak.save();
ZZ_p::init(N);
PrimeSeq seq;
for (long i=0; i<ncurves; ++i) {
if (verbose) {
if (ncurves<NTL_MAX_LONG)
std::cout<<"ECM: "<<NumBits(N)<<" bits; "
<<i<<"/"<<ncurves<<" curves\r"<<std::flush;
else
std::cout<<"ECM: "<<NumBits(N)<<" bits; "
<<i<<" curves\r"<<std::flush;
}
// try to find a factor
ECM_one_curve(q,seq,B1,B2,D);
if (!IsOne(q)) {
if (verbose) {
std::cout<<"ECM: "<<NumBits(N)<<" bits; "
<<(i+1)<<" curves; found "<<q<<" "<<std::endl;
}
return;
}
}
if (verbose)
std::cout<<"ECM: "<<NumBits(N)<<" bits; FAILED! "<<std::endl;
set(q);
}
开发者ID:onechip,项目名称:ecm,代码行数:33,代码来源:ZZFactoring.cpp
示例9: FindRoot
void FindRoot(GF2E& root, const GF2EX& ff)
// finds a root of ff.
// assumes that ff is monic and splits into distinct linear factors
{
GF2EXModulus F;
GF2EX h, h1, f;
GF2E r;
f = ff;
if (!IsOne(LeadCoeff(f)))
Error("FindRoot: bad args");
if (deg(f) == 0)
Error("FindRoot: bad args");
while (deg(f) > 1) {
build(F, f);
random(r);
clear(h);
SetCoeff(h, 1, r);
TraceMap(h, h, F);
GCD(h, h, f);
if (deg(h) > 0 && deg(h) < deg(f)) {
if (deg(h) > deg(f)/2)
div(f, f, h);
else
f = h;
}
}
root = ConstTerm(f);
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:35,代码来源:GF2EXFactoring.cpp
示例10: SquareFreeDecomp
NTL_START_IMPL
void SquareFreeDecomp(vec_pair_ZZ_pX_long& u, const ZZ_pX& ff)
{
ZZ_pX f = ff;
if (!IsOne(LeadCoeff(f)))
Error("SquareFreeDecomp: bad args");
ZZ_pX r, t, v, tmp1;
long m, j, finished, done;
u.SetLength(0);
if (deg(f) == 0)
return;
m = 1;
finished = 0;
do {
j = 1;
diff(tmp1, f);
GCD(r, f, tmp1);
div(t, f, r);
if (deg(t) > 0) {
done = 0;
do {
GCD(v, r, t);
div(tmp1, t, v);
if (deg(tmp1) > 0) append(u, cons(tmp1, j*m));
if (deg(v) > 0) {
div(r, r, v);
t = v;
j++;
}
else
done = 1;
} while (!done);
if (deg(r) == 0) finished = 1;
}
if (!finished) {
/* r is a p-th power */
long p, k, d;
conv(p, ZZ_p::modulus());
d = deg(r)/p;
f.rep.SetLength(d+1);
for (k = 0; k <= d; k++)
f.rep[k] = r.rep[k*p];
m = m*p;
}
} while (!finished);
}
开发者ID:JamesHirschorn,项目名称:QFCL,代码行数:59,代码来源:ZZ_pXFactoring.cpp
示例11: Q_KerDefined
Boolean Q_KerDefined(QMatrix *Q)
/* returns True if Q is singular and the null space has been defined
otherwise False */
{
Boolean KerDefined;
if (LASResult() == LASOK) {
if ((Q->UnitRightKer || Q->RightKerCmp != NULL) && !IsZero(Q->MultiplD)
&& IsOne(Q->MultiplU / Q->MultiplD) && IsOne(Q->MultiplL / Q->MultiplD))
KerDefined = True;
else
KerDefined = False;
} else {
KerDefined = (Boolean)0;
}
return(KerDefined);
}
开发者ID:Neo-Vincent,项目名称:vortex_stream,代码行数:17,代码来源:qmatrix.c
示例12: CoCoA_ERROR
void PolyRingBase::myMonic(RawPtr rawmonic, ConstRawPtr rawf) const
{
if (myIsZero(rawf)) // or CoCoA_ASSERT???
CoCoA_ERROR(ERR::ZeroRingElem,"PolyRingBase::myMonic");
RingElem ans = RingElemAlias(ring(this), rawf);
if (!IsOne(myLC(rawf)) && !myDivByCoeff(raw(ans), raw(myLC(rawf))))
CoCoA_ERROR(ERR::BadQuot, "PolyRingBase::myDiv");
mySwap(rawmonic, raw(ans));
}
开发者ID:BrentBaccala,项目名称:CoCoA,代码行数:9,代码来源:PolyRing.C
示例13:
long operator==(const RR& a, double b)
{
if (b == 0) return IsZero(a);
if (b == 1) return IsOne(a);
NTL_TLS_LOCAL(RR, B);
B = b;
return a == B;
}
开发者ID:95krasovsky,项目名称:SecretSharingSchemes,代码行数:9,代码来源:RR.c
示例14:
long operator==(const RR& a, double b)
{
if (b == 0) return IsZero(a);
if (b == 1) return IsOne(a);
static RR B;
B = b;
return a == B;
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:9,代码来源:RR.c
示例15: add
bool_t add(divisor& x, const divisor& a, const divisor& b)
// This subroutine wraps other functions that does the actual
// divisor arithmetic. It checks the validity of input divisors
// so that other subroutines it calls do not need to do so.
{
bool_t OK = TRUE;
/* Reduce overhead of checking with NDEBUG flag */
assert(OK = OK && a.is_valid_divisor() && b.is_valid_divisor());
if (deg(a.get_upoly()) == genus && deg(b.get_upoly()) == genus) {
if (a == - b) {
x.set_unit();
OK = TRUE;
return OK;
}
if (a != b && IsOne(GCD(a.get_upoly(), b.get_upoly()))) {
// Addition
OK = OK && add_diff(x, a, b);
return OK;
} else if (a == b && IsOne(GCD(a.get_curve().get_h() +
2*a.get_vpoly(), a.get_upoly())) ) {
// Doubling
// Exclude the case when one point of the divisor is equal to
// its opposite
OK = OK && doubling(x, a);
return OK;
}
}
// Call add_cantor() to handle other cases
OK = OK && add_cantor(x, a, b);
return OK;
}
开发者ID:syncom,项目名称:libg2hec,代码行数:42,代码来源:add_explicit.C
示例16: FindRoots
void FindRoots(vec_ZZ_pE& x, const ZZ_pEX& ff)
{
ZZ_pEX f = ff;
if (!IsOne(LeadCoeff(f)))
LogicError("FindRoots: bad args");
x.SetMaxLength(deg(f));
x.SetLength(0);
RecFindRoots(x, f);
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:11,代码来源:ZZ_pEXFactoring.cpp
示例17: FindRoots
void FindRoots(vec_GF2E& x, const GF2EX& ff)
{
GF2EX f = ff;
if (!IsOne(LeadCoeff(f)))
Error("FindRoots: bad args");
x.SetMaxLength(deg(f));
x.SetLength(0);
RecFindRoots(x, f);
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:11,代码来源:GF2EXFactoring.cpp
示例18: SquareFreeDecomp
void SquareFreeDecomp(vec_pair_GF2EX_long& u, const GF2EX& ff)
{
GF2EX f = ff;
if (!IsOne(LeadCoeff(f)))
Error("SquareFreeDecomp: bad args");
GF2EX r, t, v, tmp1;
long m, j, finished, done;
u.SetLength(0);
if (deg(f) == 0)
return;
m = 1;
finished = 0;
do {
j = 1;
diff(tmp1, f);
GCD(r, f, tmp1);
div(t, f, r);
if (deg(t) > 0) {
done = 0;
do {
GCD(v, r, t);
div(tmp1, t, v);
if (deg(tmp1) > 0) append(u, cons(tmp1, j*m));
if (deg(v) > 0) {
div(r, r, v);
t = v;
j++;
}
else
done = 1;
} while (!done);
if (deg(r) == 0) finished = 1;
}
if (!finished) {
/* r is a square */
long k, d;
d = deg(r)/2;
f.rep.SetLength(d+1);
for (k = 0; k <= d; k++)
IterSqr(f.rep[k], r.rep[k*2], GF2E::degree()-1);
m = m*2;
}
} while (!finished);
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:53,代码来源:GF2EXFactoring.cpp
示例19: IrredBaseCase
static
long IrredBaseCase(const ZZ_pEX& h, long q, long a, const ZZ_pEXModulus& F)
{
long e;
ZZ_pEX X, s, d;
e = power(q, a-1);
PowerCompose(s, h, e, F);
SetX(X);
sub(s, s, X);
GCD(d, F.f, s);
return IsOne(d);
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:13,代码来源:ZZ_pEXFactoring.cpp
示例20: MakeMonic
void MakeMonic(zz_pX& x)
{
if (IsZero(x))
return;
if (IsOne(LeadCoeff(x)))
return;
zz_p t;
inv(t, LeadCoeff(x));
mul(x, x, t);
}
开发者ID:av-elier,项目名称:fast-exponentiation-algs,代码行数:13,代码来源:lzz_pX1.c
注:本文中的IsOne函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论