Changeset d5cdf33 in git for libpolys/polys/clapsing.cc


Ignore:
Timestamp:
Sep 13, 2013, 2:15:30 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
4154bbc120e4fa4e98cdea1ae5c4cbb3e65e843aebf4609b3438506fccde45026d6628e1b7c7536a
Parents:
7627f67da8dc2c135f659c4e3f2ef25e3de4f00ebcaedabde8a91586f1c53635c29757100a6804ba
Message:
Merge pull request #371 from mmklee/cancellation

Cancellation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/clapsing.cc

    r7627f6 rd5cdf33  
    147147}
    148148
    149 void singclap_gcd_and_divide ( poly& f, poly& g, const ring r)
     149poly singclap_gcd_and_divide ( poly& f, poly& g, const ring r)
    150150{
    151151  poly res=NULL;
    152152
    153   if (f!=NULL) p_Cleardenom(f, r);
    154   if (g!=NULL) p_Cleardenom(g, r);
    155   else         return; // g==0 => but do a p_Cleardenom(f)
    156   if (f==NULL) return; // f==0 => but do a p_Cleardenom(g)
     153  if (g == NULL)
     154  {
     155    res= p_Copy (f,r);
     156    p_Delete (&f, r);
     157    f=p_One (r);
     158    return res;
     159  }
     160  if (f==NULL)
     161  {
     162    res= p_Copy (g,r);
     163    p_Delete (&g, r);
     164    g=p_One (r);
     165    return res;
     166  }
    157167
    158168  Off(SW_RATIONAL);
     
    169179      p_Delete(&f,r);
    170180      p_Delete(&g,r);
    171       f=convFactoryPSingP( F/GCD, r);
    172       g=convFactoryPSingP( G/GCD, r);
    173     }
     181      if (getCharacteristic() == 0)
     182        On (SW_RATIONAL);
     183      F /= GCD;
     184      G /= GCD;
     185      if (getCharacteristic() == 0)
     186      {
     187        CanonicalForm denF= bCommonDen (F);
     188        CanonicalForm denG= bCommonDen (G);
     189        G *= denG;
     190        F *= denF;
     191        Off (SW_RATIONAL);
     192        CanonicalForm gcddenFdenG= gcd (denG, denF);
     193        denG /= gcddenFdenG;
     194        denF /= gcddenFdenG;
     195        On (SW_RATIONAL);
     196        G *= denF;
     197        F *= denG;
     198      }
     199      f=convFactoryPSingP( F, r);
     200      g=convFactoryPSingP( G, r);
     201    }
     202    res=convFactoryPSingP( GCD , r);
    174203    if (!b1) Off (SW_USE_EZGCD_P);
    175204  }
     
    193222        p_Delete(&f,r);
    194223        p_Delete(&g,r);
    195         f= convFactoryAPSingAP( F/GCD,r );
    196         g= convFactoryAPSingAP( G/GCD,r );
    197       }
     224        if (getCharacteristic() == 0)
     225          On (SW_RATIONAL);
     226        F /= GCD;
     227        G /= GCD;
     228        if (getCharacteristic() == 0)
     229        {
     230          CanonicalForm denF= bCommonDen (F);
     231          CanonicalForm denG= bCommonDen (G);
     232          G *= denG;
     233          F *= denF;
     234          Off (SW_RATIONAL);
     235          CanonicalForm gcddenFdenG= gcd (denG, denF);
     236          denG /= gcddenFdenG;
     237          denF /= gcddenFdenG;
     238          On (SW_RATIONAL);
     239          G *= denF;
     240          F *= denG;
     241        }
     242        f= convFactoryAPSingAP( F,r );
     243        g= convFactoryAPSingAP( G,r );
     244      }
     245      res= convFactoryAPSingAP( GCD,r );
    198246      if (!b1) Off(SW_USE_QGCD);
    199247    }
     
    207255        p_Delete(&f,r);
    208256        p_Delete(&g,r);
    209         f= convFactoryPSingTrP( F/GCD,r );
    210         g= convFactoryPSingTrP( G/GCD,r );
    211       }
     257        if (getCharacteristic() == 0)
     258          On (SW_RATIONAL);
     259        F /= GCD;
     260        G /= GCD;
     261        if (getCharacteristic() == 0)
     262        {
     263          CanonicalForm denF= bCommonDen (F);
     264          CanonicalForm denG= bCommonDen (G);
     265          G *= denG;
     266          F *= denF;
     267          Off (SW_RATIONAL);
     268          CanonicalForm gcddenFdenG= gcd (denG, denF);
     269          denG /= gcddenFdenG;
     270          denF /= gcddenFdenG;
     271          On (SW_RATIONAL);
     272          G *= denF;
     273          F *= denG;
     274        }
     275        f= convFactoryPSingTrP( F,r );
     276        g= convFactoryPSingTrP( G,r );
     277      }
     278      res= convFactoryPSingTrP( GCD,r );
    212279    }
    213280  }
     
    215282    WerrorS( feNotImplemented );
    216283  Off(SW_RATIONAL);
     284  return res;
    217285}
    218286
Note: See TracChangeset for help on using the changeset viewer.