本文整理汇总了C++中ring函数的典型用法代码示例。如果您正苦于以下问题:C++ ring函数的具体用法?C++ ring怎么用?C++ ring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ring
void SMat<CoeffRing>::vec_set_entry(sparsevec *&v,
size_t r,
const elem &a) const
{
sparsevec *p;
bool iszero = ring().is_zero(a);
sparsevec head;
head.next = v;
for (p = &head; p->next != 0; p = p->next)
if (p->next->row <= r) break;
if (p->next == 0 || p->next->row < r)
{
if (iszero) return;
sparsevec *w = vec_new();
w->next = p->next;
w->row = r;
ring().init_set(w->coeff, a);
p->next = w;
}
else if (p->next->row == r)
{
if (iszero)
{
// delete node
sparsevec *tmp = p->next;
p->next = tmp->next;
vec_remove_node(tmp);
}
else
ring().set(p->next->coeff, a);
}
v = head.next;
}
示例2: monoid
// processMonomialProduct
// m is a monomial, component is ignored (it determined the possible n's
// being used here)
// n is a monomial at level 'mThisLevel-1'
// compute their product, and return the column index of this product
// or -1, if the monomial is not needed.
// additionally: the product monomial is inserted into the hash table
// and column array (if it is not already there).
// caveats: this function is only to be used during construction
// of the coeff matrices. It uses mThisLevel.
//
// If the ring has skew commuting variables, then result_sign_if_skew is set to
// 0, 1, or -1.
ComponentIndex F4Res::processMonomialProduct(res_const_packed_monomial m,
res_const_packed_monomial n,
int& result_sign_if_skew)
{
result_sign_if_skew = 1;
auto x = monoid().get_component(n);
auto& p = mFrame.level(mThisLevel - 2)[x];
if (p.mBegin == p.mEnd) return -1;
int* thisMonom = mMonomSpace2.allocate(1 + monoid().max_monomial_size());
thisMonom++; // so thisMonom[-1] exists, but is not part of the monomial, as far as
monoid().unchecked_mult(m, n, thisMonom);
monoid().set_component(x, thisMonom);
if (ring().isSkewCommutative())
{
result_sign_if_skew = monoid().skew_mult_sign(ring().skewInfo(), m, n);
if (result_sign_if_skew == 0)
{
mMonomSpace2.popLastAlloc(thisMonom-1); // we did not need this monomial!
return -1;
}
}
return processCurrentMonomial(thisMonom);
}
示例3: ring
void SMat<CoeffRing>::vec_row_op2(sparsevec *&v,
size_t r1, size_t r2,
const elem &a1, const elem &a2,
const elem &b1, const elem &b2) const
// row(r1 in v) := a1 * row(r1 in v) + a2 * row(r2 in v)
// row(r2 in v) := b1 * row(r1 in v) + b2 * row(r2 in v) (RHS refers to previous values)
{
// v[row r1] = a1 * v[r1] + a2 * v[r2]
// v[row r2] = b1 * v[r1] + b2 * v[r2]
elem e1,e2, c1,c2,c3,c4;
ring().set_zero(c1);
ring().set_zero(c2);
ring().set_zero(c3);
ring().set_zero(c4);
bool r1_nonzero = vec_get_entry(v,r1,e1);
bool r2_nonzero = vec_get_entry(v,r2,e2);
if (!r1_nonzero && !r2_nonzero) return;
if (r1_nonzero)
{
ring().mult(c1, a1, e1);
ring().mult(c3, b1, e1);
}
if (r2_nonzero)
{
ring().mult(c2,a2,e2);
ring().mult(c4,b2,e2);
}
ring().add(c1,c1,c2);
ring().add(c3,c3,c4);
vec_set_entry(v,r1,c1);
vec_set_entry(v,r2,c3);
}
示例4: print_sr
char *
print_sr(struct tr_ri *rh)
{
int hops, ii;
static char line[512];
sprintf(line, "TR Source Route dir=%d, mtu=%d",
rh->dir, Mtutab[rh->mtu]);
hops = (int)(rh->len - 2) / (int)2;
if (hops) {
sprintf(line+strlen(line), ", Route: ");
for (ii = 0; ii < hops; ii++) {
if (! bridge(rh->rd[ii])) {
sprintf(line+strlen(line), "(%d)",
ring(rh->rd[ii]));
} else {
sprintf(line+strlen(line), "(%d)%d",
ring(rh->rd[ii]), bridge(rh->rd[ii]));
}
}
}
return (&line[0]);
}
示例5: main_loop
int main_loop()
{
if( arm_main_timers() == -1) {
wrn_print("failed to arm ring timers");
terminate();
}
if(arm_24h_sig() == -1) {
wrn_print("failed to arm 24h \"killer timer\"");
terminate();
}
sigset_t set;
if(sigfillset(&set) == -1 ) {
err_print ("sigwaitinfo");
return -1;
}
siginfo_t info;
char *custom_dur;
for( ;; ) {
int sig = sigwaitinfo(&set, &info);
dbg_print("FETCHED %s SIGNAL(%ld)",strsignal(sig),(long)sig);
if(IS_EXIT_SIG(sig)) {
dbg_print("%s SIGNAL(%ld) - exit sig; exiting", strsignal(sig),(long)sig);
exit(EXIT_SUCCESS);
}
if(sig == SIG_RING_CUSTOM) {
custom_dur = get_duration(&info);
ring(custom_dur);
continue;
}
switch(sig) {
case -1:
if(errno != EAGAIN) {
err_print("sigwaitinfo");
break;
}
case SIG_REXEC:
rexec();
break;
case SIG_RING_SHORT:
ring(cmd.short_ring);
break;
case SIG_RING_LONG:
ring(cmd.long_ring);
break;
case SIGCHLD:
zombie_assasin();
break;
}
}
}
示例6: monomial
long SchreyerFrame::computeIdealQuotient(int lev, long begin, long elem)
{
/// std::cout << "computeIdealQuotient(" << lev << "," << begin << "," << elem << ")" << std::endl;
// Returns the number of elements added
res_packed_monomial m = monomial(lev, elem);
std::vector<PreElement*> elements;
if (ring().isSkewCommutative())
{
auto skewvars = new int[ring().monoid().n_vars()];
int a = ring().monoid().skew_vars(ring().skewInfo(), m, skewvars);
// std::cout << "adding " << a << " syz from skew" << std::endl;
for (int i=0; i<a; ++i)
{
PreElement* vp = mPreElements.allocate();
vp->vp = mVarpowers.reserve(mMaxVPSize);
monoid().variable_as_vp(skewvars[i], vp->vp);
vp->degree = monoid().degree_of_vp(vp->vp);
int len = static_cast<int>(res_varpower_monomials::length(vp->vp));
mVarpowers.intern(len);
elements.push_back(vp);
}
delete [] skewvars;
}
for (long i=begin; i<elem; i++)
elements.push_back(createQuotientElement(monomial(lev,i), m));
typedef ResF4MonomialLookupTableT<int32_t> MonomialLookupTable;
MonomialLookupTable montab(monoid().n_vars());
#if 0
std::cout << " #pre elements = " << elements.size() << std::endl;
for (auto i=elements.begin(); i != elements.end(); ++i)
{
varpower_monomials::elem_text_out(stdout, (*i)->vp);
fprintf(stdout, "\n");
}
#endif
PreElementSorter C;
std::stable_sort(elements.begin(), elements.end(), C);
long n_elems = 0;
for (auto i = elements.begin(); i != elements.end(); ++i)
{
int32_t not_used;
bool inideal = montab.find_one_divisor_vp(0, (*i)->vp, not_used);
if (inideal) continue;
// Now we create a res_packed_monomial, and insert it into 'lev+1'
montab.insert_minimal_vp(0, (*i)->vp, 0);
res_packed_monomial monom = monomialBlock().allocate(monoid().max_monomial_size());
monoid().from_varpower_monomial((*i)->vp, elem, monom);
// Now insert it into the frame
insertBasic(currentLevel(), monom, (*i)->degree + degree(currentLevel()-1, monoid().get_component(monom)));
n_elems++;
}
//std::cout << " returns " << n_elems << std::endl;
return n_elems;
}
示例7: QObject
AtCommands::AtCommands( AtFrontEnd *frontEnd, AtSessionManager *manager )
: QObject( frontEnd )
{
qLog(ModemEmulator) << "AT command session started";
atFrontEnd = frontEnd;
atManager = manager;
m_atgnc = new AtGsmNonCellCommands( this );
#ifdef QTOPIA_CELL
m_atgcc = new AtGsmCellCommands( this );
#endif
#ifdef ATINTERFACE_SMS
m_atsms = new AtSmsCommands( this );
#endif
#ifdef QTOPIA_BLUETOOTH
m_atbtc = new AtBluetoothCommands( this );
#endif
m_atv250c = new AtV250Commands( this );
// network registration for ATD()
dataCallRequested = false;
cmdsPosn = 0;
result = QAtResult::OK;
extendedError = QAtResult::OK;
connect( frontEnd, SIGNAL(commands(QStringList)),
this, SLOT(commands(QStringList)) );
AtCallManager *calls = manager->callManager();
connect( calls, SIGNAL(stateChanged(int,AtCallManager::CallState,QString,QString)),
this, SLOT(stateChanged(int,AtCallManager::CallState,QString,QString)) );
connect( calls, SIGNAL(deferredResult(AtCommands*,QAtResult::ResultCode)),
this, SLOT(deferredResult(AtCommands*,QAtResult::ResultCode)) );
connect( calls, SIGNAL(ring(QString,QString)),
this, SLOT(ring(QString,QString)) );
connect( calls, SIGNAL(dialingOut(bool,bool,bool)),
this, SLOT(dialingOut(bool,bool,bool)) );
connect( calls, SIGNAL(outgoingConnected(QString)),
this, SLOT(outgoingConnected(QString)) );
connect( calls, SIGNAL(callWaiting(QString,QString)),
this, SLOT(callWaiting(QString,QString)) );
connect( calls, SIGNAL(noCarrier()), this, SLOT(noCarrier()) );
// register those AT commands that this class defines.
add( "D", this, SLOT(atd(QString)) );
add( "+CDIS", this, SLOT(notAllowed()) );
add( "+CFUN", this, SLOT(atcfun(QString)) );
add( "+CIMI", this, SLOT(atcimi(QString)) );
add( "+CMAR", this, SLOT(ignore()) );
}
示例8: hasThreePrimeDifferences
static bool hasThreePrimeDifferences(qint64 n, Primes *primes) {
Q_ASSERT(n > 7);
qint64 maxDiff = (ring(n))*6 + (ring(n)+1)*6 - 1; // exact
updatePrimes(maxDiff, primes);
const QSet<qint64> b = neighbors(n);
int primeCount = 0;
foreach(qint64 i, b) {
qint64 diff = llabs(i - n);
Q_ASSERT(diff <= maxDiff);
primeCount += isPrime(diff, *primes) == true ? 1 : 0;
}
示例9: ring
void F4Res::loadRow(Row& r)
{
// std::cout << "loadRow: ";
// monoid().showAlpha(r.mLeadTerm);
// std::cout << std::endl;
int skew_sign; // will be set to 1, unless ring().isSkewCommutative() is true, then it can be -1,0,1.
// however, if it is 0, then "val" below will also be -1.
FieldElement one;
resGausser().set_one(one);
long comp = monoid().get_component(r.mLeadTerm);
auto& thiselement = mFrame.level(mThisLevel-1)[comp];
//std::cout << " comp=" << comp << " mDegree=" << thiselement.mDegree << " mThisDegree=" << mThisDegree << std::endl;
if (thiselement.mDegree == mThisDegree)
{
// We only need to add in the current monomial
//fprintf(stdout, "USING degree 0 monomial\n");
ComponentIndex val = processMonomialProduct(r.mLeadTerm, thiselement.mMonom, skew_sign);
if (val < 0) fprintf(stderr, "ERROR: expected monomial to live\n");
r.mComponents.push_back(val);
if (skew_sign > 0)
r.mCoeffs.push_back(one);
else
{
// Only happens if we are in a skew commuting ring.
FieldElement c;
ring().resGausser().negate(one, c);
r.mCoeffs.push_back(c);
}
return;
}
auto& p = thiselement.mSyzygy;
auto end = poly_iter(mRing, p, 1);
auto i = poly_iter(mRing, p);
for ( ; i != end; ++i)
{
ComponentIndex val = processMonomialProduct(r.mLeadTerm, i.monomial(), skew_sign);
//std::cout << " monom: " << val << " skewsign=" << skew_sign << " mColumns.size=" << mColumns.size() << std::endl;
if (val < 0) continue;
r.mComponents.push_back(val);
if (skew_sign > 0)
r.mCoeffs.push_back(i.coefficient());
else
{
// Only happens if we are in a skew commuting ring.
FieldElement c;
ring().resGausser().negate(i.coefficient(), c);
r.mCoeffs.push_back(c);
}
}
}
示例10: IM2_RingElement_to_BigComplex
gmp_CCorNull IM2_RingElement_to_BigComplex(const RingElement *a)
{
const Ring *R = a->get_ring();
auto RCCC = dynamic_cast<const M2::ConcreteRing<M2::ARingCCC> *>(R);
if (RCCC != 0)
{
M2::ARingCCC::ElementType b;
RCCC->ring().init(b);
RCCC->ring().from_ring_elem(b, a->get_value());
gmp_CC result = RCCC->ring().toBigComplex(b);
RCCC->ring().clear(b);
return result;
}
auto RCC = dynamic_cast<const M2::ConcreteRing<M2::ARingCC> *>(R);
if (RCC != 0)
{
M2::ARingCC::ElementType b;
RCC->ring().init(b);
RCC->ring().from_ring_elem(b, a->get_value());
gmp_CC result = RCC->ring().toBigComplex(b);
RCC->ring().clear(b);
return result;
}
ERROR("expected an element of CCC");
return 0;
}
示例11: ring
size_t SigPolyBasis::minimalLeadInSigSlow(ConstMonoRef sig) const {
monomial multiplier = ring().allocMonomial();
monomial minLead = ring().allocMonomial();
size_t minLeadGen = static_cast<size_t>(-1);
const auto sigComponent = monoid().component(sig);
const size_t genCount = size();
for (size_t gen = 0; gen < genCount; ++gen) {
if (monoid().component(signature(gen)) != sigComponent)
continue;
if (!monoid().divides(signature(gen), sig))
continue;
monoid().divide(signature(gen), sig, multiplier);
if (minLeadGen != static_cast<size_t>(-1)) {
auto genLead = leadMono(gen);
const auto leadCmp = monoid().compare(minLead, multiplier, genLead);
if (leadCmp == Monoid::LessThan)
continue;
if (leadCmp == Monoid::EqualTo) {
// If same lead monomial in signature, pick the one with fewer terms
// as that one might be less effort to reduce.
const size_t minTerms = poly(minLeadGen).termCount();
const size_t terms = poly(gen).termCount();
if (minTerms > terms)
continue;
if (minTerms == terms) {
// If same number of terms, pick the one with larger signature
// before being multiplied into the same signature. That one
// might be more reduced as the constraint on regular reduction
// is less.
const auto minSig = signature(minLeadGen);
const auto genSig = signature(gen);
const auto sigCmp = monoid().compare(minSig, genSig);
// no two generators have same signature
MATHICGB_ASSERT(sigCmp != Monoid::EqualTo);
if (sigCmp == GT)
continue;
}
}
}
minLeadGen = gen;
monoid().multiply(multiplier, leadMono(gen), minLead);
}
ring().freeMonomial(multiplier);
ring().freeMonomial(minLead);
return minLeadGen;
}
示例12: main
int main()
{
int i,j;
printf("\nEnter no. of process::");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter Process %d is Alive or not(0/1)::",i);
scanf("%d",&list[i]);
if(list[i])
cdr=i;
}
display();
do
{
printf("\n1.BULLY ALGORITHM \n2.RING ALGORITHM\n3.Display\n4.EXIT\nEnter your choice::");
scanf("%d",&j);
switch(j)
{
case 1:
bully();
break;
case 2:
ring();
case 3:
display();
break;
case 4:
exit(1);
}
}while(j!=4);
return 0;
}
示例13: extrude
PolyhedralSurface* extrude( const LineString& g, const Kernel::Vector_3& v )
{
std::auto_ptr< PolyhedralSurface > polyhedralSurface( new PolyhedralSurface() );
if ( g.isEmpty() ) {
return polyhedralSurface.release();
}
for ( size_t i = 0; i < g.numPoints() - 1; i++ ) {
std::auto_ptr< LineString > ring( new LineString ) ;
Kernel::Point_3 a = g.pointN( i ).toPoint_3() ;
Kernel::Point_3 b = g.pointN( i+1 ).toPoint_3() ;
ring->addPoint( new Point( a ) );
ring->addPoint( new Point( b ) );
ring->addPoint( new Point( b + v ) );
ring->addPoint( new Point( a + v ) );
ring->addPoint( new Point( a ) );
polyhedralSurface->addPolygon( new Polygon( ring.release() ) );
}
return polyhedralSurface.release() ;
}
示例14: neighbors
static QSet<qint64> neighbors(qint64 n) {
Q_ASSERT(n > 7);
QSet<qint64> b;
int r = ring(n);
qint64 p = positionInRing(n);
int corner = p / r; // 0 = top, counterclockwise
qint64 offsetFromCorner = p % r; //counterclockwise
qint64 o = ringOffset(r+1) + 2 + corner*(r+1) + offsetFromCorner; // outer neighbor
qint64 i = ringOffset(r-1) + 2 + corner*(r-1) + offsetFromCorner; // inner neighbor
if (p == 0) { // top corner
b.insert( o );
b.insert( o + 1 );
b.insert(modInRing(o - 1, r+1));
b.insert(modInRing(n - 1, r ));
b.insert( i );
//b.insert(n + 1); // diff = 1 -> not prime
} else if (p == r*6 - 1) { // right to the top corner
b.insert( o );
b.insert( o + 1 );
b.insert( i - 1 );
b.insert(modInRing(n + 1, r ));
b.insert(modInRing(i , r-1));
//b.insert(n - 1); // diff = 1 -> not prime
}
return b;
}
示例15: MATHICGB_ASSERT
void F4Reducer::classicReducePolySet(
const std::vector< std::unique_ptr<Poly> >& polys,
const PolyBasis& basis,
std::vector< std::unique_ptr<Poly> >& reducedOut
) {
if (polys.size() <= 1) {
if (tracingLevel >= 2)
std::cerr << "F4Reducer: Using fall-back reducer for "
<< polys.size() << " polynomials.\n";
mFallback->classicReducePolySet(polys, basis, reducedOut);
return;
}
reducedOut.clear();
MATHICGB_ASSERT(!polys.empty());
if (tracingLevel >= 2)
std::cerr << "F4Reducer: Reducing " << polys.size() << " polynomials.\n";
SparseMatrix reduced;
QuadMatrix::Monomials monomials;
{
QuadMatrix qm(ring());
{
if (mType == OldType) {
F4MatrixBuilder builder(basis, mMemoryQuantum);
for (const auto& poly : polys)
builder.addPolynomialToMatrix(*poly);
builder.buildMatrixAndClear(qm);
} else {
F4MatrixBuilder2 builder(basis, mMemoryQuantum);
for (const auto& poly : polys)
builder.addPolynomialToMatrix(*poly);
builder.buildMatrixAndClear(qm);
}
}
MATHICGB_LOG_INCREMENT_BY(F4MatrixRows, qm.rowCount());
MATHICGB_LOG_INCREMENT_BY(F4MatrixTopRows, qm.topLeft.rowCount());
MATHICGB_LOG_INCREMENT_BY(F4MatrixBottomRows, qm.bottomLeft.rowCount());
MATHICGB_LOG_INCREMENT_BY(F4MatrixEntries, qm.entryCount());
saveMatrix(qm);
reduced = F4MatrixReducer(basis.ring().charac()).
reducedRowEchelonFormBottomRight(qm);
monomials = std::move(qm.rightColumnMonomials);
for (auto& mono : qm.leftColumnMonomials)
monoid().freeRaw(mono.castAwayConst());
}
if (tracingLevel >= 2 && false)
std::cerr << "F4Reducer: Extracted " << reduced.rowCount()
<< " non-zero rows\n";
for (SparseMatrix::RowIndex row = 0; row < reduced.rowCount(); ++row) {
auto p = make_unique<Poly>(basis.ring());
reduced.rowToPolynomial(row, monomials, *p);
reducedOut.push_back(std::move(p));
}
for (auto& mono : monomials)
monoid().freeRaw(mono.castAwayConst());
}