std::vector<scigraphics::number> scigraphics::markerLogarithmPositive::marks( const interval<number> Interval ) const { if ( Interval.max() <= 0 ) return marks( interval<number>(0.1,1) ); if ( Interval.min() <= 0 ) return marks( interval<number>( Interval.max()*1e-5, Interval.max() ) ); return marksInPositiveInterval( Interval ); }
std::vector<scigraphics::number> scigraphics::markerLogarithmNegative::marks( const interval<number> Interval ) const { std::vector<number> Result; if ( Interval.min() >= 0 ) Result = marks( interval<number>(-1,-0.1) ); else if ( Interval.max() >= 0 ) Result = marks( interval<number>( Interval.min()*1e-5, Interval.min() ) ); else Result = marksInPositiveInterval( interval<number>( -Interval.min(), -Interval.max() ) ); for ( unsigned i = 0; i < Result.size(); i++ ) Result[i] *= -1; return Result; }
ZLTextMark ZLTextModel::previousMark(ZLTextMark position) const { if (marks().empty()) { return ZLTextMark(); } std::vector<ZLTextMark>::const_iterator it = std::lower_bound(marks().begin(), marks().end(), position); if (it == marks().end()) { --it; } if (*it >= position) { if (it == marks().begin()) { return ZLTextMark(); } --it; } return *it; }
void TextTier_changeLabels (I, long from, long to, const char32 *search, const char32 *replace, int use_regexp, long *nmatches, long *nstringmatches) { iam (TextTier); try { if (from == 0) { from = 1; } if (to == 0) { to = my points -> size; } if (from > to || from < 1 || to > my points -> size) { Melder_throw (U"Incorrect specification of where to act."); } if (use_regexp && str32len (search) == 0) Melder_throw (U"The regex search string cannot be empty.\n" U"You may search for an empty string with the expression \"^$\""); long nmarks = to - from + 1; autoNUMvector<char32 *> marks (1, nmarks); for (long i = from; i <= to; i++) { TextPoint point = (TextPoint) my points -> item[i]; marks[i - from + 1] = point -> mark; // Shallow copy. } autostring32vector newmarks (strs_replace (marks.peek(), 1, nmarks, search, replace, 0, nmatches, nstringmatches, use_regexp), 1, nmarks); for (long i = from; i <= to; i++) { TextPoint point = (TextPoint) my points -> item[i]; Melder_free (point -> mark); point -> mark = newmarks[i - from + 1]; // Transfer of ownership. newmarks[i - from + 1] = 0; } } catch (MelderError) { Melder_throw (me, U": no labels changed."); } }
void face(GLUquadricObj *quadObj) { glPushMatrix(); glEnable(GL_TEXTURE_2D); gluCylinder(quadObj, rTop, rTop, hFace, 50, 50); gluDisk(quadObj, 0.0, rTop, 50, 50); glDisable(GL_TEXTURE_2D); arrows(quadObj); marks(quadObj); glPopMatrix(); }
std::pair<bool, vertex_t> dfs( const adjacence_list_t & graph, size_t index ) { vertex_t vertex; marks_t marks( graph.size(), color::white ); if ( index < graph.size() ) if ( !::dfs( graph, index, marks, vertex ) ) return { false, vertex }; return { true, vertex }; }
std::pair<bool, vertex_t> topological_sort( const adjacence_list_t & graph ) { vertex_t vertex; marks_t marks( graph.size(), color::white ); for ( size_t i = 0; i < graph.size(); ++i ) if ( !::dfs( graph, i, marks, vertex ) ) return { false, vertex }; std::reverse( std::begin( vertex ), std::end( vertex ) ); return { true, vertex }; }
void ArticleView::append_data_parse_result(const gchar *real_oword, ParseResult& parse_result) { /* Why ParseResultItem's cannot be inserted into the pango_view_ in the * order they appear in the parse_result list? * * They can, but that limits use of the pango markup language when markup * intermixed with objects that are not expressed in pango markup. * For instance we cannot handle the following piece of data: * markup: "<span foreground=\"purple\">some text" * res: some image * markup: "text continues</span>" * The first markup string cannot be committed because it is not a valid * markup - span tag is not closed. But if we piece two markup strings * together, commit markup and then insert the resource, everything will be * fine. * * Here is an outline of the rules parse_result list must adhere to. * * - each list item with pango markup must contain only complete tags. Tag * may not be opened in one list item and closed in another. For example * this list is not allowed: * markup: "<span foreground=\"purple\" " * markup: "size=\"x-large\">" * * - after combining all list items with pango markup the resultant string * must constitute a valid markup (correct order of tags, each tag must have * a corresponding closing tag and so on). For example, the following text * is not allowed: "<b> bla bla </b><i>text end". * Note: list item may contain incomplete markup like "<b>text begins". * * - Delayed insert items must generate only valid markup. Items * representing images, widgets generate a pango-formated error message * if the primary object cannot be inserted. * * * Position in the pango markup string cannot be exactly specified by * character offset only. That is especially important for LabelPangoWidget * where markup is stored in a string. In order to insert delayed insert * items in the correct place it was decided to add a temporary character * in the string in the place where the delayed item must be inserted. * Temporary characters are deleted at the end. * * In addition to character offsets marks are used to specify position in * the text. Marks must be used instead of char offsets when possible. * Marks are preferred over offsets because they preserve position across * text modifications, they have a notion of right and left gravity. * In general we do not know how many character would be inserted in the * text after the call the method insert_pixbuf. Normally it is only one, * but it may be any number in case of error. * * */ Marks marks(pango_view_.get()); std::string start_mark = marks.append_mark(true); std::list<ParseResultItemWithMark> delayed_insert_list; // compose markup { std::string markup_str; int char_offset = 0; const char tmp_char = 'x'; // may be any unicode char excluding '<', '&', '>' for (std::list<ParseResultItem>::iterator it = parse_result.item_list.begin(); it != parse_result.item_list.end(); ++it) { switch (it->type) { case ParseResultItemType_mark: char_offset += xml_utf8_strlen(it->mark->pango.c_str()); markup_str += it->mark->pango; break; case ParseResultItemType_link: { /* links do not insert any text, so exact mark position is * not important. */ ParseResultItemWithMark item(&*it, char_offset); delayed_insert_list.push_back(item); char_offset += xml_utf8_strlen(it->link->pango.c_str()); markup_str += it->link->pango; break; } case ParseResultItemType_res: case ParseResultItemType_widget: { ParseResultItemWithMark item1(NULL, char_offset, true); delayed_insert_list.push_back(item1); char_offset += 1; markup_str += tmp_char; ParseResultItemWithMark item2(&*it, char_offset, true); delayed_insert_list.push_back(item2); char_offset += 1; markup_str += tmp_char; break; } case ParseResultItemType_FormatBeg: case ParseResultItemType_FormatEnd: { /* formats do not insert any text, so exact mark position is * not important. */ ParseResultItemWithMark item2(&*it, char_offset); delayed_insert_list.push_back(item2); break; } default: g_warning("Unsupported item type."); break; } } append_and_mark_orig_word(markup_str, real_oword, LinksPosList()); markup_str.clear(); pango_view_->flush(); } // Marks that precede tmp chars. One mark - one char next to it that must be // deleted. Different marks do not refer to the same char. std::list<std::string> tmp_char_mark_list; // insert marks for(std::list<ParseResultItemWithMark>::iterator it = delayed_insert_list.begin(); it != delayed_insert_list.end(); ) { it->mark = marks.insert_mark(start_mark, it->char_offset, false); if(it->tmp_char) tmp_char_mark_list.push_back(it->mark); if(it->item) ++it; else it = delayed_insert_list.erase(it); } #ifdef DDEBUG std::cout << "ArticleView::append_data_parse_result. marks inserted." << std::endl; #endif // insert delayed items for(std::list<ParseResultItemWithMark>::iterator it = delayed_insert_list.begin(); it != delayed_insert_list.end(); ) { bool EraseCurrent = true; switch(it->item->type) { case ParseResultItemType_link: pango_view_->insert_pango_text_with_links("", it->item->link->links_list, it->mark.c_str()); break; case ParseResultItemType_res: { bool loaded = false; if (it->item->res->type == "image") { append_data_res_image(it->item->res->key, it->mark, loaded); } else if (it->item->res->type == "sound") { append_data_res_sound(it->item->res->key, it->mark, loaded); } else if (it->item->res->type == "video") { append_data_res_video(it->item->res->key, it->mark, loaded); } else { append_data_res_attachment(it->item->res->key, it->mark, loaded); } if (!loaded) { std::string tmark; tmark += "<span foreground=\"red\">"; glib::CharStr m_str(g_markup_escape_text(it->item->res->key.c_str(), -1)); tmark += get_impl(m_str); tmark += "</span>"; pango_view_->insert_pango_text(tmark.c_str(), it->mark.c_str()); } break; } case ParseResultItemType_widget: pango_view_->insert_widget(it->item->widget->widget, it->mark.c_str()); break; case ParseResultItemType_FormatBeg: // change gravity of the mark it->mark = marks.clone_mark(it->mark, true); EraseCurrent = false; break; case ParseResultItemType_FormatEnd: { // find paired ParseResultItemType_FormatBeg item std::list<ParseResultItemWithMark>::reverse_iterator it2(it); for(; it2 != delayed_insert_list.rend(); ++it2) if(it2->item->type == ParseResultItemType_FormatBeg) break; if(it2 != delayed_insert_list.rend() && it2->item->format_beg->type == it->item->format_end->type) { if(it->item->format_end->type == ParseResultItemFormatType_Indent) pango_view_->indent_region(it2->mark.c_str(), 0, it->mark.c_str()); std::list<ParseResultItemWithMark>::iterator it3(it2.base()); delayed_insert_list.erase(--it3); } else g_warning("Not paired ParseResultItemType_FormatEnd item"); break; } default: g_assert_not_reached(); break; } if(EraseCurrent) it = delayed_insert_list.erase(it); else ++it; } // remove tmp chars for(std::list<std::string>::iterator it = tmp_char_mark_list.begin(); it != tmp_char_mark_list.end(); ++it) { #ifdef DDEBUG std::cout << "tmp char mark " << *it << std::endl; #endif pango_view_->delete_text(it->c_str(), 1, 0); } pango_view_->reindent(); if(!delayed_insert_list.empty()) g_warning("delayed_insert_list is not empty. " "parse_result contains not paired items."); }
ZLTextMark ZLTextModel::nextMark(ZLTextMark position) const { std::vector<ZLTextMark>::const_iterator it = std::upper_bound(marks().begin(), marks().end(), position); return (it != marks().end()) ? *it : ZLTextMark(); }
ZLTextMark ZLTextModel::lastMark() const { return marks().empty() ? ZLTextMark() : marks().back(); }
ZLTextMark ZLTextModel::firstMark() const { return marks().empty() ? ZLTextMark() : marks().front(); }
void ZLTextTreeModel::search(const std::string &text, size_t startIndex, size_t endIndex, bool ignoreCase) const { ZLTextModel::search(text, startIndex, endIndex, ignoreCase); for (std::vector<ZLTextMark>::const_iterator it = marks().begin(); it != marks().end(); ++it) { ((ZLTextTreeParagraph*)(*this)[it->ParagraphNumber])->openTree(); } }
int main() { /* factoring program using Lenstras Elliptic Curve method */ int phase,m,k,nc,iv,pos,btch,u,v; long i,p,pa,interval; big q,x,z,a,x1,z1,x2,z2,xt,zt,n,fvw; static big fu[1+MULT/2]; static BOOL cp[1+MULT/2]; mip=mirsys(30,0); q=mirvar(0); x=mirvar(0); z=mirvar(0); a=mirvar(0); x1=mirvar(0); z1=mirvar(0); x2=mirvar(0); z2=mirvar(0); n=mirvar(0); t=mirvar(0); s1=mirvar(0); d1=mirvar(0); s2=mirvar(0); d2=mirvar(0); ak=mirvar(0); xt=mirvar(0); zt=mirvar(0); fvw=mirvar(0); w=mirvar(0); gprime(LIMIT1); for (m=1;m<=MULT/2;m+=2) if (igcd(MULT,m)==1) { fu[m]=mirvar(0); cp[m]=TRUE; } else cp[m]=FALSE; printf("input number to be factored\n"); cinnum(n,stdin); if (isprime(n)) { printf("this number is prime!\n"); return 0; } prepare_monty(n); for (nc=1,k=6;k<100;k++) { /* try a new curve */ /* generating an elliptic curve */ u=k*k-5; v=4*k; convert(u,x); nres(x,x); convert(v,z); nres(z,z); nres_modsub(z,x,a); /* a=v-u */ copy(x,t); nres_modmult(x,x,x); nres_modmult(x,t,x); /* x=u^3 */ copy(z,t); nres_modmult(z,z,z); nres_modmult(z,t,z); /* z=v^3 */ copy(a,t); nres_modmult(t,t,t); nres_modmult(t,a,t); /* t=(v-u)^3 */ convert(3*u,a); nres(a,a); convert(v,ak); nres(ak,ak); nres_modadd(a,ak,a); nres_modmult(t,a,t); /* t=(v-u)^3.(3u+v) */ convert(u,a); nres(a,a); copy(a,ak); nres_modmult(a,a,a); nres_modmult(a,ak,a); /* a=u^3 */ convert(v,ak); nres(ak,ak); nres_modmult(a,ak,a); /* a=u^3.v */ nres_premult(a,16,a); nres_moddiv(t,a,ak); /* ak=(v-u)^3.(3u+v)/16u^3v */ nc++; phase=1; p=0; i=0; btch=50; printf("phase 1 - trying all primes less than %d\n",LIMIT1); printf("prime= %8ld",p); forever { /* main loop */ if (phase==1) { p=mip->PRIMES[i]; if (mip->PRIMES[i+1]==0) { /* now change gear */ phase=2; printf("\nphase 2 - trying last prime less than %ld\n", LIMIT2); printf("prime= %8ld",p); copy(x,xt); copy(z,zt); nres_modadd(x,z,s2); nres_modsub(x,z,d2); /* P = (s2,d2) */ duplication(s2,d2,x,z); nres_modadd(x,z,s1); nres_modsub(x,z,d1); /* 2.P = (s1,d1) */ nres_moddiv(x1,z1,fu[1]); /* fu[1] = x1/z1 */ addition(x1,z1,s1,d1,s2,d2,x2,z2); /* 3.P = (x2,z2) */ for (m=5;m<=MULT/2;m+=2) { /* calculate m.P = (x,z) and store fu[m] = x/z */ nres_modadd(x2,z2,s2); nres_modsub(x2,z2,d2); addition(x1,z1,s2,d2,s1,d1,x,z); copy(x2,x1); copy(z2,z1); copy(x,x2); copy(z,z2); if (!cp[m]) continue; copy(z2,fu[m]); nres_moddiv(x2,fu[m],fu[m]); } ellipse(xt,zt,MULT,x,z,x2,z2); nres_modadd(x,z,xt); nres_modsub(x,z,zt); /* MULT.P = (xt,zt) */ iv=(int)(p/MULT); if (p%MULT>MULT/2) iv++; interval=(long)iv*MULT; p=interval+1; ellipse(x,z,iv,x1,z1,x2,z2); /* (x1,z1) = iv.MULT.P */ nres_moddiv(x1,z1,fvw); /* fvw = x1/z1 */ nres_modsub(fvw,fu[p%MULT],q); marks(interval); btch*=100; i++; continue; } pa=p; while ((LIMIT1/p) > pa) pa*=p; ellipse(x,z,(int)pa,x1,z1,x2,z2); copy(x1,x); copy(z1,z); copy(z,q); } else { /* phase 2 - looking for last large prime factor of (p+1+d) */ p+=2; pos=(int)(p%MULT); if (pos>MULT/2) { /* increment giant step */ iv++; interval=(long)iv*MULT; p=interval+1; marks(interval); pos=1; nres_moddiv(x2,z2,fvw); nres_modadd(x2,z2,s2); nres_modsub(x2,z2,d2); addition(x1,z1,s2,d2,xt,zt,x,z); copy(x2,x1); copy(z2,z1); copy(x,x2); copy(z,z2); } if (!cp[pos]) continue; /* if neither interval +/- pos is prime, don't bother */ if (!plus[pos] && !minus[pos]) continue; nres_modsub(fvw,fu[pos],t); nres_modmult(q,t,q); } if (i++%btch==0) { /* try for a solution */ printf("\b\b\b\b\b\b\b\b%8ld",p); fflush(stdout); egcd(q,n,t); if (size(t)==1) { if (p>LIMIT2) break; else continue; } if (compare(t,n)==0) { printf("\ndegenerate case"); break; } printf("\nfactors are\n"); if (isprime(t)) printf("prime factor "); else printf("composite factor "); cotnum(t,stdout); divide(n,t,n); if (isprime(n)) printf("prime factor "); else printf("composite factor "); cotnum(n,stdout); return 0; } } if (nc>NCURVES) break; printf("\ntrying a different curve %d\n",nc); } printf("\nfailed to factor\n"); return 0; }
/*! \return Whether a given mark has been set on the line */ bool QDocumentLine::hasMark(int id) const { return marks().contains(id); }
void PreviewRuler::paintEvent( QPaintEvent * event ) { Q_UNUSED( event ); Q_ASSERT( m_renderer ); QPainter painter( this ); QRect marks( 0, 3, width() - 1, MARK_LARGE + 1 ); painter.setPen( QPen( QColor( 50, 50, 50 ) ) ); painter.setBrush( QBrush( QColor( 50, 50, 50 ) ) ); painter.drawRect( marks ); if ( m_renderer->getLength() > 0 ) { qreal linesToDraw = 0; qreal spacing = 0; QRect r = marks.adjusted( 1, 0, -1, 0 ); // Draw the marks if ( r.width() / 2 >= m_renderer->getLength() ) { // Every frame painter.setPen( QPen( Qt::cyan ) ); linesToDraw = (qreal)m_renderer->getLength(); if ( linesToDraw > 0 ) { spacing = (qreal)r.width() / linesToDraw; for ( int step = 0; step < linesToDraw; ++step ) painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_XSMALL, r.left() + step * spacing, r.bottom() ) ); } } if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() ) ) { // Every second painter.setPen( QPen( Qt::green ) ); linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps(); if ( linesToDraw > 0 ) { spacing = (qreal)r.width() / linesToDraw; for ( int step = 0; step < linesToDraw; ++step ) painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_XSMALL, r.left() + step * spacing, r.bottom() ) ); } } else if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 12 ) ) { // Every 5 seconds painter.setPen( QPen( Qt::green ) ); linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 12; if ( linesToDraw > 0 ) { spacing = (qreal)r.width() / linesToDraw; for ( int step = 0; step < linesToDraw; ++step ) painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_SMALL, r.left() + step * spacing, r.bottom() ) ); } } if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 ) ) { // Every minute painter.setPen( QPen( Qt::yellow ) ); linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60; if ( linesToDraw > 0 ) { spacing = (qreal)r.width() / linesToDraw; for ( int step = 0; step < linesToDraw; ++step ) painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_MEDIUM, r.left() + step * spacing, r.bottom() ) ); } } else if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 / 12 ) ) { // Every 5 minutes painter.setPen( QPen( Qt::yellow ) ); linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60 / 12; if ( linesToDraw > 0 ) { spacing = (qreal)r.width() / linesToDraw; for ( int step = 0; step < linesToDraw; ++step ) painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_MEDIUM, r.left() + step * spacing, r.bottom() ) ); } } if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 / 60 ) ) { // Every hour painter.setPen( QPen( Qt::red ) ); linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60 / 60; if ( linesToDraw > 0 ) { spacing = (qreal)r.width() / linesToDraw; for ( int step = 0; step < linesToDraw; ++step ) painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_LARGE, r.left() + step * spacing, r.bottom() ) ); } } // Draw the markers (if any) painter.setPen( QPen( Qt::green, 2 ) ); if ( m_markerStart > MARKER_DEFAULT ) { int markerPos = m_markerStart * width() / m_renderer->getLength(); QPolygon marker( 4 ); marker.setPoints( 4, markerPos + 8, 1, markerPos, 1, markerPos, 20, markerPos + 8, 20 ); painter.drawPolyline( marker ); } if ( m_markerStop > MARKER_DEFAULT ) { int markerPos = m_markerStop * width() / m_renderer->getLength(); QPolygon marker( 4 ); marker.setPoints( 4, markerPos - 8, 1, markerPos, 1, markerPos, 20, markerPos - 8, 20 ); painter.drawPolyline( marker ); } } // Draw the pointer painter.setRenderHint( QPainter::Antialiasing ); painter.setPen( QPen( Qt::white ) ); QPolygon cursor( 3 ); int cursorPos; if ( m_renderer->getLength() > 0 ) { cursorPos = m_frame * width() / m_renderer->getLength(); } else cursorPos = 0; cursorPos = qMin( qMax( cursorPos, 0 ), width() ); cursor.setPoints( 3, cursorPos - 5, 20, cursorPos + 5, 20, cursorPos, 9 ); painter.setBrush( QBrush( QColor( 26, 82, 225, 255 ) ) ); painter.drawPolygon( cursor ); }
int main() { /* factoring program using Williams (p+1) method */ int k,phase,m,nt,iv,pos,btch; long i,p,pa,interval; big b,q,n,fp,fvw,fd,fn,t; static big fu[1+MULT/2]; static BOOL cp[1+MULT/2]; mip=mirsys(30,0); b=mirvar(0); q=mirvar(0); n=mirvar(0); t=mirvar(0); fp=mirvar(0); fvw=mirvar(0); fd=mirvar(0); fn=mirvar(0); gprime(LIMIT1); for (m=1;m<=MULT/2;m+=2) if (igcd(MULT,m)==1) { fu[m]=mirvar(0); cp[m]=TRUE; } else cp[m]=FALSE; printf("input number to be factored\n"); cinnum(n,stdin); if (isprime(n)) { printf("this number is prime!\n"); return 0; } for (nt=0,k=3;k<10;k++) { /* try more than once for p+1 condition (may be p-1) */ convert(k,b); /* try b=3,4,5.. */ convert((k*k-4),t); if (egcd(t,n,t)!=1) continue; /* check (b*b-4,n)!=0 */ nt++; phase=1; p=0; btch=50; i=0; printf("phase 1 - trying all primes less than %d\n",LIMIT1); printf("prime= %8ld",p); forever { /* main loop */ if (phase==1) { /* looking for all factors of p+1 < LIMIT1 */ p=mip->PRIMES[i]; if (mip->PRIMES[i+1]==0) { /* now change gear */ phase=2; printf("\nphase 2 - trying last prime less than %ld\n" ,LIMIT2); printf("prime= %8ld",p); copy(b,fu[1]); copy(b,fp); mad(b,b,b,n,n,fd); decr(fd,2,fd); negify(b,t); mad(fd,b,t,n,n,fn); for (m=5;m<=MULT/2;m+=2) { /* store fu[m] = Vm(b) */ negify(fp,t); mad(fn,fd,t,n,n,t); copy(fn,fp); copy(t,fn); if (!cp[m]) continue; copy(t,fu[m]); } convert(MULT,t); lucas(b,t,n,fp,fd); iv=(int)(p/MULT); if (p%MULT>MULT/2) iv++; interval=(long)iv*MULT; p=interval+1; convert(iv,t); lucas(fd,t,n,fp,fvw); negify(fp,fp); subtract(fvw,fu[p%MULT],q); marks(interval); btch*=100; i++; continue; } pa=p; while ((LIMIT1/p) > pa) pa*=p; convert((int)pa,t); lucas(b,t,n,fp,q); copy(q,b); decr(q,2,q); } else { /* phase 2 - looking for last large prime factor of (p+1) */ p+=2; pos=(int)(p%MULT); if (pos>MULT/2) { /* increment giant step */ iv++; interval=(long)iv*MULT; p=interval+1; marks(interval); pos=1; copy(fvw,t); mad(fvw,fd,fp,n,n,fvw); negify(t,fp); } if (!cp[pos]) continue; /* if neither interval+/-pos is prime, don't bother */ if (!plus[pos] && !minus[pos]) continue; subtract(fvw,fu[pos],t); mad(q,t,t,n,n,q); /* batching gcds */ } if (i++%btch==0) { /* try for a solution */ printf("\b\b\b\b\b\b\b\b%8ld",p); fflush(stdout); egcd(q,n,t); if (size(t)==1) { if (p>LIMIT2) break; else continue; } if (compare(t,n)==0) { printf("\ndegenerate case"); break; } printf("\nfactors are\n"); if (isprime(t)) printf("prime factor "); else printf("composite factor "); cotnum(t,stdout); divide(n,t,n); if (isprime(n)) printf("prime factor "); else printf("composite factor "); cotnum(n,stdout); return 0; } } if (nt>=NTRYS) break; printf("\ntrying again\n"); } printf("\nfailed to factor\n"); return 0; }