Changeset 1e6de6 in git for factory/int_poly.cc


Ignore:
Timestamp:
Jan 7, 2008, 2:33:11 PM (16 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
aa7480c120ef293aaf5a185ec38a2440c23fc879
Parents:
6840b2040b65b549b02b0e852339ab1a0a791484
Message:
*hannes: some optimizations(gcd)


git-svn-id: file:///usr/local/Singular/svn/trunk@10489 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/int_poly.cc

    r6840b2 r1e6de6  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: int_poly.cc,v 1.19 2006-09-15 10:15:48 Singular Exp $ */
     2/* $Id: int_poly.cc,v 1.20 2008-01-07 13:33:10 Singular Exp $ */
    33
    44#include <config.h>
     
    11401140    if ( aTermList == 0 )
    11411141        return 0;
    1142     else  if ( negate ) {
     1142    else  if ( negate )
     1143    {
    11431144        termList sourceCursor = aTermList;
    11441145        termList dummy = new term;
    11451146        termList targetCursor = dummy;
    11461147
    1147         while ( sourceCursor ) {
     1148        while ( sourceCursor )
     1149        {
    11481150            targetCursor->next = new term( 0, -sourceCursor->coeff, sourceCursor->exp );
    11491151            targetCursor = targetCursor->next;
     
    11561158        return targetCursor;
    11571159    }
    1158     else {
     1160    else
     1161    {
    11591162        termList sourceCursor = aTermList;
    11601163        termList dummy = new term;
    11611164        termList targetCursor = dummy;
    11621165
    1163         while ( sourceCursor ) {
     1166        while ( sourceCursor )
     1167        {
    11641168            targetCursor->next = new term( 0, sourceCursor->coeff, sourceCursor->exp );
    11651169            targetCursor = targetCursor->next;
     
    11791183    if ( aTermList == 0 )
    11801184        return 0;
    1181     else {
     1185    else
     1186    {
    11821187        termList sourceCursor = aTermList;
    11831188        termList dummy = new term;
    11841189        termList targetCursor = dummy;
    11851190
    1186         while ( sourceCursor ) {
     1191        while ( sourceCursor )
     1192        {
    11871193            targetCursor->next = new term( 0, sourceCursor->coeff.deepCopy(), sourceCursor->exp );
    11881194            targetCursor = targetCursor->next;
     
    12021208    termList cursor = aTermList;
    12031209
    1204     while ( cursor ) {
     1210    while ( cursor )
     1211    {
    12051212        cursor = cursor->next;
    12061213        delete aTermList;
     
    12131220{
    12141221    termList cursor = terms;
    1215     while ( cursor ) {
     1222    while ( cursor )
     1223    {
    12161224        cursor->coeff = -cursor->coeff;
    12171225        cursor = cursor->next;
     
    12261234    termList predCursor = 0;
    12271235
    1228     while ( theCursor && aCursor ) {
    1229         if ( theCursor->exp == aCursor->exp ) {
     1236    while ( theCursor && aCursor )
     1237    {
     1238        if ( theCursor->exp == aCursor->exp )
     1239        {
    12301240            if ( negate )
    12311241                theCursor->coeff -= aCursor->coeff;
    12321242            else
    12331243                theCursor->coeff += aCursor->coeff;
    1234             if ( theCursor->coeff.isZero() ) {
    1235                 if ( predCursor ) {
     1244            if ( theCursor->coeff.isZero() )
     1245            {
     1246                if ( predCursor )
     1247                {
    12361248                    predCursor->next = theCursor->next;
    12371249                    delete theCursor;
    12381250                    theCursor = predCursor->next;
    12391251                }
    1240                 else {
     1252                else
     1253                {
    12411254                    theList = theList->next;
    12421255                    delete theCursor;
     
    12441257                }
    12451258            }
    1246             else {
     1259            else
     1260            {
    12471261                predCursor = theCursor;
    12481262                theCursor = theCursor->next;
     
    12501264            aCursor = aCursor->next;
    12511265        }
    1252         else if ( theCursor->exp < aCursor->exp ) {
     1266        else if ( theCursor->exp < aCursor->exp )
     1267        {
    12531268            if ( negate )
    1254                 if ( predCursor ) {
     1269                if ( predCursor )
     1270                {
    12551271                    predCursor->next = new term( theCursor, -aCursor->coeff, aCursor->exp );
    12561272                    predCursor = predCursor->next;
    12571273                }
    1258                 else {
     1274                else
     1275                {
    12591276                    theList = new term( theCursor, -aCursor->coeff, aCursor->exp );
    12601277                    predCursor = theList;
    12611278                }
    12621279            else
    1263                 if ( predCursor ) {
     1280                if ( predCursor )
     1281                {
    12641282                    predCursor->next = new term( theCursor, aCursor->coeff, aCursor->exp );
    12651283                    predCursor = predCursor->next;
    12661284                }
    1267                 else {
     1285                else
     1286                {
    12681287                    theList = new term( theCursor, aCursor->coeff, aCursor->exp );
    12691288                    predCursor = theList;
     
    12711290            aCursor = aCursor->next;
    12721291        }
    1273         else {
     1292        else
     1293        {
    12741294            predCursor = theCursor;
    12751295            theCursor = theCursor->next;
    12761296        }
    12771297    }
    1278     if ( aCursor ) {
     1298    if ( aCursor )
     1299    {
    12791300        if ( predCursor )
    12801301            predCursor->next = copyTermList( aCursor, lastTerm, negate );
     
    12911312InternalPoly::mulTermList ( termList theCursor, const CanonicalForm& coeff, const int exp )
    12921313{
    1293     while ( theCursor ) {
     1314    while ( theCursor )
     1315    {
    12941316        theCursor->coeff *= coeff;
    12951317        theCursor->exp += exp;
     
    13051327    termList dummy;
    13061328
    1307     while ( theCursor ) {
     1329    while ( theCursor )
     1330    {
    13081331        theCursor->coeff /= coeff;
    1309         if ( theCursor->coeff.isZero() ) {
     1332        if ( theCursor->coeff.isZero() )
     1333        {
    13101334            if ( theCursor == firstTerm )
    13111335                firstTerm = theCursor->next;
     
    13161340            delete dummy;
    13171341        }
    1318         else {
     1342        else
     1343        {
    13191344            lastTerm = theCursor;
    13201345            theCursor = theCursor->next;
     
    13311356    termList dummy;
    13321357
    1333     while ( theCursor ) {
     1358    while ( theCursor )
     1359    {
    13341360        theCursor->coeff.div( coeff );
    1335         if ( theCursor->coeff.isZero() ) {
     1361        if ( theCursor->coeff.isZero() )
     1362        {
    13361363            if ( theCursor == firstTerm )
    13371364                firstTerm = theCursor->next;
     
    13421369            delete dummy;
    13431370        }
    1344         else {
     1371        else
     1372        {
    13451373            lastTerm = theCursor;
    13461374            theCursor = theCursor->next;
     
    13571385    termList dummy;
    13581386
    1359     while ( theCursor ) {
     1387    while ( theCursor )
     1388    {
    13601389        theCursor->coeff.mod( coeff );
    1361         if ( theCursor->coeff.isZero() ) {
     1390        if ( theCursor->coeff.isZero() )
     1391        {
    13621392            if ( theCursor == firstTerm )
    13631393                firstTerm = theCursor->next;
     
    13681398            delete dummy;
    13691399        }
    1370         else {
     1400        else
     1401        {
    13711402            lastTerm = theCursor;
    13721403            theCursor = theCursor->next;
     
    13791410InternalPoly::appendTermList ( termList& first, termList& last, const CanonicalForm& coeff, const int exp )
    13801411{
    1381     if ( last ) {
     1412    if ( last )
     1413    {
    13821414        last->next = new term( 0, coeff, exp );
    13831415        last = last->next;
    13841416    }
    1385     else {
     1417    else
     1418    {
    13861419        first = new term( 0, coeff, exp );
    13871420        last = first;
     
    14021435        coeff = c;
    14031436
    1404     while ( theCursor && aCursor ) {
    1405         if ( theCursor->exp == aCursor->exp + exp ) {
     1437    while ( theCursor && aCursor )
     1438    {
     1439        if ( theCursor->exp == aCursor->exp + exp )
     1440        {
    14061441            theCursor->coeff += aCursor->coeff * coeff;
    1407             if ( theCursor->coeff.isZero() ) {
    1408                 if ( predCursor ) {
     1442            if ( theCursor->coeff.isZero() )
     1443            {
     1444                if ( predCursor )
     1445                {
    14091446                    predCursor->next = theCursor->next;
    14101447                    delete theCursor;
    14111448                    theCursor = predCursor->next;
    14121449                }
    1413                 else {
     1450                else
     1451                {
    14141452                    theList = theList->next;
    14151453                    delete theCursor;
     
    14171455                }
    14181456            }
    1419             else {
     1457            else
     1458            {
    14201459                predCursor = theCursor;
    14211460                theCursor = theCursor->next;
     
    14231462            aCursor = aCursor->next;
    14241463        }
    1425         else if ( theCursor->exp < aCursor->exp + exp ) {
    1426             if ( predCursor ) {
     1464        else if ( theCursor->exp < aCursor->exp + exp )
     1465        {
     1466            if ( predCursor )
     1467            {
    14271468                predCursor->next = new term( theCursor, aCursor->coeff * coeff, aCursor->exp + exp );
    14281469                predCursor = predCursor->next;
    14291470            }
    1430             else {
     1471            else
     1472            {
    14311473                theList = new term( theCursor, aCursor->coeff * coeff, aCursor->exp + exp );
    14321474                predCursor = theList;
     
    14341476            aCursor = aCursor->next;
    14351477        }
    1436         else {
     1478        else
     1479        {
    14371480            predCursor = theCursor;
    14381481            theCursor = theCursor->next;
    14391482        }
    14401483    }
    1441     if ( aCursor ) {
    1442         if ( predCursor ) {
     1484    if ( aCursor )
     1485    {
     1486        if ( predCursor )
     1487        {
    14431488            predCursor->next = copyTermList( aCursor, lastTerm );
    14441489            predCursor = predCursor->next;
    14451490        }
    1446         else {
     1491        else
     1492        {
    14471493            theList = copyTermList( aCursor, lastTerm );
    14481494            predCursor = theList;
    14491495        }
    1450         while ( predCursor ) {
     1496        while ( predCursor )
     1497        {
    14511498            predCursor->exp += exp;
    14521499            predCursor->coeff *= coeff;
     
    14671514    int exp = redterms->exp;
    14681515    termList dummy;
    1469     while ( first && ( first->exp >= exp ) ) {
     1516    while ( first && ( first->exp >= exp ) )
     1517    {
    14701518        newcoeff = first->coeff / coeff;
    14711519        newexp = first->exp - exp;
Note: See TracChangeset for help on using the changeset viewer.