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; }
std::shared_ptr<raytracer::Primitive> Ring::toRaytracerPrimitive() const { double br = bevelRadius(); if (br == 0.0) { return ring(m_outerRadius, m_innerRadius, m_height); } else if (isAlmost(br, (m_outerRadius - m_innerRadius) / 2.0)) { auto result = std::make_shared<raytracer::Union>(); result->add(ring(m_outerRadius, m_innerRadius, m_height - 2.0 * br)); for (int sign : { -1, 1 }) { auto instance = std::make_shared<raytracer::Instance>( std::make_shared<raytracer::Torus>(m_outerRadius - br, br) ); instance->setMatrix(Matrix4d::translate(0, sign * ((m_height / 2.0) - br), 0)); result->add(instance); } return result; } else { auto result = std::make_shared<raytracer::Union>(); result->add(ring(m_outerRadius, m_innerRadius, m_height - 2.0 * br)); result->add(ring(m_outerRadius - br, m_innerRadius + br, m_height)); for (int sign : { -1, 1 }) { for (double radius : { m_outerRadius - br, m_innerRadius + br }) { auto instance = std::make_shared<raytracer::Instance>( std::make_shared<raytracer::Torus>(radius, br) ); instance->setMatrix(Matrix4d::translate(0, sign * ((m_height / 2.0) - br), 0)); result->add(instance); } } return result; } }
bool SLEvaluatorConcrete<RT>::evaluate(const DMat<RT>& inputs, DMat<RT>& outputs) { if (varsPos.size() != inputs.numRows()*inputs.numColumns()) { ERROR("inputs: the number of inputs does not match the number of entries in the inputs matrix"); std::cout << varsPos.size() << " != " << inputs.numRows()*inputs.numColumns() << std::endl; return false; } size_t i=0; for(size_t r=0; r<inputs.numRows(); r++) for(size_t c=0; c<inputs.numColumns(); c++) ring().set(values[varsPos[i++]],inputs.entry(r,c)); nIt = slp->mNodes.begin(); numInputsIt = slp->mNumInputs.begin(); inputPositionsIt = slp->mInputPositions.begin(); for (vIt = values.begin()+slp->inputCounter; vIt != values.end(); ++vIt) computeNextNode(); if (slp->mOutputPositions.size() != outputs.numRows()*outputs.numColumns()) { ERROR("outputs: the number of outputs does not match the number of entries in the outputs matrix"); std::cout << slp->mOutputPositions.size() << " != " << outputs.numRows() << " * " << outputs.numColumns() << std::endl; return false; } i=0; for(size_t r=0; r<outputs.numRows(); r++) for(size_t c=0; c<outputs.numColumns(); c++) ring().set(outputs.entry(r,c),values[ap(slp->mOutputPositions[i++])]); return true; }
// 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); }
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); }
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]); }
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; } } }
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; }
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()) ); }
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; }
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); } } }
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; }
void SLEvaluatorConcrete<RT>::computeNextNode() { ElementType& v = *vIt; switch (*nIt++) { case SLProgram::MProduct: ring().set_from_long(v,1); for (int i=0; i<*numInputsIt; i++) ring().mult(v,v,*(vIt+(*inputPositionsIt++))); numInputsIt++; break; case SLProgram::MSum: ring().set_zero(v); for (int i=0; i<*numInputsIt; i++) ring().add(v,v,*(vIt+(*inputPositionsIt++))); numInputsIt++; break; case SLProgram::Det: { int n = static_cast<int>(sqrt(*numInputsIt++)); DMat<RT> mat(ring(),n,n); for (int i=0; i<n; i++) for (int j=0; j<n; j++) ring().set(mat.entry(i,j),*(vIt+(*inputPositionsIt++))); DMatLinAlg<RT>(mat).determinant(v); } break; case SLProgram::Divide: ring().set(v,*(vIt+(*inputPositionsIt++))); ring().divide(v,v,*(vIt+(*inputPositionsIt++))); break; default: ERROR("unknown node type"); } }
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; }
void SMat<CoeffRing>::negateInPlace() // this = -this { for (size_t c = 0; c < numColumns(); c++) for (sparsevec *p = columns_[c]; p != NULL; p = p->next) ring().negate(p->coeff, p->coeff); }
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; }
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() ; }
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; }
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()); }
void SLEvaluatorConcrete<RT>::text_out(buffer& o) const { o << "SLEvaluator(slp = "; slp->text_out(o); o << ", mRing = "; ring().text_out(o); o << ")" << newline; }
void CachedNode::cursorRings(const CachedFrame* frame, WTF::Vector<WebCore::IntRect>* rings) const { rings->clear(); for (unsigned index = 0; index < mCursorRing.size(); index++) rings->append(ring(frame, index)); }
void QgsHighlight::paintPolygon( QPainter *p, QgsPolygon polygon ) { QPolygonF poly; // just ring outlines, no fill p->setPen( mPen ); p->setBrush( Qt::NoBrush ); for ( int i = 0; i < polygon.size(); i++ ) { QPolygonF ring( polygon[i].size() + 1 ); for ( int j = 0; j < polygon[i].size(); j++ ) { ring[ j ] = toCanvasCoordinates( polygon[i][j] ) - pos(); } ring[ polygon[i].size()] = ring[ 0 ]; p->drawPolygon( ring ); if ( i == 0 ) poly = ring; else poly = poly.subtracted( ring ); } // just fill, no outline p->setPen( Qt::NoPen ); p->setBrush( mBrush ); p->drawPolygon( poly ); }
inline Polynomial<T, Structure> Polynomial<T, Structure>::pow_eq(exponent_type exponent) { const ring_type *r = ring(); AlgebraHelper::pow_eq(r, *this, exponent); delete r; return *this; }
int main(int argc, char *argv[]){ if(argc<4){ fprintf(stderr,"Error, missing args\n\t1: id (string)\n\t2: udp_port (int)\n\t3: tcp_port (int)"); } id = argv[1]; udp_port = atoi(argv[2]); tcp_port = atoi(argv[3]); getOwnIp(); int exit = 0; char* cmd = malloc(100); ip_str = IptoStr(inet_ntoa(my_ip)); //printf("%s\n",ip_str); while(!exit){ fgets(cmd,99,stdin); char *token = strsep(&cmd, " "); //printf("%s\n",cmd); //printf("test\n"); if(strcmp(token,"RING") == 0){ ring(cmd); }else if(strcmp(token, "JOIN") == 0){ //printf("test\n"); connectWELC(cmd); } } }
void SchreyerFrame::show(int len) const { std::cout << "#levels=" << mFrame.mLevels.size() << " currentLevel=" << currentLevel() << std::endl; for (int i=0; i<mFrame.mLevels.size(); i++) { auto& myframe = level(i); auto& myorder = schreyerOrder(i); if (myframe.size() == 0) continue; std::cout << "--- level " << i << " ------" << std::endl; for (int j=0; j<myframe.size(); j++) { std::cout << " " << j << " " << myframe[j].mDegree << " (" << myframe[j].mBegin << "," << myframe[j].mEnd << ") " << std::flush; std::cout << "(size:" << myframe[j].mSyzygy.len << ") ["; monoid().showAlpha(myorder.mTotalMonom[j]); std::cout << " " << myorder.mTieBreaker[j] << "] "; if (len == 0 or myframe[j].mSyzygy.len == 0) monoid().showAlpha(myframe[j].mMonom); else display_poly(stdout, ring(), myframe[j].mSyzygy); std::cout << std::endl; } } showMemoryUsage(); }
inline Polynomial<T, Structure> Polynomial<T, Structure>::mult_inv_mod(const Polynomial<T, Structure>& modulus) const { const ring_type *r = ring(); Polynomial<T> inverse = AlgebraHelper::inv_mod(r, mod(modulus), modulus); delete r; return inverse; }
Patch *SubdAccBuilder::run(SubdFace *face) { SubdFaceRing ring(face, face->edge); GregoryAccStencil stencil(&ring); float3 position[20]; computeCornerStencil(&ring, &stencil); computeEdgeStencil(&ring, &stencil); computeInteriorStencil(&ring, &stencil); ring.evaluate_stencils(position, stencil.stencil, 20); if(face->num_edges() == 3) { GregoryTrianglePatch *patch = new GregoryTrianglePatch(); memcpy(patch->hull, position, sizeof(float3)*20); return patch; } else if(face->num_edges() == 4) { GregoryQuadPatch *patch = new GregoryQuadPatch(); memcpy(patch->hull, position, sizeof(float3)*20); return patch; } assert(0); /* n-gons should have been split already */ return NULL; }
t_k *texture(t_objet obj3, t_k *k, int text) { if (text == 1) k = chess(obj3, k); else if (text == 2) k = ring(obj3, k); return (k); }
inline Polynomial<T, Structure> Polynomial<T, Structure>::pow_mod_eq(const LongInt& exponent, const Polynomial<T, Structure>& modulus) { const ring_type *r = ring(); AlgebraHelper::pow_mod_eq(r, *this, exponent, modulus); remove_zeros(); delete r; return *this; }
SLEvaluatorConcrete<RT>::SLEvaluatorConcrete(const SLEvaluatorConcrete<RT>& a) : mRing(a.ring()), values(a.values.size()) { slp = a.slp; varsPos = a.varsPos; for(auto i=values.begin(), j=a.values.begin(); i!=values.end(); ++i,++j) ring().init_set(*i,*j); }