Changeset 9d6bf4 in git for libfac/charset/alg_factor.cc


Ignore:
Timestamp:
Jul 3, 2012, 1:50:59 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
cd81417ddd6d2d3d0d2f8b3b8f109992056f2920
Parents:
18500b278c2d1587c78c8502e401e80745031231
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2012-07-03 13:50:59+02:00
git-committer:
Martin Lee <martinlee84@web.de>2012-08-03 10:03:18+02:00
Message:
chg: Factorize -> factorize, p1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfac/charset/alg_factor.cc

    r18500b r9d6bf4  
    22// emacs edit mode for this file is -*- C++ -*-
    33////////////////////////////////////////////////////////////
    4 ////////////////////////////////////////////////////////////
     4
    55// FACTORY - Includes
    66#include <factory.h>
     
    8080// replacement for factory's broken psr
    8181static CanonicalForm
    82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){
     82mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x )
     83{
    8384  CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue;
    8485  int dr, dv, d,n=0;
     
    104105// replacement for factory's broken resultant
    105106static CanonicalForm
    106 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){
     107resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v )
     108{
    107109  bool on_rational = isOn(SW_RATIONAL);
    108110  On(SW_RATIONAL);
     
    113115  if (!on_rational)  Off(SW_RATIONAL);
    114116
    115 return resultant(fz,gz,v);
     117  return resultant(fz,gz,v);
    116118}
    117119
     
    133135sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    134136           CFGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    135            CanonicalForm & R){
     137           CanonicalForm & R)
     138{
    136139  Variable y=PPalpha.mvar(),vf=f.mvar();
    137140  CanonicalForm temp, Palpha=PPalpha, t;
     
    147150
    148151  // Norm, resultante taken with respect to y
    149   while ( !sqfreetest ){
     152  while ( !sqfreetest )
     153  {
    150154    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
    151155    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
     
    169173      if (getAlgVar(R,X))
    170174      {
    171         if (R.isUnivariate())
    172175          testlist=factorize( R, X );
    173         else
    174           testlist= Factorize(R, X, 0);
    175176      }
    176177      else
     
    198199sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    199200           AlgExtGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    200            CanonicalForm & R){
     201           CanonicalForm & R)
     202{
    201203  Variable y=PPalpha.mvar(),vf=f.mvar();
    202204  CanonicalForm temp, Palpha=PPalpha, t;
     
    225227      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
    226228    }
    227     else{
     229    else
     230    {
    228231      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    229232      // Look at SqrFreeTest!
     
    234237      if (getAlgVar(R,X))
    235238      {
    236         if (R.isUnivariate())
    237239          testlist=factorize( R, X );
    238         else
    239           testlist= Factorize(R, X, 0);
    240240      }
    241241      else
     
    248248      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
    249249    }
    250     if ( ! sqfreetest ){
     250    if ( ! sqfreetest )
     251    {
    251252      myrandom.next();
    252253      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
     
    264265sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha,
    265266           const Variable & Extension, CanonicalForm & s,  CanonicalForm & g,
    266            CanonicalForm & R){
    267 
     267           CanonicalForm & R)
     268{
    268269  DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
    269270  DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
    270   if ( getCharacteristic() == 0 ) {
     271  if ( getCharacteristic() == 0 )
     272  {
    271273    IntGenerator myrandom;
    272274    DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0");
     
    278280    DEBOUTLN(CERR, "sqrf_norm:      R= ", R);
    279281  }
    280   else if ( degree(Extension) > 0 ){ // working over Extensions
     282  else if ( degree(Extension) > 0 ) // working over Extensions
     283  {
    281284    DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension));
    282285    AlgExtGenerator myrandom(Extension);
    283286    sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R);
    284287  }
    285   else{
     288  else
     289  {
    286290    FFGenerator myrandom;
    287291    DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0");
     
    296300  Variable x;
    297301
    298   for ( VarlistIterator i=uord; i.hasItem(); i++){
     302  for ( VarlistIterator i=uord; i.hasItem(); i++)
     303  {
    299304    x=i.getItem();
    300     for ( CFListIterator j=Astar; j.hasItem(); j++ ){
     305    for ( CFListIterator j=Astar; j.hasItem(); j++ )
     306    {
    301307      elem= j.getItem();
    302       if ( degree(elem,x) > 0 ){ // x actually occures in Astar
     308      if ( degree(elem,x) > 0 ) // x actually occures in Astar
     309      {
    303310        output.append(x);
    304311        break;
     
    312319// Must be a power of p: i.e. y^{p^e}-x
    313320static int
    314 inseperable(const CFList & Astar){
     321inseperable(const CFList & Astar)
     322{
    315323  CanonicalForm elem;
    316324  int Counter= 1;
    317325
    318326  if ( Astar.length() == 0 ) return 0;
    319   for ( CFListIterator i=Astar; i.hasItem(); i++){
     327  for ( CFListIterator i=Astar; i.hasItem(); i++)
     328  {
    320329    elem= i.getItem();
    321330    if ( elem.deriv() == elem.genZero() ) return Counter;
     
    327336// calculate gcd of f and g in char=0
    328337static CanonicalForm
    329 gcd0( CanonicalForm f, CanonicalForm g ){
     338gcd0( CanonicalForm f, CanonicalForm g )
     339{
    330340  int charac= getCharacteristic();
    331341  int save=isOn(SW_RATIONAL);
     
    333343  CanonicalForm ff= mapinto(f), gg= mapinto(g);
    334344  CanonicalForm result= gcd(ff,gg);
    335   setCharacteristic(charac); 
     345  setCharacteristic(charac);
    336346  if (save) On(SW_RATIONAL);
    337347  return mapinto(result);
     
    344354// have enough elements to plug in.
    345355static int
    346 getextension( IntList & degreelist, int n){
     356getextension( IntList & degreelist, int n)
     357{
    347358  int charac= getCharacteristic();
    348359  setCharacteristic(0); // need it for k !
     
    543554
    544555static CFFList
    545 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){
     556endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord )
     557{
    546558  CanonicalForm F=f, g, q,r;
    547559  CFFList Output;
     
    551563  Variable vg;
    552564
    553   for (i=as; i.hasItem(); i++){
     565  for (i=as; i.hasItem(); i++)
     566  {
    554567    g= i.getItem();
    555     if (g.deriv() == 0 ){
     568    if (g.deriv() == 0 )
     569    {
    556570      DEBOUTLN(CERR, "Inseperable extension detected: ", g);
    557       for (j=uord; j.hasItem(); j++){
     571      for (j=uord; j.hasItem(); j++)
     572      {
    558573        if ( degree(g,j.getItem()) > 0 ) vg= j.getItem();
    559574      }
     
    568583      // Now transform all remaining polys in as:
    569584      int x=0;
    570       for (ii=i; ii.hasItem(); ii++){
    571         if ( x != 0 ){
     585      for (ii=i; ii.hasItem(); ii++)
     586      {
     587        if ( x != 0 )
     588        {
    572589          divrem(ii.getItem(), gg, q,r);
    573590//          CERR << ii.getItem() << " divided by " << gg << "\n";
     
    595612
    596613  // Transform back:
    597   for ( CFFListIterator k=factorlist; k.hasItem(); k++){
     614  for ( CFFListIterator k=factorlist; k.hasItem(); k++)
     615  {
    598616    CanonicalForm factor= k.getItem().factor();
    599617    ii=One;
    600     for (i=Two; i.hasItem(); i++){
     618    for (i=Two; i.hasItem(); i++)
     619    {
    601620      DEBOUTLN(CERR, "Mapping ", i.getItem());
    602621      DEBOUTLN(CERR, "     to ", ii.getItem());
     
    618637//           no transcendentals, seperable and inseperable extensions
    619638CFFList
    620 newfactoras( const CanonicalForm & f, const CFList & as, int &success){
     639newfactoras( const CanonicalForm & f, const CFList & as, int &success)
     640{
    621641  Variable vf=f.mvar();
    622642  CFListIterator i;
     
    751771
    752772CFFList
    753 newcfactor(const CanonicalForm & f, const CFList & as, int & success ){
     773newcfactor(const CanonicalForm & f, const CFList & as, int & success )
     774{
    754775  Off(SW_RATIONAL);
    755   CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL);
     776  CFFList Output, output, Factors=Factorize(f);
     777  On(SW_RATIONAL);
    756778  Factors.removeFirst();
    757779
     
    760782
    761783  success=1;
    762   for ( CFFListIterator i=Factors; i.hasItem(); i++ ){
     784  for ( CFFListIterator i=Factors; i.hasItem(); i++ )
     785  {
    763786    output=newfactoras(i.getItem().factor(),as, success);
    764787    for ( CFFListIterator j=output; j.hasItem(); j++)
Note: See TracChangeset for help on using the changeset viewer.