void main( ) { struct polynode *first, *second, *mult ; int i = 1 ; first = second = mult = NULL ; /* empty linked lists */ poly_append ( &first, 3, 5 ) ; poly_append ( &first, 2, 4 ) ; poly_append ( &first, 1, 2 ) ; display_poly ( first ) ; poly_append ( &second, 1, 6 ) ; poly_append ( &second, 2, 5 ) ; poly_append ( &second, 3, 4 ) ; printf ( "\n\n" ) ; display_poly ( second ) ; printf ( "\n" ); while ( i++ < 79 ) printf ( "-" ) ; poly_multiply ( first, second, &mult ) ; printf ( "\n\n" ) ; display_poly ( mult ) ; }
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(); }
int main( ) { struct polynode *first, *second, *total ; int i = 0 ; first = second = total = NULL ; /* empty linked lists */ poly_append ( &first, 1.4f, 5 ) ; poly_append ( &first, 1.5f, 4 ) ; poly_append ( &first, 1.7f, 2 ) ; poly_append ( &first, 1.8f, 1 ) ; poly_append ( &first, 1.9f, 0 ) ; system ( "cls" ) ; display_poly ( first ) ; poly_append ( &second, 1.5f, 6 ) ; poly_append ( &second, 2.5f, 5 ) ; poly_append ( &second, -3.5f, 4 ) ; poly_append ( &second, 4.5f, 3 ) ; poly_append ( &second, 6.5f, 1 ) ; printf ( "\n\n" ) ; display_poly ( second ) ; /* draws a dashed horizontal line */ printf ( "\n" ) ; while ( i++ < 79 ) printf ( "-" ) ; printf ( "\n\n" ) ; poly_add ( first, second, &total ) ; display_poly ( total ) ; /* displays the resultant polynomial */ return 0 ; }
bool SchreyerFrame::debugCheckOrder(int lev) const { if (lev == 0) return true; bool result = true; auto& mylevel = level(lev); auto& myorder = schreyerOrder(lev-1); int which = 0; for (auto i = mylevel.cbegin(); i != mylevel.cend(); ++i, ++which) { if (!check_poly(ring(), i->mSyzygy, myorder)) { std::cout << "Error: terms of polynomial at level " << lev << " location " << which << " not in order" << std::endl; std::cout << " poly = "; display_poly(stdin, ring(), i->mSyzygy); std::cout << std::endl; result = false; } } return result; }
bool SchreyerFrame::insertLevelOne(res_packed_monomial monom, int deg, poly& syzygy) { insertBasic(1, monom, deg); // deg is the actual degree of this element. long comp = monoid().get_component(monom); auto last = level(1).size(); auto& p = level(0)[comp]; if (p.mBegin == -1) p.mBegin = last-1; p.mEnd = last; if (!check_poly(ring(), syzygy, schreyerOrder(0))) { if (M2_gbTrace >= 1) { std::cout << "Error: expected terms of polynomial to be in order, in poly#" << last << ": "; display_poly(stdout, ring(), syzygy); std::cout << std::endl; } return false; } std::swap(level(1)[level(1).size()-1].mSyzygy, syzygy); return true; }