Changeset 806c18 in git


Ignore:
Timestamp:
Nov 15, 2010, 4:34:57 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
Children:
7c3bca08c96331a56864c1d35b8c2e8ff2e0be89
Parents:
c840d97af622b4e4da8761738b540e21144f716b
Message:
format

git-svn-id: file:///usr/local/Singular/svn/trunk@13655 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
69 edited

Legend:

Unmodified
Added
Removed
  • factory/DegreePattern.cc

    rc840d9 r806c18  
    11/*****************************************************************************\
    2  * Computer Algebra System SINGULAR   
     2 * Computer Algebra System SINGULAR
    33\*****************************************************************************/
    44/** @file DegreePattern.cc
    5  * 
    6  * This file provides functions for manipulating DegreePatterns     
     5 *
     6 * This file provides functions for manipulating DegreePatterns
    77 *
    88 * @author Martin Lee
     
    1515#include <config.h>
    1616
    17 #include "DegreePattern.h" 
     17#include "DegreePattern.h"
    1818#include "cf_iter.h"
    1919#include "ftmpl_functions.h"
     
    2121
    2222
    23 DegreePattern::DegreePattern (const CFList& l) 
    24 { 
     23DegreePattern::DegreePattern (const CFList& l)
     24{
    2525  m_data = NULL;
    2626
     
    2929  else
    3030  {
    31  
     31
    3232  Variable x= Variable (1);
    3333  int p= getCharacteristic();
     
    4242  int j= 0;
    4343  for (CFIterator i= buf; i.hasTerms(); i++, j++)
    44     ; 
     44    ;
    4545
    4646  ASSERT ( j > 1, "j > 1 expected" );
    47  
     47
    4848  m_data = new Pattern( j - 1 );
    4949
     
    6262void DegreePattern::intersect (const DegreePattern& degPat)
    6363{
    64   if (degPat.getLength() < getLength()) 
     64  if (degPat.getLength() < getLength())
    6565  {
    6666    DegreePattern bufDeg= *this;
     
    7272  int length= tmin (getLength(), degPat.getLength());
    7373  int* buf= new int [length];
    74   for (int i= 0; i < length; i++) 
     74  for (int i= 0; i < length; i++)
    7575  {
    76     if (degPat.find ((*this)[i])) 
    77     { 
     76    if (degPat.find ((*this)[i]))
     77    {
    7878      buf[i]= (*this)[i];
    7979      count++;
     
    8686  init (count);
    8787  count= 0;
    88   for (int i= 0; i < length; i++) 
     88  for (int i= 0; i < length; i++)
    8989  {
    90     if (buf[i] != -1) 
     90    if (buf[i] != -1)
    9191    {
    9292      (*this) [count]= buf[i];
     
    9696  delete[] buf;
    9797}
    98    
     98
    9999void DegreePattern::refine ()
    100100{
     
    107107  for (int i= 0; i < getLength(); i++)
    108108    buf[i]= -1;
    109   for (int i= 1; i < getLength(); i++) 
     109  for (int i= 1; i < getLength(); i++)
    110110  {
    111111    pos= (*this).find (d - (*this)[i]);
    112     if (pos) 
    113     { 
     112    if (pos)
     113    {
    114114      buf[i]= (*this)[i];
    115115      count++;
     
    127127  init (count);
    128128  count= 0;
    129   for (int i= 0; i < length; i++) 
     129  for (int i= 0; i < length; i++)
    130130  {
    131     if (buf[i] != -1) 
     131    if (buf[i] != -1)
    132132    {
    133133      (*this)[count]= buf[i];
  • factory/DegreePattern.h

    rc840d9 r806c18  
    11/*****************************************************************************\
    2  * Computer Algebra System SINGULAR   
     2 * Computer Algebra System SINGULAR
    33\*****************************************************************************/
    44/** @file DegreePattern.h
    5  * 
    6  * This file provides a class to handle degree patterns.           
     5 *
     6 * This file provides a class to handle degree patterns.
    77 *
    88 * @author Martin Lee
     
    2525
    2626/** @class DegreePattern DegreePattern.h "factory/DegreePattern.h"
    27  * 
     27 *
    2828 * DegreePattern provides a functionality to create, intersect and refine
    2929 * degree patterns.
    3030 *
    31  * 
     31 *
    3232 */
    3333class DegreePattern
     
    5252    ASSERT ( m_data != NULL, "non-null pointer expected");
    5353    ASSERT ( m_data->m_refCounter == 0, "ref count of 0 expected");
    54     if( m_data->m_pattern != NULL ) 
     54    if( m_data->m_pattern != NULL )
    5555      delete[] m_data->m_pattern;
    5656    m_data->m_pattern = NULL;
    57    
     57
    5858    delete m_data;
    5959    m_data = NULL;
     
    6767    if( (--m_data->m_refCounter) < 1 )
    6868      release();
    69    
     69
    7070    m_data = new Pattern(n);
    7171  }
     
    9494  /// operator []
    9595  ///
    96   /// @return @a operator[] returns the element at @a index 
     96  /// @return @a operator[] returns the element at @a index
    9797  inline int operator[] (const int index ///< [in] some int >= 0, < getLength()
    9898                        ) const
     
    106106  /// operator []
    107107  ///
    108   /// @return @a operator[] sets the element at @a index 
     108  /// @return @a operator[] sets the element at @a index
    109109  inline int& operator[] (const int index ///< [in] some int >= 0, < getLength()
    110110                         )
     
    121121  /// copy constructor
    122122  DegreePattern (const DegreePattern& degPat ///< [in] some degree pattern
    123                 ): m_data( degPat.m_data ) 
     123                ): m_data( degPat.m_data )
    124124  {
    125125    ASSERT( degPat.m_data != NULL, "non-null pointer expected"  );
     
    130130  DegreePattern (const CFList& l ///< [in] some list of (univariate) polys
    131131                );
    132  
     132
    133133  /// assignment
    134134  DegreePattern& operator= (const DegreePattern& degPat ///< [in] some degree
     
    148148
    149149  /// destructor
    150   ~DegreePattern () 
     150  ~DegreePattern ()
    151151  {
    152152    ASSERT( m_data !=  NULL, "non-null pointer expected"  );
    153     if( (--m_data->m_refCounter) < 1 ) 
     153    if( (--m_data->m_refCounter) < 1 )
    154154      release();
    155155  }
    156156
    157   /// find an element @a x 
     157  /// find an element @a x
    158158  ///
    159   /// @return @a find returns the index + 1 of @a x, if @a x is an element of 
     159  /// @return @a find returns the index + 1 of @a x, if @a x is an element of
    160160  ///         the degree pattern, 0 otherwise
    161161  int find (const int x ///< [in] some int
     
    167167    return 0;
    168168  };
    169  
    170   /// intersect two degree patterns 
     169
     170  /// intersect two degree patterns
    171171  void intersect (const DegreePattern& degPat ///< [in] some degree pattern
    172172                 );
    173173  /// Refine a degree pattern. Assumes that (*this)[0]:= @a d is the degree
    174174  /// of the poly to be factored. Now for every other entry @a a there should be
    175   /// some entry @a b such that @a a+b= d. Elements which do not satisfy this 
     175  /// some entry @a b such that @a a+b= d. Elements which do not satisfy this
    176176  /// relation are removed.
    177177  void refine ();
  • factory/ExtensionInfo.cc

    rc840d9 r806c18  
    11/*****************************************************************************\
    2  * Computer Algebra System SINGULAR   
     2 * Computer Algebra System SINGULAR
    33\*****************************************************************************/
    44/** @file ExtensionInfo.cc
    5  * 
    6  * This file provides member functions for ExtensionInfo     
     5 *
     6 * This file provides member functions for ExtensionInfo
    77 *
    88 * @author Martin Lee
     
    2828}
    2929
    30 ExtensionInfo::ExtensionInfo (const Variable& alpha, const Variable& beta, 
    31                               const CanonicalForm& gamma, const CanonicalForm& 
     30ExtensionInfo::ExtensionInfo (const Variable& alpha, const Variable& beta,
     31                              const CanonicalForm& gamma, const CanonicalForm&
    3232                              delta, const int nGFDegree, const char cGFName,
    3333                              const bool extension)
     
    4242}
    4343
    44 ExtensionInfo::ExtensionInfo (const Variable& alpha, const Variable& beta, 
    45                               const CanonicalForm& gamma, const CanonicalForm& 
     44ExtensionInfo::ExtensionInfo (const Variable& alpha, const Variable& beta,
     45                              const CanonicalForm& gamma, const CanonicalForm&
    4646                              delta)
    4747{
     
    6666}
    6767
     68#if 0
    6869ExtensionInfo::ExtensionInfo (const Variable& alpha)
    6970{
     
    7677  m_extension= true;
    7778}
     79#endif
    7880
    7981ExtensionInfo::ExtensionInfo (const int nGFDegree, const char cGFName, const
  • factory/ExtensionInfo.h

    rc840d9 r806c18  
    11/*****************************************************************************\
    2  * Computer Algebra System SINGULAR   
     2 * Computer Algebra System SINGULAR
    33\*****************************************************************************/
    44/** @file ExtensionInfo.h
    5  * 
     5 *
    66 * This file provides a class to store information about finite fields and
    7  * extensions thereof.   
    8  *         
     7 * extensions thereof.
     8 *
    99 *
    1010 * @author Martin Lee
     
    2323
    2424/** @class ExtensionInfo ExtensionInfo.h "factory/ExtensionInfo.h"
    25  *  ExtensionInfo contains information about extension. 
    26  *  If @a m_extension is true we are in an extension of some initial field. 
    27  *  If the initial field is \f$ F_p \f$ and we pass to \f$ F_p (\alpha) \f$ 
    28  *  then @a m_alpha is an algebraic variable, @a m_beta= Variable(1), 
     25 *  ExtensionInfo contains information about extension.
     26 *  If @a m_extension is true we are in an extension of some initial field.
     27 *  If the initial field is \f$ F_p \f$ and we pass to \f$ F_p (\alpha) \f$
     28 *  then @a m_alpha is an algebraic variable, @a m_beta= Variable(1),
    2929 *  @a m_gamma= @a m_delta= 1, @a m_GFDegree= 0, @a m_GFName= 'Z'. If we pass
    30  *  to some GF (p^k) then @a m_alpha= Variable (1), @a m_beta= Variable(1), 
    31  *  @a m_gamma= @a m_delta= 1, @a m_GFDegree= 1, @a m_GFName= 'Z'. 
    32  *  @n If the initial field is \f$ F_p (\epsilon) \f$, then @a m_beta= 
    33  *  \f$ \epsilon \f$, @a m_alpha an algebraic variable defining an extension of 
    34  *  \f$ F_p (\epsilon) \f$, @a m_gamma is a primitive element of 
    35  *  \f$ F_p (\alpha) \f$, @a m_delta is a primitive element of 
    36  *  \f$ F_p (\beta) \f$, @a m_GFDegree= 0, @a m_GFName= 'Z'. 
    37  *  @n If the initial field is GF(p^k), then @a m_alpha= Variable (1), 
    38  *  @a m_beta= Variable (1), @a m_gamma= 1, @a m_delta= 1, @a m_GFDegree()= k, 
    39  *  @a m_GFName= gf_name of the initial field. 
    40  *  @n If @a m_extension is false and the current field is \f$ F_p \f$ then 
    41  *  @a m_alpha= Variable (1), @a m_beta= Variable (1), @a m_gamma= 1, 
    42  *  @a m_delta= 1, @a m_GFDegree= 1, @a m_GFName= 'Z'. 
    43  *  @n If the current field is \f$ F_p (\alpha) \f$ then 
    44  *  @a m_alpha is some algebraic variable, @a m_beta= Variable (1), 
    45  *  @a m_gamma= 1, @a m_delta= 1, @a m_GFDegree= 0, @a m_GFName= 'Z'. 
    46  *  @n If the current field is GF then @a m_alpha= Variable (1), 
    47  *  @a m_beta= Variable (1),  @a m_gamma= 1, @a m_delta= 1, 
     30 *  to some GF (p^k) then @a m_alpha= Variable (1), @a m_beta= Variable(1),
     31 *  @a m_gamma= @a m_delta= 1, @a m_GFDegree= 1, @a m_GFName= 'Z'.
     32 *  @n If the initial field is \f$ F_p (\epsilon) \f$, then @a m_beta=
     33 *  \f$ \epsilon \f$, @a m_alpha an algebraic variable defining an extension of
     34 *  \f$ F_p (\epsilon) \f$, @a m_gamma is a primitive element of
     35 *  \f$ F_p (\alpha) \f$, @a m_delta is a primitive element of
     36 *  \f$ F_p (\beta) \f$, @a m_GFDegree= 0, @a m_GFName= 'Z'.
     37 *  @n If the initial field is GF(p^k), then @a m_alpha= Variable (1),
     38 *  @a m_beta= Variable (1), @a m_gamma= 1, @a m_delta= 1, @a m_GFDegree()= k,
     39 *  @a m_GFName= gf_name of the initial field.
     40 *  @n If @a m_extension is false and the current field is \f$ F_p \f$ then
     41 *  @a m_alpha= Variable (1), @a m_beta= Variable (1), @a m_gamma= 1,
     42 *  @a m_delta= 1, @a m_GFDegree= 1, @a m_GFName= 'Z'.
     43 *  @n If the current field is \f$ F_p (\alpha) \f$ then
     44 *  @a m_alpha is some algebraic variable, @a m_beta= Variable (1),
     45 *  @a m_gamma= 1, @a m_delta= 1, @a m_GFDegree= 0, @a m_GFName= 'Z'.
     46 *  @n If the current field is GF then @a m_alpha= Variable (1),
     47 *  @a m_beta= Variable (1),  @a m_gamma= 1, @a m_delta= 1,
    4848 *  @a m_GFDegree= getGFDegree(), @a m_GFName= gf_name.
    4949 *
    50  *  @sa facFqBivar.h, facFqFactorize.h 
     50 *  @sa facFqBivar.h, facFqFactorize.h
    5151 */
    5252class ExtensionInfo
    5353{
    5454private:
    55   /// an algebraic variable or Variable (1) 
     55  /// an algebraic variable or Variable (1)
    5656  Variable m_alpha;
    5757  /// an algebraic variable or Variable (1)
    58   Variable m_beta; 
     58  Variable m_beta;
    5959  /// a primitive element of \f$ F_p (\alpha) \f$ or 1
    6060  CanonicalForm m_gamma;
     
    6969public:
    7070  /// \f$ F_p \f$ as initial field, if @a extension is true we are in some GF
    71   ExtensionInfo (const bool extension  ///< [in] some bool 
     71  ExtensionInfo (const bool extension  ///< [in] some bool
    7272                );
    73   /// Construct an @a ExtensionInfo 
    74   ExtensionInfo (const Variable& alpha,      ///< [in] some algebraic variable 
     73  /// Construct an @a ExtensionInfo
     74  ExtensionInfo (const Variable& alpha,      ///< [in] some algebraic variable
    7575                 const Variable& beta,       ///< [in] some algebraic variable
    7676                 const CanonicalForm& gamma, ///< [in] some primitive element
     
    8585  /// \f$ F_p (\beta) \f$ as initial field and switch to an extension given by
    8686  /// @a alpha, needs primitive elements @a gamma and @a delta for maps
    87   /// between \f$ F_p (\alpha) \subset F_p (\beta) \f$ 
     87  /// between \f$ F_p (\alpha) \subset F_p (\beta) \f$
    8888  ExtensionInfo (const Variable& alpha,      ///< [in] some algebraic variable
    8989                 const Variable& beta,       ///< [in] some algebraic variable
     
    9494                );
    9595  /// \f$ F_p (\alpha) \f$ as initial field, if @a extension is false.
    96   /// Else initial field is \f$ F_p \f$ 
     96  /// Else initial field is \f$ F_p \f$
    9797  ExtensionInfo (const Variable& alpha, ///< [in] some algebraic variable
    9898                 const bool extension   ///< [in] some bool
    99                 ); 
     99                );
    100100
    101   ExtensionInfo (const Variable& alpha ///< [in] some algebraic variable
     101  //ExtensionInfo (const Variable& alpha ///< [in] some algebraic variable
     102  //              );
     103
     104  /// GF as initial field
     105  ExtensionInfo (const int nGFDegree,   ///< [in] GF degree of initial field
     106                 const char cGFName,    ///< [in] name of GF variable
     107                 const bool extension   ///< [in] some bool
    102108                );
    103  
    104   /// GF as initial field
    105   ExtensionInfo (const int nGFDegree,   ///< [in] GF degree of initial field
    106                  const char cGFName,    ///< [in] name of GF variable
    107                  const bool extension   ///< [in] some bool
    108                 );
    109109
    110110  /// getter
  • factory/NTLconvert.cc

    rc840d9 r806c18  
    4747#define Free(A,L) free(A)
    4848#endif
    49  
     49
    5050void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
    51        
     51
    5252
    5353int fac_NTL_char=-1;            // the current characterstic for NTL calls
     
    625625
    626626    //reverse the list to obtain the correct string
    627     //NTL_SNS 
     627    //NTL_SNS
    628628    for (int i=l-1;i>=0;i--) // l ist the position of \0
    629629    {
     
    10691069}
    10701070
    1071 CanonicalForm convertNTLzz_pEX2CF (zz_pEX f, Variable x, Variable alpha) 
     1071CanonicalForm convertNTLzz_pEX2CF (zz_pEX f, Variable x, Variable alpha)
    10721072{
    10731073  CanonicalForm bigone;
     
    10761076    bigone= 0;
    10771077    bigone.mapinto();
    1078     for (int j=0;j<deg(f)+1;j++) 
     1078    for (int j=0;j<deg(f)+1;j++)
    10791079    {
    10801080      if (coeff(f,j)!=0)
  • factory/abs_fac.cc

    rc840d9 r806c18  
    3636
    3737  if( F.isZero() ) return 0;
    38   if( F.inBaseDomain() )  return F; 
    39 
    40   if( level(F) < 0 )  return 1; 
     38  if( F.inBaseDomain() )  return F;
     39
     40  if( level(F) < 0 )  return 1;
    4141
    4242  r = LC( F, x);
     
    4747  {
    4848    t = LC(g, x);
    49     if( t == 1 || t == -1 ) return 1; 
     49    if( t == 1 || t == -1 ) return 1;
    5050    r = MYGCD( r, t);
    51     if( r == 1 ) return 1; 
    52     g = g - power(x,degree(g,x))*t; 
     51    if( r == 1 ) return 1;
     52    g = g - power(x,degree(g,x))*t;
    5353  }
    5454  return r;
     
    613613   CFFListIterator J=Result;
    614614   for ( ; J.hasItem(); J++)
    615     { 
     615    {
    616616     Factor_Norm = J.getItem().factor();
    617617     Factor_Norm = Factor_Norm(x+k*l,x);   // die Störungen werden rückgänig gemacht
     
    861861    F = A[i];
    862862
    863     if( degree(F,x) == 0 ) 
    864   if( c.level() < 0 ) return 1; else return c; 
     863    if( degree(F,x) == 0 )
     864  if( c.level() < 0 ) return 1; else return c;
    865865
    866866    F = gamma*F/LC(F, x);
     
    908908  if( g != g(0,i) )
    909909     L.append(i);
    910  
     910
    911911 int nvg = L.length();
    912912
    913  
     913
    914914
    915915 if( f.level() < 0 && g.level() < 0 )  { ;
    916916  return 1; }
    917    
     917
    918918 CFArray A;
    919    
     919
    920920 i=0;
    921921    int r;
     
    940940 if( nvf <= 1 && nvg <=1 )
    941941 {
    942   gamma = MyGCDmod( LC(F,x), LC(G,x) ); 
     942  gamma = MyGCDmod( LC(F,x), LC(G,x) );
    943943  c = MyGCDmod( Cf, Cg );
    944944 }
     
    956956    F = A[i];
    957957
    958     if( degree(F,x) == 0 ) 
    959   if( c.level() < 0 ) return 1; else return c; 
     958    if( degree(F,x) == 0 )
     959  if( c.level() < 0 ) return 1; else return c;
    960960
    961961    F = gamma*F/LC(F, x);
     
    10071007  {
    10081008   CanonicalForm qi = MYGCD( temp2, temp4);
    1009    if( qi != 1 ) L.append( CFFactor( qi, i ) ); 
     1009   if( qi != 1 ) L.append( CFFactor( qi, i ) );
    10101010   i++;
    10111011   temp2 = temp2/qi;
     
    10371037 for ( CFIterator I = F; I.hasTerms(); ++I ) fillVarsRec( I.coeff(), vrs );
    10381038
    1039  N.append( CFFactor(F,1) ); 
     1039 N.append( CFFactor(F,1) );
    10401040
    10411041 int i = n+1;
     
    10431043 while( i >= 0 )
    10441044 {
    1045   b = 0; 
     1045  b = 0;
    10461046
    10471047  if( i == 0 ){  v = mvar(F); b=1 ;}
    10481048  else
    1049   if( vrs[i] != 0 ){ b=1; v= Variable(i);} 
    1050   if( vrs[i] == 0 )  i--; 
     1049  if( vrs[i] != 0 ){ b=1; v= Variable(i);}
     1050  if( vrs[i] == 0 )  i--;
    10511051
    10521052  if( b )
    1053   { 
     1053  {
    10541054   for( CFFListIterator J = L; J.hasItem(); J++ )
    10551055   {
     
    10651065   }
    10661066   if( N.length() == L.length() ) i -= 1;
    1067    L=N; 
     1067   L=N;
    10681068  }
    10691069 }
  • factory/algext.cc

    rc840d9 r806c18  
    569569      other[i] = 0; // reset (this is necessary, because some entries may not be updated by call to leadDeg)
    570570    other = leadDeg(Dp,other);
    571    
     571
    572572    if(isEqual(bound, other, 1, mv)) // equal
    573573    {
  • factory/bifac.cc

    rc840d9 r806c18  
    44#include "bifacConfig.h"
    55
    6 #define BIFAC_BASIS_OF_G_CHECK  1
     6#define BIFAC_BASIS_OF_G_CHECK        1
    77void Reduce( bool );
    88CanonicalForm Bigcd( const CanonicalForm& f, const CanonicalForm& g);
     
    2828
    2929//==================================================
    30 class PolyVector 
     30class PolyVector
    3131//==================================================
    3232{
     
    5353      int correction = 1;  // univariate polynomials
    5454      if( n==0) correction = n+1;
    55      
     55
    5656      value = new CanonicalForm[m*(n+1)+n+1];
    5757      for(int i=0; i<=m*(n+1)+n; i++) value[i]=0;
    5858
    59      
    60       for ( CFIterator i = f; i.hasTerms(); i++ ) { 
    61         for ( CFIterator j = i.coeff(); j.hasTerms(); j++ ){
    62                 if( i.coeff().mvar().level()< 0 ){
    63                         value[ 0*(n+1) + i.exp()*correction ] = j.coeff();}
    64             else{
    65                         value[ j.exp()*(n+1) + i.exp()*correction ] = j.coeff();}}}
     59
     60      for ( CFIterator i = f; i.hasTerms(); i++ ) {
     61        for ( CFIterator j = i.coeff(); j.hasTerms(); j++ ){
     62                if( i.coeff().mvar().level()< 0 ){
     63                        value[ 0*(n+1) + i.exp()*correction ] = j.coeff();}
     64            else{
     65                        value[ j.exp()*(n+1) + i.exp()*correction ] = j.coeff();}}}
    6666    }
    6767  }
     
    8484      s << "[";
    8585      for (int j=0;j<=V.n;j++)
    86         s << V.value[i*(V.n+1)+j] << ", ";
     86        s << V.value[i*(V.n+1)+j] << ", ";
    8787      s << "]\n";
    8888    }
     
    120120//--<>---------------------------------
    121121{
    122 } 
     122}
    123123
    124124
     
    137137
    138138//    // === Datei löschen ===
    139  
    140 //    ofstream* aus = new ofstream(name, ios::out); 
     139
     140//    ofstream* aus = new ofstream(name, ios::out);
    141141//    delete aus;
    142142
     
    144144//    // === Jetzt immer nur anhängen ===
    145145
    146 //    aus  = new ofstream(name, ios::app); 
     146//    aus  = new ofstream(name, ios::app);
    147147//    *aus << "// Zeilen Spalten\n"
    148148//         << "// x-Koord. y-Koord.  Wert\n";
     
    157157//        *aus << i << " " << j << " " << M(i+1,j+1) << endl;;
    158158//    delete aus;
    159 //  }   
     159//  }
    160160
    161161//=======================================================
     
    163163//=======================================================
    164164{
    165         ;
     165        ;
    166166}
    167167
     
    174174
    175175  for ( CFIterator i = f; i.hasTerms(); i++ )
    176     for ( CFIterator j = i.coeff(); j.hasTerms(); j++ ) 
     176    for ( CFIterator j = i.coeff(); j.hasTerms(); j++ )
    177177      z++;
    178178  return( z );
    179179}
    180  
     180
    181181//=======================================================
    182182void BIFAC::biGanzMachen(  CanonicalForm & f )
     
    188188
    189189  for ( CFIterator i = f; i.hasTerms(); i++ )
    190     for ( CFIterator j = i.coeff(); j.hasTerms(); j++ ) 
     190    for ( CFIterator j = i.coeff(); j.hasTerms(); j++ )
    191191    {
    192192      if( !init )
    193       { 
    194         ggT = j.coeff();
    195         init = true;
     193      {
     194        ggT = j.coeff();
     195        init = true;
    196196      }
    197       else           
    198         ggT = gcd(j.coeff(), ggT);
     197      else
     198        ggT = gcd(j.coeff(), ggT);
    199199    }
    200200  f /= ggT;
     
    203203
    204204//=======================================================
    205 void  BIFAC::biNormieren( CanonicalForm & f ) 
     205void  BIFAC::biNormieren( CanonicalForm & f )
    206206//=======================================================
    207207{
     
    209209  {
    210210    for ( CFIterator i = f; i.hasTerms(); i++ )
    211       for ( CFIterator j = i.coeff(); j.hasTerms(); j++ ) 
    212         if( j.coeff().den() != 1 )
    213         {
    214           f  *= j.coeff().den();
    215           biNormieren( f );
    216         }
     211      for ( CFIterator j = i.coeff(); j.hasTerms(); j++ )
     212        if( j.coeff().den() != 1 )
     213        {
     214          f  *= j.coeff().den();
     215          biNormieren( f );
     216        }
    217217    biGanzMachen( f );
    218   } 
     218  }
    219219  else
    220220  {
     
    242242    for(i=0; i<=m-1; i++)
    243243      for(j=0; j<=n; j++)
    244         g += A(k, i*(n+1)+j+1)* power(x,i) * power(y,j);
     244        g += A(k, i*(n+1)+j+1)* power(x,i) * power(y,j);
    245245    Lg.append(g);
    246246  }
     
    255255      h=0;
    256256      for(i=0; i<=m; i++)
    257         for(j=0; j<n; j++)
    258           h += A(k, i*n+j+1 +m*(n+1))* power(x,i) * power(y,j);
     257        for(j=0; j<n; j++)
     258          h += A(k, i*n+j+1 +m*(n+1))* power(x,i) * power(y,j);
    259259      Lh.append(h);
    260260    }
    261    
     261
    262262    // === Is the solution correct? ===
    263263    CFListIterator itg=Lg;
     
    268268      h = ith.getItem();
    269269      ff = f*(deriv(g,y)-deriv(h,x)) +h*deriv(f,x) -g*deriv(f,y);
    270       if( !ff.isZero()) { 
     270      if( !ff.isZero()) {
    271271      #ifndef NOSTREAMIO
    272         AUSGABE_ERR("* Falsche Polynome!");
    273         exit (1);
     272        AUSGABE_ERR("* Falsche Polynome!");
     273        exit (1);
    274274      #else
    275275        printf("wrong polys\n");
     
    277277      #endif
    278278      }
    279     } 
     279    }
    280280  }
    281281  ///////////  END VALIDATION ////////////////////////////////////
     
    302302  int n = degree(f,y);
    303303  int r,s, ii,jj;
    304  
     304
    305305
    306306  // ======= Creation of the system of linear equations for G =============
     
    309309
    310310  CFMatrix M(rows, columns); // Remember: The first index is (1,1) -- not (0,0)!
    311  
     311
    312312  for ( CFIterator i = f; i.hasTerms(); i++ )  // All coeffizients of y
    313313  {
     
    319319      // Now we regard g_{ii,jj)
    320320      for( ii=0; ii<m; ii++)
    321         for( jj=0; jj<=n; jj++)
    322         {
    323           if(  s>= 1) M( (r+ii)*2*n +(jj+s-1)+1, ii*(n+1)+jj +1) += -j.coeff() * s;
    324           if( jj>= 1) M( (r+ii)*2*n +(jj+s-1)+1, ii*(n+1)+jj +1) +=  j.coeff() * jj;
    325         }
     321        for( jj=0; jj<=n; jj++)
     322        {
     323          if(  s>= 1) M( (r+ii)*2*n +(jj+s-1)+1, ii*(n+1)+jj +1) += -j.coeff() * s;
     324          if( jj>= 1) M( (r+ii)*2*n +(jj+s-1)+1, ii*(n+1)+jj +1) +=  j.coeff() * jj;
     325        }
    326326
    327327      // Now we regard h_{ii,jj}
    328328      for( ii=0; ii<=m; ii++)
    329         for( jj=0; jj<n; jj++)
    330         {
    331           if(  r>= 1) M( (r+ii-1)*2*n +(jj+s)+1, (ii*n)+jj +m*(n+1) +1) += j.coeff() * r;
    332           if( ii>= 1) M( (r+ii-1)*2*n +(jj+s)+1, (ii*n) +jj +m*(n+1) +1) +=  -j.coeff() * ii;
    333         }
     329        for( jj=0; jj<n; jj++)
     330        {
     331          if(  r>= 1) M( (r+ii-1)*2*n +(jj+s)+1, (ii*n)+jj +m*(n+1) +1) += j.coeff() * r;
     332          if( ii>= 1) M( (r+ii-1)*2*n +(jj+s)+1, (ii*n) +jj +m*(n+1) +1) +=  -j.coeff() * ii;
     333        }
    334334    }
    335335  }
     
    364364      tmp =0;
    365365      for(int j=1; j<=columns; j++)
    366         tmp += M(i,j) * basis(k,j);
     366        tmp += M(i,j) * basis(k,j);
    367367      if( tmp!= 0) {
    368         exit(17);
     368        exit(17);
    369369      }
    370370    }
     
    374374
    375375//=======================================================
    376 //   Compute a   r x r - matrix A=(a_ij) for 
     376//   Compute a   r x r - matrix A=(a_ij) for
    377377//     gg_i = SUM a_ij * g_j * f_x (mod f)
    378 //  Return a list consisting of 
     378//  Return a list consisting of
    379379//    r x (r+1) Matrix A
    380 //    the last columns contains only the indices of the 
     380//    the last columns contains only the indices of the
    381381//    first r linear independent lines
    382382// REMARK: this is used by BIFAC::createEg but NOT by createEgUni!!
     
    390390  int r = G.length();  // number of factors
    391391
    392   LGS       L(r,r,true);     
    393 //  LGS       L(r,r);     
     392  LGS       L(r,r,true);
     393//  LGS       L(r,r);
    394394  CFMatrix  Z(1,r);
    395395  CFMatrix  A(r,r+2);  // the last two column contain the bi-degree
     
    402402  CanonicalForm q;
    403403
    404   for( CFListIterator it=G; it.hasItem(); it++, i++){ 
     404  for( CFListIterator it=G; it.hasItem(); it++, i++){
    405405
    406406    gifx[i].init( (it.getItem()*fx)%f );
     
    410410
    411411  e=1; // row number of A
    412   n=0; // 
     412  n=0; //
    413413  m=0; //
    414414  while (L.rank() != r )
     
    461461      g += rand_coeff1[i]  * it.getItem();
    462462    }
    463  
     463
    464464  delete[] rand_coeff1;
    465465
     
    483483
    484484  bool suitable1 = false; // Is Eg by chance unsuitable?
    485   bool suitable2 = false;  // Is on of g*g_i or g_i*f_x zero? 
     485  bool suitable2 = false;  // Is on of g*g_i or g_i*f_x zero?
    486486
    487487  // === (0) Preparation ===
     
    511511  {
    512512
    513      suitable2 = false; 
     513     suitable2 = false;
    514514    // === (1) Creating g ===
    515515    while ( !suitable2 )
     
    519519//        for( CFListIterator it=G; it.hasItem(); it++, i++)
    520520//        {
    521 //      gi[i] =  it.getItem();
    522 //      rand_coeff[i] =  RANDOM.generate().intval();
    523 //      g += rand_coeff[i] * it.getItem();
     521//          gi[i] =  it.getItem();
     522//          rand_coeff[i] =  RANDOM.generate().intval();
     523//          g += rand_coeff[i] * it.getItem();
    524524//        }
    525525      g = create_g( G );
    526    
     526
    527527      // === (2) Computing g_i * g ===
    528           //
    529       for(i=0; i<r; i++){ 
    530 
    531           ggi[i]  = (g*gi[i])%f;   // seite 10
     528          //
     529      for(i=0; i<r; i++){
     530
     531          ggi[i]  = (g*gi[i])%f;   // seite 10
    532532      }
    533      
     533
    534534      // ===  Check if all polynomials are <> 0  ===
    535535      suitable2 = true;    // It should be fine, but ...
    536       if( g.isZero() ) 
    537         suitable2 = false;
     536      if( g.isZero() )
     537        suitable2 = false;
    538538//        else
    539 //      for(i=0; i<r; i++)
    540 //        if(  ggi[i].isZero() )
    541 //          suitable2 = false;
     539//          for(i=0; i<r; i++)
     540//            if(  ggi[i].isZero() )
     541//              suitable2 = false;
    542542
    543543    } // end of  Žwhile ( !suitable2 )Ž
    544    
     544
    545545    // === (3) Computing Eg(x) ===
    546    
     546
    547547    for(i=0;i<r;i++)  // Get Polynomials as vectors
    548548      v_ggi[i].init(ggi[i]);
    549549
    550550    // Matrix A
    551     for(i=1; i<=r; i++) 
     551    for(i=1; i<=r; i++)
    552552      for( j=1; j<=r; j++)
    553553      {
    554         A(i,j) = 0;
    555         for( e=1; e<=r; e++)
    556         {
     554        A(i,j) = 0;
     555        for( e=1; e<=r; e++)
     556        {
    557557
    558558
     
    562562//
    563563
    564         }
     564        }
    565565      }
    566566
     
    605605  CanonicalForm ff, ffx,g, gg, Eg;
    606606
    607  
     607
    608608  bool suitable1 = false;  // Is Eg unsuitable?
    609   bool suitable2 = false;  // Is on of g*g_i or g_i*f_x zero? 
     609  bool suitable2 = false;  // Is on of g*g_i or g_i*f_x zero?
    610610  bool suitable3 = false;  // Is 'konst' unsuitable?
    611611
     
    627627  CFMatrix  Z(1,r);     // `Vector` for data transportation
    628628  CFMatrix  AA(m,r);    // but first we generate AA.
    629   CFMatrix  AI(r,r+1);  // 
    630   LGS       L(r,r,true); 
     629  CFMatrix  AI(r,r+1);  //
     630  LGS       L(r,r,true);
    631631  IntRandom RANDOM(S);
    632632
     
    642642    ff  = f(konst,'y');
    643643    ffx = fx(konst,'y');
    644    
     644
    645645    if( gcd(ff, ffx) == 1)
    646646      suitable3 = true;
     
    649649      konst *= -1;
    650650      if( konst >= 0 )
    651         konst++;
     651        konst++;
    652652    }
    653653  }
     
    660660  for( CFListIterator it=G; it.hasItem(); it++, i++)
    661661  {
    662     gi[i] =  it.getItem()(konst,'y'); 
     662    gi[i] =  it.getItem()(konst,'y');
    663663  }
    664664
     
    666666  // =   (3) Compute the matrices 'AA' and 'AI'    =
    667667  // ===============================================
    668  
     668
    669669
    670670  for( i=0; i<r; i++) // First store all coeffizients in AA.
     
    673673    //biNormieren(ggi[i]);
    674674    for ( CFIterator j = ggi[i]; j.hasTerms(); j++ )
    675       AA( j.exp()+1, i+1) = j.coeff(); 
     675      AA( j.exp()+1, i+1) = j.coeff();
    676676  }
    677677
     
    684684    ASSERT( i<=m, "Too few linear independent rows!");
    685685
    686     for (k=1; k<=r; k++) 
     686    for (k=1; k<=r; k++)
    687687      Z(1,k) =  AA(i,k);
    688688    if( L.new_row(Z,0) )  // linear independent row?
     
    701701  // =   (4) Big loop to find a suitable 'Eg(x)   =
    702702  // ==============================================
    703    
     703
    704704  while ( !suitable1 )    // Is Eg(x) suitable? -> Check at the end of this procedure!
    705705  {
     
    711711//    rand_coeff[0] = 0;
    712712//    rand_coeff[1] = 4;
    713    
     713
    714714
    715715    while ( !suitable2 )
     
    720720      for( CFListIterator it=G; it.hasItem(); it++, i++)
    721721      {
    722         rand_coeff[i] =  RANDOM.generate().intval();
    723         g += rand_coeff[i] * it.getItem();
     722         rand_coeff[i] =  RANDOM.generate().intval();
     723        g += rand_coeff[i] * it.getItem();
    724724      }
    725725      gg = g(konst,'y');   // univariate!
     
    728728      // ===  (ii) Check if all polynomials are <> 0  ===
    729729      suitable2 = true;    // It should be fine, but ...
    730       if( gg.isZero() ) 
    731         suitable2 = false;
     730      if( gg.isZero() )
     731        suitable2 = false;
    732732//        else
    733 //      for(i=0; i<r; i++)
    734 //        if(  ggi[i].isZero() )
    735 //          suitable2 = false;
     733//          for(i=0; i<r; i++)
     734//            if(  ggi[i].isZero() )
     735//              suitable2 = false;
    736736    } // end of  Žwhile ( !suitable2 )Ž
    737  
     737
    738738//    createRg(g,f);
    739739
     
    741741    // =    (b) Compute matrix 'A'                   =
    742742    // ===============================================
    743     for(i=1; i<=r; i++) 
    744     {
    745       for( ii=1; ii<=m; ii++) 
    746         AA (ii,1) = 0;  // !! Redefinition of AA !!
     743    for(i=1; i<=r; i++)
     744    {
     745      for( ii=1; ii<=m; ii++)
     746        AA (ii,1) = 0;  // !! Redefinition of AA !!
    747747      for ( CFIterator j = ggi[i-1]; j.hasTerms(); j++ )
    748         AA( j.exp()+1, 1) = j.coeff(); 
     748        AA( j.exp()+1, 1) = j.coeff();
    749749
    750750      for( ii=1; ii<=r; ii++)
    751751      {
    752         A(i,ii) = 0;
    753         for( k=1; k<=r; k++)
    754           A(i,ii) += ( AI(ii,k ) *  AA( AI(k, r+1 ).intval(),1) );
     752        A(i,ii) = 0;
     753        for( k=1; k<=r; k++)
     754          A(i,ii) += ( AI(ii,k ) *  AA( AI(k, r+1 ).intval(),1) );
    755755      }
    756756    }
     
    761761    // =    (c) Compute Eg(x) and check it           =
    762762    // ===============================================
    763  
     763
    764764    Eg = determinant(A,r);
    765765    if( gcd(Eg, deriv(Eg,x)) == 1 )
     
    769769  } // end of  Žwhile ( !suitable1 )Ž
    770770
    771  
     771
    772772  // ==============================================
    773773  // =   (5) Prepare for leaving                  =
     
    777777  delete[] ggi;
    778778  delete[] rand_coeff;
    779  
     779
    780780  CFList LL;
    781781  LL.append(Eg);
     
    805805  // ===============================================
    806806
    807   CanonicalForm alpha=1; 
    808 
    809   while(  resultant( f, fx, x)(alpha) == 0 ) 
    810   {
    811         //while( resultant( f, fx, x)(alpha).inCoeffDomain() != true )
     807  CanonicalForm alpha=1;
     808
     809  while(  resultant( f, fx, x)(alpha) == 0 )
     810  {
     811        //while( resultant( f, fx, x)(alpha).inCoeffDomain() != true )
    812812    //alpha +=1;
    813813  }
     
    817817  // =   (2) Find a suitable constant              =
    818818  // ===============================================
    819  
     819
    820820  Rg = resultant( f(alpha,y), g(alpha,y)-z*fx(alpha,y), x);
    821  
     821
    822822
    823823  CFList LL;
     
    838838  CanonicalForm tmp;
    839839
    840   factorsUni = AbsFactorize(ff); 
     840  factorsUni = AbsFactorize(ff);
    841841
    842842  for( CFFListIterator l=factorsUni; l.hasItem(); l++)
     
    854854//=======================================================
    855855CanonicalForm BIFAC::RationalFactor (CanonicalForm phi, CanonicalForm ff, \
    856                                      CanonicalForm fx, CanonicalForm g)
     856                                     CanonicalForm fx, CanonicalForm g)
    857857//=======================================================
    858858{
     
    866866
    867867  hh = Bigcd(ff,  h);
    868  
     868
    869869  return(hh);
    870870}
     
    880880    ASSERT( i.getItem().exp() == 1 , "Wrong factor of Eg"); // degree must be 1
    881881    CanonicalForm phi = i.getItem().factor();
    882    
     882
    883883    if( ! phi.inBaseDomain())
    884884    {
     
    908908    else
    909909      root = -tailcoeff(fac)/lc(fac);
    910  
    911  
     910
     911
    912912    AbsFac.append( f1(root,e) );
    913913    AbsFac.append( i.getItem().exp() * exponent);
     
    933933  CanonicalForm h, h_abs, h_res, h_rat;
    934934  CanonicalForm fx = deriv(ff,x);
    935  
     935
    936936
    937937  for( CFFListIterator i=Phis; i.hasItem(); i++)
     
    939939    ASSERT( i.getItem().exp() == 1 , "Wrong factor of Eg"); // degree must be 1
    940940    phi = i.getItem().factor();
    941    
     941
    942942    if( ! phi.inBaseDomain())
    943943    {
     
    946946      if( phi.degree() == 1 )
    947947      {
    948         if( taildegree(phi) > 0 )  // case: phi = a * x
    949           h = gcd( ff,g );
    950         else                       // case: phi = a * x + c
    951         {
    952           h =  gcd( ff, g+tailcoeff(phi)/lc(phi)*fx);
    953         }
    954        
    955         //biNormieren( h );
    956         gl_AL.append(h); // Factor of degree 1
    957         gl_AL.append(exponent); // Multiplicity (exponent)
    958         gl_AL.append(0); // No field extension
     948        if( taildegree(phi) > 0 )  // case: phi = a * x
     949          h = gcd( ff,g );
     950        else                       // case: phi = a * x + c
     951        {
     952          h =  gcd( ff, g+tailcoeff(phi)/lc(phi)*fx);
     953        }
     954
     955        //biNormieren( h );
     956        gl_AL.append(h); // Factor of degree 1
     957         gl_AL.append(exponent); // Multiplicity (exponent)
     958        gl_AL.append(0); // No field extension
    959959      } else
    960960      {
    961         // === Case 2:  phi has degree > 1 ===
    962         e=rootOf(phi, 'e');
    963         h =  gcd( ff, g-e*fx);
    964         //biNormieren( h );
    965 
    966         AbsFac = getAbsoluteFactors(h, phi);
    967         for( CFListIterator l=AbsFac; l.hasItem(); l++)
    968           gl_AL.append( l.getItem() );
    969 
    970 
    971         // ===  (1) Get the rational factor by multi-  ===
    972         // ===      plication of the absolute factor.  ===
    973         h_abs=1;
    974         ii = 0;
    975        
    976         for( CFListIterator l=AbsFac; l.hasItem(); l++)
    977         {
    978           ii++;
    979           if (ii%3 == 1 )
    980             h_abs *= l.getItem();
    981         }
    982         //biNormieren( h_abs );
    983 
    984 
    985         // === (2) Compute the rational factor  ===
    986         // ===     by using the resultant.      ===
    987         h_res =  resultant(phi(z,x), h(z,e), z);
    988         //biNormieren( h_res );
    989 
    990 
    991         // === (3) Compute the rational factor by ignoring  ===
    992         // ===     all knowledge of absolute factors.       ===
    993         h_rat = RationalFactor(phi, ff,fx, g);
    994         //biNormieren( h_rat );
    995 
    996         ASSERT(  (h_abs == h_res) && (h_res == h_rat), "Wrong rational factor ?!?");
    997         h = h_abs;
     961        // === Case 2:  phi has degree > 1 ===
     962        e=rootOf(phi, 'e');
     963        h =  gcd( ff, g-e*fx);
     964        //biNormieren( h );
     965
     966        AbsFac = getAbsoluteFactors(h, phi);
     967        for( CFListIterator l=AbsFac; l.hasItem(); l++)
     968          gl_AL.append( l.getItem() );
     969
     970
     971        // ===  (1) Get the rational factor by multi-  ===
     972        // ===      plication of the absolute factor.  ===
     973        h_abs=1;
     974        ii = 0;
     975
     976        for( CFListIterator l=AbsFac; l.hasItem(); l++)
     977        {
     978          ii++;
     979          if (ii%3 == 1 )
     980            h_abs *= l.getItem();
     981        }
     982        //biNormieren( h_abs );
     983
     984
     985        // === (2) Compute the rational factor  ===
     986        // ===     by using the resultant.      ===
     987        h_res =  resultant(phi(z,x), h(z,e), z);
     988        //biNormieren( h_res );
     989
     990
     991        // === (3) Compute the rational factor by ignoring  ===
     992        // ===     all knowledge of absolute factors.       ===
     993        h_rat = RationalFactor(phi, ff,fx, g);
     994        //biNormieren( h_rat );
     995
     996        ASSERT(  (h_abs == h_res) && (h_res == h_rat), "Wrong rational factor ?!?");
     997        h = h_abs;
    998998      }
    999999      // End of absolute factorization.
     
    10051005
    10061006
    1007 //====================================================== 
     1007//======================================================
    10081008//  Factorization of a squarefree bivariate polynomial
    10091009//  in which every factor appears only once.
    10101010//  Do we need a complete factorization ('absolute' is true)
    10111011//  or only a rational factorization ('absolute' false)?
    1012 //====================================================== 
     1012//======================================================
    10131013void BIFAC::bifacSqrFree(CanonicalForm ff)
    10141014//=======================================================
     
    10351035//    LL  = createEg(G,ff);
    10361036//   LL = createEgUni(G,ff); // Hier ist noch ein FEHLER !!!!
    1037        
     1037
    10381038   LL = createRg( G, ff);  // viel langsamer als EgUni
    1039    
    1040    
     1039
     1040
    10411041    Eg  =  LL.getFirst();
    1042         Eg  =  Eg/LC(Eg);
    1043    
     1042        Eg  =  Eg/LC(Eg);
     1043
    10441044   g   =  LL.getLast();
    10451045
    10461046//      g = G.getFirst();
    10471047
    1048    
    1049     CFFList PHI = AbsFactorize( Eg ); 
    1050 
    1051         CFFListIterator J=PHI;
    1052         CanonicalForm Eg2=1;
    1053         for ( ; J.hasItem(); J++)
    1054         { Eg2 = Eg2 * J.getItem().factor(); }
     1048
     1049    CFFList PHI = AbsFactorize( Eg );
     1050
     1051        CFFListIterator J=PHI;
     1052        CanonicalForm Eg2=1;
     1053         for ( ; J.hasItem(); J++)
     1054        { Eg2 = Eg2 * J.getItem().factor(); }
    10551055
    10561056    // === Is Eg(x) irreducible ? ===
    10571057    anz=0;
    10581058
    1059         // PHI =  AbsFactorize( Eg) ;
    1060         //
    1061        
    1062     for( CFFListIterator i=PHI; i.hasItem(); i++) { 
     1059        // PHI =  AbsFactorize( Eg) ;
     1060        //
     1061
     1062    for( CFFListIterator i=PHI; i.hasItem(); i++) {
    10631063      if( !i.getItem().factor().inBaseDomain())
    1064         anz++;
    1065         }
     1064        anz++;
     1065        }
    10661066
    10671067    /* if( absolute ) // Only for a absolute factorization
    10681068      AbsoluteFactorization( PHI,ff, g);
    1069     else         // only for a rational factorization 
     1069    else         // only for a rational factorization
    10701070    { */
    10711071      if( anz==1 ){ ;
    1072         gl_RL.append( CFFactor(ff,exponent));}
    1073       else         
    1074         RationalFactorizationOnly( PHI,ff, g);
     1072        gl_RL.append( CFFactor(ff,exponent));}
     1073      else
     1074        RationalFactorizationOnly( PHI,ff, g);
    10751075   /* } */
    10761076  }
     
    11071107  // ===============================================
    11081108
    1109  
    1110         CFFList Q =Mysqrfree(f);
    1111 //     
    1112 //      cout << Q << endl;
     1109
     1110        CFFList Q =Mysqrfree(f);
     1111//
     1112//        cout << Q << endl;
    11131113//
    11141114
     
    11231123  {
    11241124
    1125         if( i.getItem().factor().level() < 0 ) ;
    1126         else
    1127         {
     1125        if( i.getItem().factor().level() < 0 ) ;
     1126        else
     1127        {
    11281128    if( ( degree(i.getItem().factor(),x) == 0 || degree( i.getItem().factor(),y) == 0) ) {
    11291129      // case: univariate
     
    11311131    else // case: bivariate
    11321132    {
    1133       exponent =  i.getItem().exp();       // global variable 
    1134           CanonicalForm dumm = i.getItem().factor();
    1135           dumm = dumm.LC();
    1136           if( dumm.level() > 0 ){ dumm =  1;  }
    1137       bifacSqrFree(i.getItem().factor()/dumm ); 
     1133      exponent =  i.getItem().exp();       // global variable
     1134          CanonicalForm dumm = i.getItem().factor();
     1135          dumm = dumm.LC();
     1136          if( dumm.level() > 0 ){ dumm =  1;  }
     1137      bifacSqrFree(i.getItem().factor()/dumm );
    11381138    }
    11391139  }}
     
    11561156
    11571157  if( min >= 32003 ) return ( 32003 ); // this is the maximum
    1158  
     1158
    11591159  // Find the smallest poosible prime
    11601160  while ( cf_getPrime(nr) < min)  { nr++;  }
     
    11841184  //cout << gl_RL<<endl;
    11851185
    1186         if( sw )
    1187         {
    1188                 Variable W('W');
    1189                 for( CFFListIterator i=gl_RL; i.hasItem(); i++)
    1190             {
    1191                         c = i.getItem().factor();
    1192                         c = c(W,y);
    1193                         c = c(y,x);
    1194                         c = c(x,W);
    1195                         aL.append( CFFactor( c, i.getItem().exp() ));
    1196                 }
    1197 
    1198                 f = f(W,y); f=f(y,x); f=f(x,W);
    1199         }
    1200         else aL = gl_RL;
    1201 
    1202         gl_RL = aL;
    1203 
    1204         //cout << aL;
     1186        if( sw )
     1187        {
     1188                Variable W('W');
     1189                for( CFFListIterator i=gl_RL; i.hasItem(); i++)
     1190            {
     1191                        c = i.getItem().factor();
     1192                        c = c(W,y);
     1193                        c = c(y,x);
     1194                        c = c(x,W);
     1195                        aL.append( CFFactor( c, i.getItem().exp() ));
     1196                }
     1197
     1198                f = f(W,y); f=f(y,x); f=f(x,W);
     1199        }
     1200        else aL = gl_RL;
     1201
     1202        gl_RL = aL;
     1203
     1204        //cout << aL;
    12051205
    12061206
     
    12171217
    12181218//  cout << "\n* Test auf Korrektheit ...";
    1219  
    1220  
     1219
     1220
    12211221  for( CFFListIterator i=aL; i.hasItem(); i++)
    12221222    {
    12231223      ff *= power(i.getItem().factor(),  i.getItem().exp() );
    12241224      //      cout << " ff = " << ff
    1225       //           << "\n a^b = " << i.getItem().factor() << "  ^ " <<   i.getItem().exp() << endl;
     1225      //           << "\n a^b = " << i.getItem().factor() << "  ^ " <<   i.getItem().exp() << endl;
    12261226    }
    12271227  c = f.LC()/ff.LC();
     
    12311231
    12321232//   cout << "\n\nOriginal f = " << f << "\n\nff = " << ff
    1233 //         << "\n\nDiff = " << f-ff << endl << "Quot "<< f/ff <<endl;
     1233//           << "\n\nDiff = " << f-ff << endl << "Quot "<< f/ff <<endl;
    12341234//  cout << "degree 0: " << c << endl;
    1235  
    1236  
     1235
     1236
    12371237#ifndef NOSTREAMIO
    1238   if( f != ff ) cout << "\n\nOriginal f = " << f << "\n\nff = " << ff 
    1239                      << "\n\nDiff = " << f-ff << endl << "Quot "<< f/ff <<endl;
     1238  if( f != ff ) cout << "\n\nOriginal f = " << f << "\n\nff = " << ff
     1239                     << "\n\nDiff = " << f-ff << endl << "Quot "<< f/ff <<endl;
    12401240#endif
    12411241  ASSERT( f==ff, "Wrong rational factorization. Abborting!");
    12421242//  cout << "  [OK]\n";
    1243    
     1243
    12441244}
    12451245//--<>---------------------------------
     
    12541254
    12551255  ASSERT( ch==0 && !isOn(SW_RATIONAL), "Integer numbers not allowed" );
    1256  
     1256
    12571257
    12581258  // === Check the characteristic ===
    1259   if( ch != 0 ) 
     1259  if( ch != 0 )
    12601260  {
    12611261    ch2 = findCharacteristic(f);
     
    12671267      // PROVISORISCH
    12681268      //cerr << "\n Characteristic is too small!"
    1269         //  << "\n The result might be wrong!\n\n";
     1269        //  << "\n The result might be wrong!\n\n";
    12701270      exit(1);
    12711271
     
    12731273  }
    12741274
    1275         Variable W('W');
    1276         CanonicalForm l;
    1277         int sw = 0;
    1278 
    1279         if( degree(f,x) < degree(f,y) ) {
    1280                 f = f(W,x);   f = f(x,y); f=f(y,W); 
    1281                 sw = 1;
    1282         }
    1283                 l = f.LC();
    1284 
    1285                 if( l.level()<0 ) { f = f/f.LC(); gl_RL.append( CFFactor(l,1) ); }
     1275         Variable W('W');
     1276          CanonicalForm l;
     1277        int sw = 0;
     1278
     1279        if( degree(f,x) < degree(f,y) ) {
     1280                f = f(W,x);   f = f(x,y); f=f(y,W);
     1281                sw = 1;
     1282        }
     1283                l = f.LC();
     1284
     1285                if( l.level()<0 ) { f = f/f.LC(); gl_RL.append( CFFactor(l,1) ); }
    12861286
    12871287
  • factory/bifac.h

    rc840d9 r806c18  
    4444////////////////////////////////////////////////////////////////
    4545  public:
    46 //////////////////////////////////////////////////////////////// 
     46////////////////////////////////////////////////////////////////
    4747
    4848  // === KONST-/ DESTRUKTOREN ====
     
    7878  void     unifac(CanonicalForm f, int grad);
    7979  CanonicalForm RationalFactor (CanonicalForm phi, CanonicalForm f, \
    80                                 CanonicalForm fx, CanonicalForm g);
     80                                CanonicalForm fx, CanonicalForm g);
    8181  void   RationalFactorizationOnly (CFFList Phis, CanonicalForm f, CanonicalForm g);
    8282  CFList getAbsoluteFactors (CanonicalForm f1, CanonicalForm phi);
     
    8484  void   bifacSqrFree( CanonicalForm f );
    8585  void   bifacMain(CanonicalForm f);
    86  
     86
    8787
    8888  // === Variable =======
    8989  CFFList gl_RL;    // where to store the rational factorization
    9090  CFList  gl_AL;    // where to store the absolute factorization
    91   bool   absolute;  // Compute an absolute factorization as well? 
    92   int    exponent;  // 
     91  bool   absolute;  // Compute an absolute factorization as well?
     92  int    exponent;  //
    9393};
    9494
  • factory/bifacConfig.h

    rc840d9 r806c18  
    1 /*  =================================================================== 
     1/*  ===================================================================
    22    GLOBAL COMPILE OPTIONS FOR BIFAC
    33    =================================================================== */
     
    4040
    4141
    42 /*  =================================================================== 
     42/*  ===================================================================
    4343    GLOBAL COMPILE OPTIONS FOR MULTIFAC
    4444    =================================================================== */
  • factory/canonicalform.cc

    rc840d9 r806c18  
    14421442            return g.value->bgcdcoeff( f.value );
    14431443        else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) )
    1444         {
     1444        {
    14451445            // calculate gcd using standard integer
    14461446            // arithmetic
     
    14521452            // swap fInt and gInt
    14531453            if ( gInt > fInt )
    1454             {
     1454            {
    14551455                int swap = gInt;
    14561456                gInt = fInt;
     
    14601460            // now, 0 <= gInt <= fInt.  Start the loop.
    14611461            while ( gInt )
    1462             {
     1462            {
    14631463                // calculate (fInt, gInt) = (gInt, fInt%gInt)
    14641464                int r = fInt % gInt;
     
    14691469            return CanonicalForm( fInt );
    14701470        }
    1471         else
     1471        else
    14721472            // we do not go for maximal speed for these stupid
    14731473            // special cases
  • factory/canonicalform.h

    rc840d9 r806c18  
    4949inline int is_imm ( const InternalCF * const ptr )
    5050{
    51     // returns 0 if ptr is not immediate       
     51    // returns 0 if ptr is not immediate
    5252    return ( ((int)((long)ptr)) & 3 );
    5353}
     
    325325{
    326326    if ( f.level() > 0 )
    327         return power( f.mvar(), f.degree() ) * f.LC();
     327        return power( f.mvar(), f.degree() ) * f.LC();
    328328    else
    329         return f;
     329        return f;
    330330}
    331331
  • factory/cf_binom.cc

    rc840d9 r806c18  
    3434
    3535    if ( ! initialized ) {
    36         initialized = true;
    37         ptZ = new CFArray[MAXPT+1];
    38         ptF = new CFArray[MAXPT+1];
    39         int i, j;
    40         ptZ[0] = CFArray(1); ptZ[0][0] = 1;
    41         ptF[0] = CFArray(1);
    42         for ( i = 1; i <= INITPT; i++ ) {
    43             ptF[i] = CFArray(i+1);
    44             ptZ[i] = CFArray(i+1);
    45             (ptZ[i])[0] = 1;
    46             for ( j = 1; j < i; j++ )
    47                 (ptZ[i])[j] = (ptZ[i-1])[j-1] + (ptZ[i-1])[j];
    48             (ptZ[i])[i] = 1;
    49         }
    50         for ( i = INITPT+1; i <= MAXPT; i++ ) {
    51             ptF[i] = CFArray(i+1);
    52             ptZ[i] = CFArray(i+1);
    53         }
    54         ptZmax = INITPT;
    55         ptFmax = 0;
     36        initialized = true;
     37        ptZ = new CFArray[MAXPT+1];
     38        ptF = new CFArray[MAXPT+1];
     39        int i, j;
     40        ptZ[0] = CFArray(1); ptZ[0][0] = 1;
     41        ptF[0] = CFArray(1);
     42        for ( i = 1; i <= INITPT; i++ ) {
     43            ptF[i] = CFArray(i+1);
     44            ptZ[i] = CFArray(i+1);
     45            (ptZ[i])[0] = 1;
     46            for ( j = 1; j < i; j++ )
     47                (ptZ[i])[j] = (ptZ[i-1])[j-1] + (ptZ[i-1])[j];
     48            (ptZ[i])[i] = 1;
     49        }
     50        for ( i = INITPT+1; i <= MAXPT; i++ ) {
     51            ptF[i] = CFArray(i+1);
     52            ptZ[i] = CFArray(i+1);
     53        }
     54        ptZmax = INITPT;
     55        ptFmax = 0;
    5656    }
    5757}
     
    6161{
    6262    if ( n == 0 )
    63         return 1;
     63        return 1;
    6464    else if ( n == 1 )
    65         return x + a;
     65        return x + a;
    6666    else if ( getCharacteristic() == 0 ) {
    67         if ( n <= MAXPT ) {
    68             if ( n > ptZmax ) {
    69                 int i, j;
    70                 for ( i = ptZmax+1; i <= n; i++ ) {
    71                     (ptZ[i])[0] = 1;
    72                     for ( j = 1; j < i; j++ )
    73                         (ptZ[i])[j] = (ptZ[i-1])[j-1] + (ptZ[i-1])[j];
    74                     (ptZ[i])[i] = 1;
    75                 }
    76                 ptZmax = n;
    77             }
    78             CanonicalForm result = 0, apower = 1;
    79             int k;
    80             for ( k = n; k >= 0; k-- ) {
    81                 result += power( x, k ) * apower * (ptZ[n])[k];
    82                 if ( k != 0 )
    83                     apower *= a;
    84             }
    85             return result;
    86         }
    87         else {
    88             CanonicalForm result = binomialpower( x, a, MAXPT );
    89             CanonicalForm xa = x + a;
    90             int i;
    91             for ( i = MAXPT; i < n; i++ )
    92                 result *= xa;
    93             return result;
    94         }
     67        if ( n <= MAXPT ) {
     68            if ( n > ptZmax ) {
     69                int i, j;
     70                for ( i = ptZmax+1; i <= n; i++ ) {
     71                    (ptZ[i])[0] = 1;
     72                    for ( j = 1; j < i; j++ )
     73                        (ptZ[i])[j] = (ptZ[i-1])[j-1] + (ptZ[i-1])[j];
     74                    (ptZ[i])[i] = 1;
     75                }
     76                ptZmax = n;
     77            }
     78            CanonicalForm result = 0, apower = 1;
     79            int k;
     80            for ( k = n; k >= 0; k-- ) {
     81                result += power( x, k ) * apower * (ptZ[n])[k];
     82                if ( k != 0 )
     83                    apower *= a;
     84            }
     85            return result;
     86        }
     87        else {
     88            CanonicalForm result = binomialpower( x, a, MAXPT );
     89            CanonicalForm xa = x + a;
     90            int i;
     91            for ( i = MAXPT; i < n; i++ )
     92                result *= xa;
     93            return result;
     94        }
    9595    }
    9696    else {
    97         if ( getCharacteristic() != charac || gfdeg != getGFDegree() ) {
    98             ptFmax = 0;
    99             charac = getCharacteristic();
    100             gfdeg = getGFDegree();
    101             (ptF[0])[0] = 1;
    102         }
    103         if ( n <= MAXPT ) {
    104             if ( n > ptFmax ) {
    105                 int i, j;
    106                 for ( i = ptFmax+1; i <= n; i++ ) {
    107                     (ptF[i])[0] = 1;
    108                     for ( j = 1; j < i; j++ )
    109                         (ptF[i])[j] = (ptF[i-1])[j-1] + (ptF[i-1])[j];
    110                     (ptF[i])[i] = 1;
    111                 }
    112                 ptFmax = n;
    113             }
    114             CanonicalForm result = 0, apower = 1;
    115             int k;
    116             for ( k = n; k >= 0; k-- ) {
    117                 result += power( x, k ) * apower * (ptF[n])[k];
    118                 if ( k != 0 )
    119                     apower *= a;
    120             }
    121             return result;
    122         }
    123         else {
    124             CanonicalForm result = binomialpower( x, a, MAXPT );
    125             CanonicalForm xa = x + a;
    126             int i;
    127             for ( i = MAXPT; i < n; i++ )
    128                 result *= xa;
    129             return result;
    130         }
     97        if ( getCharacteristic() != charac || gfdeg != getGFDegree() ) {
     98            ptFmax = 0;
     99            charac = getCharacteristic();
     100            gfdeg = getGFDegree();
     101            (ptF[0])[0] = 1;
     102        }
     103        if ( n <= MAXPT ) {
     104            if ( n > ptFmax ) {
     105                int i, j;
     106                for ( i = ptFmax+1; i <= n; i++ ) {
     107                    (ptF[i])[0] = 1;
     108                    for ( j = 1; j < i; j++ )
     109                        (ptF[i])[j] = (ptF[i-1])[j-1] + (ptF[i-1])[j];
     110                    (ptF[i])[i] = 1;
     111                }
     112                ptFmax = n;
     113            }
     114            CanonicalForm result = 0, apower = 1;
     115            int k;
     116            for ( k = n; k >= 0; k-- ) {
     117                result += power( x, k ) * apower * (ptF[n])[k];
     118                if ( k != 0 )
     119                    apower *= a;
     120            }
     121            return result;
     122        }
     123        else {
     124            CanonicalForm result = binomialpower( x, a, MAXPT );
     125            CanonicalForm xa = x + a;
     126            int i;
     127            for ( i = MAXPT; i < n; i++ )
     128                result *= xa;
     129            return result;
     130        }
    131131    }
    132132}
  • factory/cf_char.cc

    rc840d9 r806c18  
    3838        theCharacteristic = c;
    3939        ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
    40         if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
     40        if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
    4141        ff_setprime( c );
    4242        resetFPT();
  • factory/cf_chinese.cc

    rc840d9 r806c18  
    162162{
    163163   //assume(P>0);
    164    // assume !isOn(SW_RATIONAL): mod is a no-op otherwise 
     164   // assume !isOn(SW_RATIONAL): mod is a no-op otherwise
    165165   if (N<0) N +=P;
    166166   CanonicalForm A,B,C,D,E;
     
    171171        if (2*N*N<P)
    172172        {
    173            On(SW_RATIONAL);
    174            N /=B;
    175            Off(SW_RATIONAL);
     173           On(SW_RATIONAL);
     174           N /=B;
     175           Off(SW_RATIONAL);
    176176           return(N);
    177177        }
  • factory/cf_cyclo.cc

    rc840d9 r806c18  
    1111 *   (c) by The SINGULAR Team, see LICENSE file
    1212 *
    13  * @internal 
     13 * @internal
    1414 * @version \$Id$
    1515 *
     
    3131/// function may fail if integer contains primes which exceed the largest prime
    3232/// in our table
    33 int* integerFactorizer (const long integer, int& length, bool& fail) 
     33int* integerFactorizer (const long integer, int& length, bool& fail)
    3434{
    35   ASSERT (integer != 0 && integer != 1 && integer != -1, 
    36           "non-zero non-unit expected"); 
     35  ASSERT (integer != 0 && integer != 1 && integer != -1,
     36          "non-zero non-unit expected");
    3737  int* result;
    3838  length= 0;
     
    4343
    4444  int exp= 0;
    45   while ((i != 1) && (i%2 == 0)) 
     45  while ((i != 1) && (i%2 == 0))
    4646  {
    4747    i /= 2;
    4848    exp++;
    4949  }
    50   if (exp != 0) 
     50  if (exp != 0)
    5151  {
    5252    result= new int [exp];
     
    5454      result[k]= 2;
    5555    length += exp;
    56   } 
     56  }
    5757  if (i == 1) return result;
    5858
     
    6161  int* buf;
    6262  int next_prime;
    63   while ((i != 1) && (j < 31937)) 
     63  while ((i != 1) && (j < 31937))
    6464  {
    6565    next_prime= cf_getPrime (j);
    66     while ((i != 1) && (i%next_prime == 0)) 
     66    while ((i != 1) && (i%next_prime == 0))
    6767    {
    6868      i /= next_prime;
    6969      exp++;
    70     } 
    71     if (exp != 0) 
     70    }
     71    if (exp != 0)
    7272    {
    73       buf= result; 
     73      buf= result;
    7474      result= new int [length + exp];
    75       for (int k= 0; k < length; k++) 
     75      for (int k= 0; k < length; k++)
    7676        result [k]= buf[k];
    7777      for (int k= 0; k < exp; k++)
    7878        result [k + length]= next_prime;
    79       length += exp; 
     79      length += exp;
    8080    }
    8181    exp= 0;
     
    9696  int* buf;
    9797  result[0]= factors [0];
    98   for (int i= 1; i < factors_length; i++) 
     98  for (int i= 1; i < factors_length; i++)
    9999  {
    100     if (factors[i - 1] != factors[i]) 
     100    if (factors[i - 1] != factors[i])
    101101    {
    102102      buf= result;
     
    104104      for (int j= 0; j < length; j++)
    105105        result[j]= buf [j];
    106       result[length]= factors[i]; 
    107       length++;   
     106      result[length]= factors[i];
     107      length++;
    108108    }
    109109  }
     
    113113/// compute the n-th cyclotomic polynomial,
    114114/// function may fail if integer_factorizer fails to factorize n
    115 CanonicalForm cyclotomicPoly (int n, bool& fail) 
     115CanonicalForm cyclotomicPoly (int n, bool& fail)
    116116{
    117117  fail= false;
     
    133133  {
    134134    result= result (power (x, distinct_factors[i]), x)/result;
    135     prod *= distinct_factors[i]; 
     135    prod *= distinct_factors[i];
    136136  }
    137137  return result (power (x, n/prod), x);
     
    140140#ifdef HAVE_NTL
    141141/// checks if alpha is a primitive element, alpha is assumed to be an algebraic
    142 /// variable over some finite prime field 
    143 bool isPrimitive (const Variable& alpha, bool& fail) 
     142/// variable over some finite prime field
     143bool isPrimitive (const Variable& alpha, bool& fail)
    144144{
    145145  int p= getCharacteristic();
  • factory/cf_cyclo.h

    rc840d9 r806c18  
    1313 *   (c) by The SINGULAR Team, see LICENSE file
    1414 *
    15  * @internal 
     15 * @internal
    1616 * @version \$Id$
    1717 *
  • factory/cf_eval.cc

    rc840d9 r806c18  
    1515{
    1616    if ( this != &e ) {
    17         values = e.values;
     17        values = e.values;
    1818    }
    1919    return *this;
     
    2424{
    2525    if ( f.inCoeffDomain() || f.level() < values.min() )
    26         return f;
     26        return f;
    2727    else  if ( f.level() < values.max() )
    28         return evalCF( f, values, values.min(), f.level() );
     28        return evalCF( f, values, values.min(), f.level() );
    2929    else
    30         return evalCF( f, values, values.min(), values.max() );
     30        return evalCF( f, values, values.min(), values.max() );
    3131}
    3232
     
    3535{
    3636    if ( i > j )
    37         return f;
     37        return f;
    3838    return evalCF( f, values, i, j );
    3939}
     
    4444    int n = values.max();
    4545    for ( int i = values.min(); i <= n; i++ )
    46         values[i] += 1;
     46        values[i] += 1;
    4747}
    4848
     
    6060{
    6161    if ( m > n )
    62         return f;
     62        return f;
    6363    else {
    64         CanonicalForm result = f;
    65         while ( n >= m ) {
    66             result = result( a[n], Variable( n ) );
    67             n--;
    68         }
    69         return result;
     64        CanonicalForm result = f;
     65        while ( n >= m ) {
     66            result = result( a[n], Variable( n ) );
     67            n--;
     68        }
     69        return result;
    7070    }
    7171//    iterated method turned out to be faster than
  • factory/cf_factor.cc

    rc840d9 r806c18  
    129129      {
    130130        mpz_t m;
    131         gmp_numerator(f,m);
     131        gmp_numerator(f,m);
    132132        char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
    133133        str = mpz_get_str( str, 10, m );
    134134        printf("%s",str);
    135135        delete[] str;
    136         mpz_clear(m);
     136        mpz_clear(m);
    137137      }
    138138      else if (f.inQ())
    139139      {
    140140        mpz_t m;
    141         gmp_numerator(f,m);
     141        gmp_numerator(f,m);
    142142        char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
    143143        str = mpz_get_str( str, 10, m );
    144144        printf("%s/",str);
    145145        delete[] str;
    146         mpz_clear(m);
     146        mpz_clear(m);
    147147        gmp_denominator(f,m);
    148148        str = new char[mpz_sizeinbase( m, 10 ) + 2];
     
    150150        printf("%s",str);
    151151        delete[] str;
    152         mpz_clear(m);
     152        mpz_clear(m);
    153153      }
    154154    #else
  • factory/cf_factory.cc

    rc840d9 r806c18  
    2929{
    3030    if ( currenttype == IntegerDomain )
    31         if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
    32             return int2imm( value );
    33         else
    34             return new InternalInteger( value );
     31        if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
     32            return int2imm( value );
     33        else
     34            return new InternalInteger( value );
    3535//     else  if ( currenttype == RationalDomain )
    36 //      if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
    37 //          return int2imm( value );
    38 //      else
    39 //          return new InternalRational( value );
     36//         if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
     37//             return int2imm( value );
     38//         else
     39//             return new InternalRational( value );
    4040    else  if ( currenttype == FiniteFieldDomain )
    41         return int2imm_p( ff_norm( value ) );
     41        return int2imm_p( ff_norm( value ) );
    4242    else  if ( currenttype == GaloisFieldDomain )
    43         return int2imm_gf( gf_int2gf( value ) );
     43        return int2imm_gf( gf_int2gf( value ) );
    4444    else  if ( currenttype == PrimePowerDomain )
    45         return new InternalPrimePower( value );
    46     else {
    47         ASSERT( 0, "illegal basic domain!" );
    48         return 0;
     45        return new InternalPrimePower( value );
     46    else {
     47        ASSERT( 0, "illegal basic domain!" );
     48        return 0;
    4949    }
    5050}
     
    5454{
    5555    if ( type == IntegerDomain )
    56         if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
    57             return int2imm( value );
    58         else
    59             return new InternalInteger( value );
     56        if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
     57            return int2imm( value );
     58        else
     59            return new InternalInteger( value );
    6060//     else  if ( type == RationalDomain )
    61 //      if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
    62 //          return int2imm( value );
    63 //      else
    64 //          return new InternalRational( value );
     61//         if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
     62//             return int2imm( value );
     63//         else
     64//             return new InternalRational( value );
    6565    else  if ( type == FiniteFieldDomain )
    66         return int2imm_p( ff_norm( value ) );
     66        return int2imm_p( ff_norm( value ) );
    6767    else  if ( type == GaloisFieldDomain )
    68         return int2imm_gf( gf_int2gf( value ) );
     68        return int2imm_gf( gf_int2gf( value ) );
    6969    else  if ( type == PrimePowerDomain )
    70         return new InternalPrimePower( value );
    71     else {
    72         ASSERT1( 0, "illegal basic domain (type = %d)!", type );
    73         return 0;
     70        return new InternalPrimePower( value );
     71    else {
     72        ASSERT1( 0, "illegal basic domain (type = %d)!", type );
     73        return 0;
    7474    }
    7575}
     
    7979{
    8080    if ( currenttype == IntegerDomain ) {
    81         InternalInteger * dummy = new InternalInteger( str );
    82         if ( dummy->is_imm() ) {
    83             InternalCF * res = int2imm( dummy->intval() );
    84             delete dummy;
    85             return res;
    86         }
    87         else
    88             return dummy;
     81        InternalInteger * dummy = new InternalInteger( str );
     82        if ( dummy->is_imm() ) {
     83            InternalCF * res = int2imm( dummy->intval() );
     84            delete dummy;
     85            return res;
     86        }
     87        else
     88            return dummy;
    8989    }
    9090//     else  if ( currenttype == RationalDomain ) {
    91 //      InternalRational * dummy = new InternalRational( str );
    92 //      if ( dummy->is_imm() ) {
    93 //          InternalCF * res = int2imm( dummy->intval() );
    94 //          delete dummy;
    95 //          return res;
    96 //      }
    97 //      else
    98 //          return dummy;
     91//         InternalRational * dummy = new InternalRational( str );
     92//         if ( dummy->is_imm() ) {
     93//             InternalCF * res = int2imm( dummy->intval() );
     94//             delete dummy;
     95//             return res;
     96//         }
     97//         else
     98//             return dummy;
    9999//     }
    100100    else  if ( currenttype == FiniteFieldDomain ) {
    101         InternalInteger * dummy = new InternalInteger( str );
    102         InternalCF * res = int2imm_p( dummy->intmod( ff_prime ) );
    103         delete dummy;
    104         return res;
     101        InternalInteger * dummy = new InternalInteger( str );
     102        InternalCF * res = int2imm_p( dummy->intmod( ff_prime ) );
     103        delete dummy;
     104        return res;
    105105    }
    106106    else  if ( currenttype == GaloisFieldDomain ) {
    107         InternalInteger * dummy = new InternalInteger( str );
    108         InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
    109         delete dummy;
    110         return res;
     107        InternalInteger * dummy = new InternalInteger( str );
     108        InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
     109        delete dummy;
     110        return res;
    111111    }
    112112    else  if ( currenttype == PrimePowerDomain )
    113         return new InternalPrimePower( str );
    114     else {
    115         ASSERT( 0, "illegal basic domain!" );
    116         return 0;
     113        return new InternalPrimePower( str );
     114    else {
     115        ASSERT( 0, "illegal basic domain!" );
     116        return 0;
    117117    }
    118118}
     
    122122{
    123123    if ( currenttype == IntegerDomain ) {
    124         InternalInteger * dummy = new InternalInteger( str, base );
    125         if ( dummy->is_imm() ) {
    126             InternalCF * res = int2imm( dummy->intval() );
    127             delete dummy;
    128             return res;
    129         }
    130         else
    131             return dummy;
     124        InternalInteger * dummy = new InternalInteger( str, base );
     125        if ( dummy->is_imm() ) {
     126            InternalCF * res = int2imm( dummy->intval() );
     127            delete dummy;
     128            return res;
     129        }
     130        else
     131            return dummy;
    132132    }
    133133//     else  if ( currenttype == RationalDomain ) {
    134 //      InternalRational * dummy = new InternalRational( str );
    135 //      if ( dummy->is_imm() ) {
    136 //          InternalCF * res = int2imm( dummy->intval() );
    137 //          delete dummy;
    138 //          return res;
    139 //      }
    140 //      else
    141 //          return dummy;
     134//         InternalRational * dummy = new InternalRational( str );
     135//         if ( dummy->is_imm() ) {
     136//             InternalCF * res = int2imm( dummy->intval() );
     137//             delete dummy;
     138//             return res;
     139//         }
     140//         else
     141//             return dummy;
    142142//     }
    143143    else  if ( currenttype == FiniteFieldDomain ) {
    144         InternalInteger * dummy = new InternalInteger( str, base );
    145         InternalCF * res = int2imm_p( dummy->intmod( ff_prime ) );
    146         delete dummy;
    147         return res;
     144        InternalInteger * dummy = new InternalInteger( str, base );
     145        InternalCF * res = int2imm_p( dummy->intmod( ff_prime ) );
     146        delete dummy;
     147        return res;
    148148    }
    149149    else  if ( currenttype == GaloisFieldDomain ) {
    150         InternalInteger * dummy = new InternalInteger( str, base );
    151         InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
    152         delete dummy;
    153         return res;
     150        InternalInteger * dummy = new InternalInteger( str, base );
     151        InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
     152        delete dummy;
     153        return res;
    154154    }
    155155    else  if ( currenttype == PrimePowerDomain )
    156         return new InternalPrimePower( str, base );
    157     else {
    158         ASSERT( 0, "illegal basic domain!" );
    159         return 0;
     156        return new InternalPrimePower( str, base );
     157    else {
     158        ASSERT( 0, "illegal basic domain!" );
     159        return 0;
    160160    }
    161161}
     
    165165{
    166166    if ( type == IntegerDomain ) {
    167         InternalInteger * dummy = new InternalInteger( str );
    168         if ( dummy->is_imm() ) {
    169             InternalCF * res = int2imm( dummy->intval() );
    170             delete dummy;
    171             return res;
    172         }
    173         else
    174             return dummy;
     167        InternalInteger * dummy = new InternalInteger( str );
     168        if ( dummy->is_imm() ) {
     169            InternalCF * res = int2imm( dummy->intval() );
     170            delete dummy;
     171            return res;
     172        }
     173        else
     174            return dummy;
    175175    }
    176176//     else  if ( type == RationalDomain ) {
    177 //      InternalRational * dummy = new InternalRational( str );
    178 //      if ( dummy->is_imm() ) {
    179 //          InternalCF * res = int2imm( dummy->intval() );
    180 //          delete dummy;
    181 //          return res;
    182 //      }
    183 //      else
    184 //          return dummy;
     177//         InternalRational * dummy = new InternalRational( str );
     178//         if ( dummy->is_imm() ) {
     179//             InternalCF * res = int2imm( dummy->intval() );
     180//             delete dummy;
     181//             return res;
     182//         }
     183//         else
     184//             return dummy;
    185185//     }
    186186    else  if ( type == FiniteFieldDomain ) {
    187         InternalInteger * dummy = new InternalInteger( str );
    188         InternalCF * res = int2imm( dummy->intmod( ff_prime ) );
    189         delete dummy;
    190         return res;
     187        InternalInteger * dummy = new InternalInteger( str );
     188        InternalCF * res = int2imm( dummy->intmod( ff_prime ) );
     189        delete dummy;
     190        return res;
    191191    }
    192192    else  if ( type == GaloisFieldDomain ) {
    193         InternalInteger * dummy = new InternalInteger( str );
    194         InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
    195         delete dummy;
    196         return res;
     193        InternalInteger * dummy = new InternalInteger( str );
     194        InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
     195        delete dummy;
     196        return res;
    197197    }
    198198    else  if ( type == PrimePowerDomain )
    199         return new InternalPrimePower( str );
    200     else {
    201         ASSERT( 0, "illegal basic domain!" );
    202         return 0;
     199        return new InternalPrimePower( str );
     200    else {
     201        ASSERT( 0, "illegal basic domain!" );
     202        return 0;
    203203    }
    204204}
     
    208208{
    209209    if ( nonimm )
    210         if ( type == IntegerDomain )
    211             return new InternalInteger( value );
    212         else  if ( type == RationalDomain )
    213             return new InternalRational( value );
    214         else {
    215             ASSERT( 0, "illegal basic domain!" );
    216             return 0;
    217         }
    218     else
    219         return CFFactory::basic( type, value );
     210        if ( type == IntegerDomain )
     211            return new InternalInteger( value );
     212         else  if ( type == RationalDomain )
     213             return new InternalRational( value );
     214        else {
     215            ASSERT( 0, "illegal basic domain!" );
     216            return 0;
     217        }
     218    else
     219        return CFFactory::basic( type, value );
    220220}
    221221
     
    224224{
    225225    if ( currenttype != IntegerDomain ) {
    226         InternalPrimePower * dummy = new InternalPrimePower( num );
    227         return (InternalCF*)(dummy->normalize_myself());
    228     }
    229     else
    230         return new InternalInteger( num );
     226        InternalPrimePower * dummy = new InternalPrimePower( num );
     227        return (InternalCF*)(dummy->normalize_myself());
     228    }
     229    else
     230        return new InternalInteger( num );
    231231}
    232232
     
    242242{
    243243    if ( normalize ) {
    244         InternalRational * result = new InternalRational( num, den );
    245         return result->normalize_myself();
    246     }
    247     else
    248         return new InternalRational( num, den );
     244        InternalRational * result = new InternalRational( num, den );
     245        return result->normalize_myself();
     246    }
     247    else
     248        return new InternalRational( num, den );
    249249}
    250250
     
    253253{
    254254    if ( v.level() == LEVELBASE )
    255         return c.getval();
    256     else
    257         return new InternalPoly( v, exp, c );
     255        return c.getval();
     256    else
     257        return new InternalPoly( v, exp, c );
    258258}
    259259
     
    262262{
    263263    if ( v.level() == LEVELBASE )
    264         return CFFactory::basic( 1 );
    265     else
    266         return new InternalPoly( v, exp, 1 );
     264        return CFFactory::basic( 1 );
     265    else
     266        return new InternalPoly( v, exp, 1 );
    267267}
    268268
     
    272272    MP_INT dummy;
    273273    if ( value->levelcoeff() == IntegerDomain )
    274         mpz_init_set( &dummy, &InternalInteger::MPI( value ) );
     274        mpz_init_set( &dummy, &InternalInteger::MPI( value ) );
    275275    else  if ( symmetric ) {
    276         mpz_init( &dummy );
    277         if ( mpz_cmp( &InternalPrimePower::primepowhalf, &InternalPrimePower::MPI( value ) ) < 0 )
    278             mpz_sub( &dummy, &InternalPrimePower::MPI( value ), &InternalPrimePower::primepow );
    279         else
    280             mpz_set( &dummy, &InternalPrimePower::MPI( value ) );
    281     }
    282     else
    283         mpz_init_set( &dummy, &InternalPrimePower::MPI( value ) );
     276        mpz_init( &dummy );
     277        if ( mpz_cmp( &InternalPrimePower::primepowhalf, &InternalPrimePower::MPI( value ) ) < 0 )
     278            mpz_sub( &dummy, &InternalPrimePower::MPI( value ), &InternalPrimePower::primepow );
     279        else
     280            mpz_set( &dummy, &InternalPrimePower::MPI( value ) );
     281    }
     282    else
     283        mpz_init_set( &dummy, &InternalPrimePower::MPI( value ) );
    284284    return dummy;
    285285}
  • factory/cf_gcd_charp.cc

    rc840d9 r806c18  
    4141
    4242
    43 static CanonicalForm 
     43static CanonicalForm
    4444contentWRT0(const CanonicalForm & F, const int lev, const int lev0)
    4545// Computes the content of a polynomial, considering the variables of level
     
    6464      {
    6565        CanonicalForm cc=i.coeff();
    66         if (cc.level() > lev0) 
     66        if (cc.level() > lev0)
    6767          pol = contentWRT0(cc, lev, lev0-1 );
    6868        else
     
    7979}
    8080
    81 static CanonicalForm 
     81static CanonicalForm
    8282contentWRT(const CanonicalForm & F, const int lev)
    8383// Computes the content of a polynomial, considering the variables of level
     
    108108      {
    109109        CanonicalForm cc=i.coeff();
    110         if (cc.level() > lev) 
     110        if (cc.level() > lev)
    111111          pol = contentWRT0(cc, lev, cc.level());
    112112        else
     
    364364  //  cout << "pow: " << ipower(p, k) << endl;
    365365  //}
    366  
     366
    367367  CFMap M,N;
    368368  compress(A,B,M,N);
     
    538538          On(SW_USE_GCD_P);
    539539          return temp;
    540         } 
     540        }
    541541      }
    542542      else
     
    560560          On(SW_USE_GCD_P);
    561561          return temp;
    562         } 
     562        }
    563563      }
    564564    }
  • factory/cf_gcd_smallp.cc

    rc840d9 r806c18  
    66 * @date 22.10.2009
    77 *
    8  * This file implements the GCD of two polynomials over \f$ F_{p} \f$ , 
    9  * \f$ F_{p}(\alpha ) \f$ or GF based on Alg. 7.2. as described in "Algorithms 
     8 * This file implements the GCD of two polynomials over \f$ F_{p} \f$ ,
     9 * \f$ F_{p}(\alpha ) \f$ or GF based on Alg. 7.2. as described in "Algorithms
    1010 * for Computer Algebra" by Geddes, Czapor, Labahnn
    1111 *
     
    1313 *   (c) by The SINGULAR Team, see LICENSE file
    1414 *
    15  * @internal 
     15 * @internal
    1616 * @version \$Id$
    1717 *
     
    4646TIMING_DEFINE_PRINT(newton_interpolation);
    4747
    48 /// compressing two polynomials F and G, M is used for compressing, 
     48/// compressing two polynomials F and G, M is used for compressing,
    4949/// N to reverse the compression
    5050static inline
    5151int myCompress (const CanonicalForm& F, const CanonicalForm& G, CFMap & M,
    52                 CFMap & N, bool& topLevel) 
    53 { 
     52                CFMap & N, bool& topLevel)
     53{
    5454  int n= tmax (F.level(), G.level());
    5555  int * degsf= new int [n + 1];
     
    5858  for (int i = 0; i <= n; i++)
    5959    degsf[i]= degsg[i]= 0;
    60    
     60
    6161  degsf= degrees (F, degsf);
    6262  degsg= degrees (G, degsg);
    63  
     63
    6464  int both_non_zero= 0;
    6565  int f_zero= 0;
     
    6767  int both_zero= 0;
    6868
    69   if (topLevel) 
    70   {
    71     for (int i= 1; i <= n; i++) 
    72     {
    73       if (degsf[i] != 0 && degsg[i] != 0) 
     69  if (topLevel)
     70  {
     71    for (int i= 1; i <= n; i++)
     72    {
     73      if (degsf[i] != 0 && degsg[i] != 0)
    7474      {
    7575        both_non_zero++;
    7676        continue;
    7777      }
    78       if (degsf[i] == 0 && degsg[i] != 0 && i <= G.level()) 
     78      if (degsf[i] == 0 && degsg[i] != 0 && i <= G.level())
    7979      {
    8080        f_zero++;
    8181        continue;
    8282      }
    83       if (degsg[i] == 0 && degsf[i] && i <= F.level()) 
     83      if (degsg[i] == 0 && degsf[i] && i <= F.level())
    8484      {
    8585        g_zero++;
     
    8888    }
    8989
    90     if (both_non_zero == 0) 
     90    if (both_non_zero == 0)
    9191    {
    9292      delete [] degsf;
     
    9898    int k= 1;
    9999    int l= 1;
    100     for (int i= 1; i <= n; i++) 
    101     { 
    102       if (degsf[i] != 0 && degsg[i] == 0 && i <= F.level()) 
    103       {
    104         if (k + both_non_zero != i) 
     100    for (int i= 1; i <= n; i++)
     101    {
     102      if (degsf[i] != 0 && degsg[i] == 0 && i <= F.level())
     103      {
     104        if (k + both_non_zero != i)
    105105        {
    106106          M.newpair (Variable (i), Variable (k + both_non_zero));
     
    109109        k++;
    110110      }
    111       if (degsf[i] == 0 && degsg[i] != 0 && i <= G.level()) 
    112       {
    113         if (l + g_zero + both_non_zero != i) 
     111      if (degsf[i] == 0 && degsg[i] != 0 && i <= G.level())
     112      {
     113        if (l + g_zero + both_non_zero != i)
    114114        {
    115115          M.newpair (Variable (i), Variable (l + g_zero + both_non_zero));
     
    119119      }
    120120    }
    121  
     121
    122122    // sort Variables x_{i} in increasing order of
    123     // min(deg_{x_{i}}(f),deg_{x_{i}}(g)) 
     123    // min(deg_{x_{i}}(f),deg_{x_{i}}(g))
    124124    int m= tmin (F.level(), G.level());
    125125    int max_min_deg;
     
    127127    l= 0;
    128128    int i= 1;
    129     while (k > 0) 
     129    while (k > 0)
    130130    {
    131131      max_min_deg= tmin (degsf[i], degsg[i]);
    132       while (max_min_deg == 0) 
     132      while (max_min_deg == 0)
    133133      {
    134134        i++;
    135135        max_min_deg= tmin (degsf[i], degsg[i]);
    136136      }
    137       for (int j= i + 1; j <=  m; j++) 
    138       {
    139         if (tmin (degsf[j],degsg[j]) >= max_min_deg) 
     137      for (int j= i + 1; j <=  m; j++)
     138      {
     139        if (tmin (degsf[j],degsg[j]) >= max_min_deg)
    140140        {
    141141          max_min_deg= tmin (degsf[j], degsg[j]);
    142           l= j; 
     142          l= j;
    143143        }
    144144      }
    145       if (l != 0) 
    146       {
    147         if (l != k) 
     145      if (l != 0)
     146      {
     147        if (l != k)
    148148        {
    149149          M.newpair (Variable (l), Variable(k));
     
    153153          l= 0;
    154154        }
    155         else 
     155        else
    156156        {
    157157          degsf[l]= 0;
     
    159159          l= 0;
    160160        }
    161       } 
    162       else if (l == 0) 
    163       {
    164         if (i != k) 
     161      }
     162      else if (l == 0)
     163      {
     164        if (i != k)
    165165        {
    166166          M.newpair (Variable (i), Variable (k));
     
    169169          degsg[i]= 0;
    170170        }
    171         else 
     171        else
    172172        {
    173173          degsf[i]= 0;
     
    175175        }
    176176        i++;
    177       } 
     177      }
    178178      k--;
    179179    }
    180180  }
    181   else 
     181  else
    182182  {
    183183    //arrange Variables such that no gaps occur
    184     for (int i= 1; i <= n; i++) 
    185     {
    186       if (degsf[i] == 0 && degsg[i] == 0) 
     184    for (int i= 1; i <= n; i++)
     185    {
     186      if (degsf[i] == 0 && degsg[i] == 0)
    187187      {
    188188        both_zero++;
    189189        continue;
    190190      }
    191       else 
    192       {
    193         if (both_zero != 0) 
     191      else
     192      {
     193        if (both_zero != 0)
    194194        {
    195195          M.newpair (Variable (i), Variable (i - both_zero));
     
    207207
    208208int
    209 substituteCheck (const CanonicalForm& F, const CanonicalForm& G) 
     209substituteCheck (const CanonicalForm& F, const CanonicalForm& G)
    210210{
    211211  if (F.inCoeffDomain() || G.inCoeffDomain())
     
    214214  if (degree (F, x) <= 1 || degree (G, x) <= 1)
    215215    return 0;
    216   CanonicalForm f= swapvar (F, F.mvar(), x); //TODO swapping seems to be pretty expensive 
    217   CanonicalForm g= swapvar (G, G.mvar(), x); 
     216  CanonicalForm f= swapvar (F, F.mvar(), x); //TODO swapping seems to be pretty expensive
     217  CanonicalForm g= swapvar (G, G.mvar(), x);
    218218  int sizef= 0;
    219   int sizeg= 0; 
     219  int sizeg= 0;
    220220  for (CFIterator i= f; i.hasTerms(); i++, sizef++)
    221221  {
     
    240240    expg [j]= i.exp();
    241241  }
    242  
     242
    243243  int indf= sizef - 1;
    244244  int indg= sizeg - 1;
     
    247247  if (expg[indg] == 0)
    248248    indg--;
    249    
     249
    250250  if (expg[indg] != expf [indf] || (expg[indg] == 1 && expf[indf] == 1))
    251251  {
     
    265265    }
    266266  }
    267  
     267
    268268  for (int i= indg - 1; i >= 0; i--)
    269269  {
     
    282282
    283283// substiution
    284 void 
    285 subst (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& A, 
     284void
     285subst (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& A,
    286286       CanonicalForm& B, const int d
    287287      )
     
    293293    return;
    294294  }
    295  
     295
    296296  CanonicalForm C= 0;
    297   CanonicalForm D= 0; 
     297  CanonicalForm D= 0;
    298298  Variable x= Variable (1);
    299299  CanonicalForm f= swapvar (F, x, F.mvar());
     
    307307}
    308308
    309 CanonicalForm 
     309CanonicalForm
    310310reverseSubst (const CanonicalForm& F, const int d)
    311311{
    312312  if (d == 1)
    313313    return F;
    314  
     314
    315315  Variable x= Variable (1);
    316316  if (degree (F, x) <= 0)
     
    320320  for (CFIterator i= f; i.hasTerms(); i++)
    321321    result += i.coeff()*power (f.mvar(), d*i.exp());
    322   return swapvar (result, x, F.mvar());   
    323 }
    324 
    325 static inline CanonicalForm 
     322  return swapvar (result, x, F.mvar());
     323}
     324
     325static inline CanonicalForm
    326326uni_content (const CanonicalForm & F);
    327327
     
    335335  if (F.level() != x.level() && F.isUnivariate())
    336336    return F.genOne();
    337    
     337
    338338  if (x.level() != 1)
    339339  {
     
    344344  else
    345345    return uni_content (F);
    346 } 
    347 
    348 /// compute the content of F, where F is considered as an element of 
    349 /// \f$ R[x_{1}][x_{2},\ldots ,x_{n}] \f$ 
    350 static inline CanonicalForm 
    351 uni_content (const CanonicalForm & F) 
    352 { 
     346}
     347
     348/// compute the content of F, where F is considered as an element of
     349/// \f$ R[x_{1}][x_{2},\ldots ,x_{n}] \f$
     350static inline CanonicalForm
     351uni_content (const CanonicalForm & F)
     352{
    353353  if (F.inBaseDomain())
    354354    return F.genOne();
     
    360360
    361361  int l= F.level();
    362   if (l == 2) 
     362  if (l == 2)
    363363    return content(F);
    364   else 
     364  else
    365365  {
    366366    CanonicalForm pol, c = 0;
    367367    CFIterator i = F;
    368     for (; i.hasTerms(); i++) 
    369     {
    370       pol= i.coeff(); 
     368    for (; i.hasTerms(); i++)
     369    {
     370      pol= i.coeff();
    371371      pol= uni_content (pol);
    372372      c= gcd (c, pol);
     
    378378}
    379379
    380 CanonicalForm 
    381 extractContents (const CanonicalForm& F, const CanonicalForm& G, 
    382                  CanonicalForm& contentF, CanonicalForm& contentG, 
     380CanonicalForm
     381extractContents (const CanonicalForm& F, const CanonicalForm& G,
     382                 CanonicalForm& contentF, CanonicalForm& contentG,
    383383                 CanonicalForm& ppF, CanonicalForm& ppG, const int d)
    384384{
     
    407407/// is dp.
    408408static inline
    409 CanonicalForm uni_lcoeff (const CanonicalForm& F) 
     409CanonicalForm uni_lcoeff (const CanonicalForm& F)
    410410{
    411411  if (F.level() <= 1)
    412     return F; 
     412    return F;
    413413  else
    414414  {
     
    418418    {
    419419      if (i.exp() + totaldegree (i.coeff(), x, i.coeff().mvar()) == deg)
    420         return uni_lcoeff (i.coeff()); 
     420        return uni_lcoeff (i.coeff());
    421421    }
    422422  }
     
    441441}
    442442
    443 /// compute a random element a of \f$ F_{p}(\alpha ) \f$ , 
     443/// compute a random element a of \f$ F_{p}(\alpha ) \f$ ,
    444444/// s.t. F(a) \f$ \neq 0 \f$ , F is a univariate polynomial, returns
    445 /// fail if there are no field elements left which have not been used before 
    446 static inline CanonicalForm 
     445/// fail if there are no field elements left which have not been used before
     446static inline CanonicalForm
    447447randomElement (const CanonicalForm & F, const Variable & alpha, CFList & list,
    448                bool & fail) 
     448               bool & fail)
    449449{
    450450  fail= false;
     
    457457  int d= degree (mipo);
    458458  int bound= ipower (p, d);
    459   do 
     459  do
    460460  {
    461461    if (list.length() == bound)
     
    464464      break;
    465465    }
    466     if (list.length() < p) 
     466    if (list.length() < p)
    467467    {
    468468      random= genFF.generate();
     
    470470        random= genFF.generate();
    471471    }
    472     else 
     472    else
    473473    {
    474474      random= genAlgExt.generate();
     
    476476        random= genAlgExt.generate();
    477477    }
    478     if (F (random, x) == 0) 
     478    if (F (random, x) == 0)
    479479    {
    480480      list.append (random);
     
    485485}
    486486
    487 /// chooses a suitable extension of \f$ F_{p}(\alpha ) \f$ 
     487/// chooses a suitable extension of \f$ F_{p}(\alpha ) \f$
    488488/// we do not extend \f$ F_{p}(\alpha ) \f$ itself but extend \f$ F_{p} \f$ ,
    489 /// s.t. \f$ F_{p}(\alpha ) \subset F_{p}(\beta ) \f$ 
     489/// s.t. \f$ F_{p}(\alpha ) \subset F_{p}(\beta ) \f$
    490490static inline
    491 void choose_extension (const int& d, const int& num_vars, Variable& beta) 
     491void choose_extension (const int& d, const int& num_vars, Variable& beta)
    492492{
    493493  int p= getCharacteristic();
     
    496496  ZZ_pX NTLirredpoly;
    497497  //TODO: replace d by max_{i} (deg_x{i}(f))
    498   int i= (int) (log ((double) ipower (d + 1, num_vars))/log ((double) p)); 
     498  int i= (int) (log ((double) ipower (d + 1, num_vars))/log ((double) p));
    499499  int m= degree (getMipo (beta));
    500500  if (i <= 1)
    501501    i= 2;
    502   BuildIrred (NTLirredpoly, i*m); 
    503   CanonicalForm mipo= convertNTLZZpX2CF (NTLirredpoly, Variable(1)); 
    504   beta= rootOf (mipo); 
    505 }
    506 
    507 /// GCD of F and G over \f$ F_{p}(\alpha ) \f$ , 
     502  BuildIrred (NTLirredpoly, i*m);
     503  CanonicalForm mipo= convertNTLZZpX2CF (NTLirredpoly, Variable(1));
     504  beta= rootOf (mipo);
     505}
     506
     507/// GCD of F and G over \f$ F_{p}(\alpha ) \f$ ,
    508508/// l and topLevel are only used internally, output is monic
    509509/// based on Alg. 7.2. as described in "Algorithms for
    510510/// Computer Algebra" by Geddes, Czapor, Labahn
    511 CanonicalForm 
    512 GCD_Fp_extension (const CanonicalForm& F, const CanonicalForm& G, 
    513                   Variable & alpha, CFList& l, bool& topLevel) 
    514 { 
     511CanonicalForm
     512GCD_Fp_extension (const CanonicalForm& F, const CanonicalForm& G,
     513                  Variable & alpha, CFList& l, bool& topLevel)
     514{
    515515  CanonicalForm A= F;
    516516  CanonicalForm B= G;
     
    522522  if (G.isUnivariate() && fdivides(G, F)) return G/Lc(G);
    523523  if (F == G) return F/Lc(F);
    524  
     524
    525525  CFMap M,N;
    526526  int best_level= myCompress (A, B, M, N, topLevel);
     
    533533  Variable x= Variable(1);
    534534
    535   //univariate case 
    536   if (A.isUnivariate() && B.isUnivariate()) 
    537     return N (gcd(A,B)); 
    538  
     535  //univariate case
     536  if (A.isUnivariate() && B.isUnivariate())
     537    return N (gcd(A,B));
     538
    539539  int substitute= substituteCheck (A, B);
    540  
     540
    541541  if (substitute > 1)
    542542    subst (A, B, A, B, substitute);
     
    550550    if (best_level <= 2)
    551551      gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, best_level);
    552     else 
    553       gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, 2); 
     552    else
     553      gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, 2);
    554554  }
    555555  else
    556556  {
    557557    cA = uni_content (A);
    558     cB = uni_content (B); 
     558    cB = uni_content (B);
    559559    gcdcAcB= gcd (cA, cB);
    560560    ppA= A/cA;
     
    563563
    564564  CanonicalForm lcA, lcB;  // leading coefficients of A and B
    565   CanonicalForm gcdlcAlcB; 
     565  CanonicalForm gcdlcAlcB;
    566566
    567567  lcA= uni_lcoeff (ppA);
    568568  lcB= uni_lcoeff (ppB);
    569  
    570   if (fdivides (lcA, lcB)) 
    571   { 
     569
     570  if (fdivides (lcA, lcB))
     571  {
    572572    if (fdivides (A, B))
    573       return F/Lc(F);   
     573      return F/Lc(F);
    574574  }
    575575  if (fdivides (lcB, lcA))
    576   { 
    577     if (fdivides (B, A)) 
     576  {
     577    if (fdivides (B, A))
    578578      return G/Lc(G);
    579579  }
     
    587587    if (substitute > 1)
    588588      return N (reverseSubst (gcdcAcB, substitute));
    589     else 
     589    else
    590590      return N(gcdcAcB);
    591591  }
    592592  int d0= totaldegree (ppB, Variable(2), Variable (ppB.level()));
    593   if (d0 < d) 
    594     d= d0; 
     593  if (d0 < d)
     594    d= d0;
    595595  if (d == 0)
    596596  {
    597597    if (substitute > 1)
    598598      return N (reverseSubst (gcdcAcB, substitute));
    599     else 
     599    else
    600600      return N(gcdcAcB);
    601601  }
     
    614614  CanonicalForm prim_elem, im_prim_elem;
    615615  CFList source, dest;
    616   do 
     616  do
    617617  {
    618618    random_element= randomElement (m, V_buf, l, fail);
    619     if (fail) 
     619    if (fail)
    620620    {
    621621      source= CFList();
     
    638638      DEBOUTLN (cerr, "getMipo (V_buf2)= " << getMipo (V_buf2));
    639639      inextension= true;
    640       for (CFListIterator i= l; i.hasItem(); i++) 
    641         i.getItem()= mapUp (i.getItem(), alpha, V_buf, prim_elem, 
     640      for (CFListIterator i= l; i.hasItem(); i++)
     641        i.getItem()= mapUp (i.getItem(), alpha, V_buf, prim_elem,
    642642                             im_prim_elem, source, dest);
    643643      m= mapUp (m, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    644644      G_m= mapUp (G_m, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    645       newtonPoly= mapUp (newtonPoly, alpha, V_buf, prim_elem, im_prim_elem, 
     645      newtonPoly= mapUp (newtonPoly, alpha, V_buf, prim_elem, im_prim_elem,
    646646                          source, dest);
    647647      ppA= mapUp (ppA, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    648648      ppB= mapUp (ppB, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    649       gcdlcAlcB= mapUp (gcdlcAlcB, alpha, V_buf, prim_elem, im_prim_elem, 
     649      gcdlcAlcB= mapUp (gcdlcAlcB, alpha, V_buf, prim_elem, im_prim_elem,
    650650                         source, dest);
    651651
     
    655655      CFList list;
    656656      TIMING_START (gcd_recursion);
    657       G_random_element= 
     657      G_random_element=
    658658      GCD_Fp_extension (ppA (random_element, x), ppB (random_element, x), V_buf,
    659659                        list, topLevel);
    660       TIMING_END_AND_PRINT (gcd_recursion, 
     660      TIMING_END_AND_PRINT (gcd_recursion,
    661661                            "time for recursive call: ");
    662662      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
    663663    }
    664     else 
     664    else
    665665    {
    666666      CFList list;
    667667      TIMING_START (gcd_recursion);
    668       G_random_element= 
     668      G_random_element=
    669669      GCD_Fp_extension (ppA(random_element, x), ppB(random_element, x), V_buf,
    670670                        list, topLevel);
    671       TIMING_END_AND_PRINT (gcd_recursion, 
     671      TIMING_END_AND_PRINT (gcd_recursion,
    672672                            "time for recursive call: ");
    673673      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
    674674    }
    675675
    676     d0= totaldegree (G_random_element, Variable(2), 
     676    d0= totaldegree (G_random_element, Variable(2),
    677677                     Variable (G_random_element.level()));
    678678    if (d0 == 0)
     
    680680      if (substitute > 1)
    681681        return N (reverseSubst (gcdcAcB, substitute));
    682       else 
     682      else
    683683        return N(gcdcAcB);
    684684    }
    685     if (d0 >  d) 
     685    if (d0 >  d)
    686686    {
    687687      if (!find (l, random_element))
     
    690690    }
    691691
    692     G_random_element= 
     692    G_random_element=
    693693    (gcdlcAlcB(random_element, x)/uni_lcoeff (G_random_element))
    694694    * G_random_element;
    695695
    696     d0= totaldegree (G_random_element, Variable(2), 
     696    d0= totaldegree (G_random_element, Variable(2),
    697697                     Variable(G_random_element.level()));
    698     if (d0 <  d) 
     698    if (d0 <  d)
    699699    {
    700700      m= gcdlcAlcB;
     
    706706    TIMING_START (newton_interpolation);
    707707    H= newtonInterp (random_element, G_random_element, newtonPoly, G_m, x);
    708     TIMING_END_AND_PRINT (newton_interpolation, 
     708    TIMING_END_AND_PRINT (newton_interpolation,
    709709                          "time for newton interpolation: ");
    710710
    711     //termination test 
    712     if (uni_lcoeff (H) == gcdlcAlcB) 
     711    //termination test
     712    if (uni_lcoeff (H) == gcdlcAlcB)
    713713    {
    714714      cH= uni_content (H);
    715715      ppH= H/cH;
    716       if (inextension) 
    717       {
    718         CFList u, v; 
     716      if (inextension)
     717      {
     718        CFList u, v;
    719719        //maybe it's better to test if ppH is an element of F(\alpha) before
    720720        //mapping down
    721721        DEBOUTLN (cerr, "ppH before mapDown= " << ppH);
    722         ppH= mapDown (ppH, prim_elem, im_prim_elem, alpha, u, v); 
     722        ppH= mapDown (ppH, prim_elem, im_prim_elem, alpha, u, v);
    723723        ppH /= Lc(ppH);
    724724        DEBOUTLN (cerr, "ppH after mapDown= " << ppH);
    725         if (fdivides (ppH, A) && fdivides (ppH, B))         
     725        if (fdivides (ppH, A) && fdivides (ppH, B))
    726726        {
    727727          if (substitute > 1)
     
    733733        }
    734734      }
    735       else if (fdivides (ppH, A) && fdivides (ppH, B)) 
     735      else if (fdivides (ppH, A) && fdivides (ppH, B))
    736736      {
    737737        if (substitute > 1)
     
    752752}
    753753
    754 /// compute a random element a of GF, s.t. F(a) \f$ \neq 0 \f$ , F is a 
     754/// compute a random element a of GF, s.t. F(a) \f$ \neq 0 \f$ , F is a
    755755/// univariate polynomial, returns fail if there are no field elements left
    756756/// which have not been used before
     
    766766  int d= getGFDegree();
    767767  int bound= ipower (p, d);
    768   do 
     768  do
    769769  {
    770770    if (list.length() == bound)
     
    775775    if (list.length() < 1)
    776776      random= 0;
    777     else 
     777    else
    778778    {
    779779      random= genGF.generate();
     
    781781        random= genGF.generate();
    782782    }
    783     if (F (random, x) == 0) 
     783    if (F (random, x) == 0)
    784784    {
    785785      list.append (random);
     
    796796/// the size of the base field is bounded by 2^16, output is monic
    797797CanonicalForm GCD_GF (const CanonicalForm& F, const CanonicalForm& G,
    798         CFList& l, bool& topLevel) 
    799 { 
     798        CFList& l, bool& topLevel)
     799{
    800800  CanonicalForm A= F;
    801801  CanonicalForm B= G;
     
    807807  if (G.isUnivariate() && fdivides(G, F)) return G/Lc(G);
    808808  if (F == G) return F/Lc(F);
    809  
     809
    810810  CFMap M,N;
    811811  int best_level= myCompress (A, B, M, N, topLevel);
     
    818818  Variable x= Variable(1);
    819819
    820   //univariate case 
    821   if (A.isUnivariate() && B.isUnivariate()) 
    822     return N (gcd (A, B)); 
     820  //univariate case
     821  if (A.isUnivariate() && B.isUnivariate())
     822    return N (gcd (A, B));
    823823
    824824  int substitute= substituteCheck (A, B);
    825  
     825
    826826  if (substitute > 1)
    827827    subst (A, B, A, B, substitute);
     
    835835    if (best_level <= 2)
    836836      gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, best_level);
    837     else 
    838       gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, 2); 
     837    else
     838      gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, 2);
    839839  }
    840840  else
    841841  {
    842842    cA = uni_content (A);
    843     cB = uni_content (B); 
     843    cB = uni_content (B);
    844844    gcdcAcB= gcd (cA, cB);
    845845    ppA= A/cA;
     
    848848
    849849  CanonicalForm lcA, lcB;  // leading coefficients of A and B
    850   CanonicalForm gcdlcAlcB; 
     850  CanonicalForm gcdlcAlcB;
    851851
    852852  lcA= uni_lcoeff (ppA);
    853853  lcB= uni_lcoeff (ppB);
    854854
    855   if (fdivides (lcA, lcB)) 
    856   { 
     855  if (fdivides (lcA, lcB))
     856  {
    857857    if (fdivides (A, B))
    858       return F; 
    859   }   
    860   if (fdivides (lcB, lcA)) 
    861   { 
    862     if (fdivides (B, A)) 
     858      return F;
     859  }
     860  if (fdivides (lcB, lcA))
     861  {
     862    if (fdivides (B, A))
    863863      return G;
    864864  }
     
    871871    if (substitute > 1)
    872872      return N (reverseSubst (gcdcAcB, substitute));
    873     else 
     873    else
    874874      return N(gcdcAcB);
    875875  }
    876876  int d0= totaldegree (ppB, Variable(2), Variable (ppB.level()));
    877   if (d0 < d) 
    878     d= d0; 
     877  if (d0 < d)
     878    d= d0;
    879879  if (d == 0)
    880880  {
    881881    if (substitute > 1)
    882882      return N (reverseSubst (gcdcAcB, substitute));
    883     else 
     883    else
    884884      return N(gcdcAcB);
    885885  }
     
    900900  int expon;
    901901  char gf_name_buf= gf_name;
    902   do 
     902  do
    903903  {
    904904    random_element= GFRandomElement (m, l, fail);
    905     if (fail) 
    906     { 
     905    if (fail)
     906    {
    907907      int num_vars= tmin (getNumVars(A), getNumVars(B));
    908908      num_vars--;
     
    911911      if (expon < 2)
    912912        expon= 2;
    913       kk= getGFDegree(); 
    914       if (ipower (p, kk*expon) < (1 << 16)) 
     913      kk= getGFDegree();
     914      if (ipower (p, kk*expon) < (1 << 16))
    915915        setCharacteristic (p, kk*(int)expon, 'b');
    916       else 
     916      else
    917917      {
    918918        expon= (int) floor((log ((double)((1<<16) - 1)))/(log((double)p)*kk));
     
    922922      inextension= true;
    923923      fail= false;
    924       for (CFListIterator i= l; i.hasItem(); i++) 
     924      for (CFListIterator i= l; i.hasItem(); i++)
    925925        i.getItem()= GFMapUp (i.getItem(), kk);
    926926      m= GFMapUp (m, kk);
     
    934934      CFList list;
    935935      TIMING_START (gcd_recursion);
    936       G_random_element= GCD_GF (ppA(random_element, x), ppB(random_element, x), 
     936      G_random_element= GCD_GF (ppA(random_element, x), ppB(random_element, x),
    937937                                list, topLevel);
    938       TIMING_END_AND_PRINT (gcd_recursion, 
     938      TIMING_END_AND_PRINT (gcd_recursion,
    939939                            "time for recursive call: ");
    940940      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
    941941    }
    942     else 
     942    else
    943943    {
    944944      CFList list;
    945945      TIMING_START (gcd_recursion);
    946       G_random_element= GCD_GF (ppA(random_element, x), ppB(random_element, x), 
     946      G_random_element= GCD_GF (ppA(random_element, x), ppB(random_element, x),
    947947                                list, topLevel);
    948       TIMING_END_AND_PRINT (gcd_recursion, 
     948      TIMING_END_AND_PRINT (gcd_recursion,
    949949                            "time for recursive call: ");
    950950      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
    951951    }
    952952
    953     d0= totaldegree (G_random_element, Variable(2), 
     953    d0= totaldegree (G_random_element, Variable(2),
    954954                     Variable (G_random_element.level()));
    955     if (d0 == 0) 
    956     {
    957       if (inextension) 
     955    if (d0 == 0)
     956    {
     957      if (inextension)
    958958      {
    959959        setCharacteristic (p, k, gf_name_buf);
     
    962962            return N (reverseSubst (gcdcAcB, substitute));
    963963          else
    964             return N(gcdcAcB); 
    965         } 
     964            return N(gcdcAcB);
     965        }
    966966      }
    967967      else
     
    970970          return N (reverseSubst (gcdcAcB, substitute));
    971971        else
    972           return N(gcdcAcB); 
    973       }
    974     } 
    975     if (d0 >  d) 
     972          return N(gcdcAcB);
     973      }
     974    }
     975    if (d0 >  d)
    976976    {
    977977      if (!find (l, random_element))
     
    980980    }
    981981
    982     G_random_element= 
     982    G_random_element=
    983983    (gcdlcAlcB(random_element, x)/uni_lcoeff(G_random_element)) *
    984984     G_random_element;
    985     d0= totaldegree (G_random_element, Variable(2), 
     985    d0= totaldegree (G_random_element, Variable(2),
    986986                     Variable (G_random_element.level()));
    987987
    988     if (d0 < d) 
     988    if (d0 < d)
    989989    {
    990990      m= gcdlcAlcB;
     
    998998    TIMING_END_AND_PRINT (newton_interpolation, "time for newton interpolation: ");
    999999
    1000     //termination test 
    1001     if (uni_lcoeff (H) == gcdlcAlcB) 
     1000    //termination test
     1001    if (uni_lcoeff (H) == gcdlcAlcB)
    10021002    {
    10031003      cH= uni_content (H);
    10041004      ppH= H/cH;
    1005       if (inextension) 
    1006       {
    1007         if (fdivides(ppH, GFMapUp(A, k)) && fdivides(ppH, GFMapUp(B,k))) 
     1005      if (inextension)
     1006      {
     1007        if (fdivides(ppH, GFMapUp(A, k)) && fdivides(ppH, GFMapUp(B,k)))
    10081008        {
    10091009          DEBOUTLN (cerr, "ppH before mapDown= " << ppH);
     
    10191019        }
    10201020      }
    1021       else 
    1022       {
    1023         if (fdivides (ppH, A) && fdivides (ppH, B)) 
     1021      else
     1022      {
     1023        if (fdivides (ppH, A) && fdivides (ppH, B))
    10241024        {
    10251025          if (substitute > 1)
     
    10421042
    10431043/// F is assumed to be an univariate polynomial in x,
    1044 /// computes a random monic irreducible univariate polynomial of random 
     1044/// computes a random monic irreducible univariate polynomial of random
    10451045/// degree < i in x which does not divide F
    1046 CanonicalForm 
    1047 randomIrredpoly (int i, const Variable & x) 
     1046CanonicalForm
     1047randomIrredpoly (int i, const Variable & x)
    10481048{
    10491049  int p= getCharacteristic();
    10501050  ZZ NTLp= to_ZZ (p);
    10511051  ZZ_p::init (NTLp);
    1052   ZZ_pX NTLirredpoly; 
     1052  ZZ_pX NTLirredpoly;
    10531053  CanonicalForm CFirredpoly;
    10541054  BuildIrred (NTLirredpoly, i + 1);
    10551055  CFirredpoly= convertNTLZZpX2CF (NTLirredpoly, x);
    10561056  return CFirredpoly;
    1057 } 
     1057}
    10581058
    10591059static inline
     
    10671067  int p= getCharacteristic();
    10681068  int bound= p;
    1069   do 
     1069  do
    10701070  {
    10711071    if (list.length() == bound)
     
    10761076    if (list.length() < 1)
    10771077      random= 0;
    1078     else 
     1078    else
    10791079    {
    10801080      random= genFF.generate();
     
    10821082        random= genFF.generate();
    10831083    }
    1084     if (F (random, x) == 0) 
     1084    if (F (random, x) == 0)
    10851085    {
    10861086      list.append (random);
     
    10911091}
    10921092
    1093 CanonicalForm GCD_small_p (const CanonicalForm& F, const CanonicalForm&  G, 
    1094                            bool& topLevel, CFList& l) 
     1093CanonicalForm GCD_small_p (const CanonicalForm& F, const CanonicalForm&  G,
     1094                           bool& topLevel, CFList& l)
    10951095{
    10961096  CanonicalForm A= F;
     
    11141114  Variable x= Variable (1);
    11151115
    1116   //univariate case 
    1117   if (A.isUnivariate() && B.isUnivariate()) 
     1116  //univariate case
     1117  if (A.isUnivariate() && B.isUnivariate())
    11181118    return N (gcd (A, B));
    11191119
    11201120  int substitute= substituteCheck (A, B);
    1121  
     1121
    11221122  if (substitute > 1)
    11231123    subst (A, B, A, B, substitute);
     
    11311131    if (best_level <= 2)
    11321132      gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, best_level);
    1133     else 
    1134       gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, 2); 
     1133    else
     1134      gcdcAcB= extractContents (A, B, cA, cB, ppA, ppB, 2);
    11351135  }
    11361136  else
    11371137  {
    11381138    cA = uni_content (A);
    1139     cB = uni_content (B); 
     1139    cB = uni_content (B);
    11401140    gcdcAcB= gcd (cA, cB);
    11411141    ppA= A/cA;
     
    11441144
    11451145  CanonicalForm lcA, lcB;  // leading coefficients of A and B
    1146   CanonicalForm gcdlcAlcB; 
     1146  CanonicalForm gcdlcAlcB;
    11471147  lcA= uni_lcoeff (ppA);
    11481148  lcB= uni_lcoeff (ppB);
    11491149
    1150   if (fdivides (lcA, lcB)) 
    1151   { 
     1150  if (fdivides (lcA, lcB))
     1151  {
    11521152    if (fdivides (A, B))
    11531153      return F/Lc(F);
    1154   }   
     1154  }
    11551155  if (fdivides (lcB, lcA))
    1156   { 
    1157     if (fdivides (B, A)) 
     1156  {
     1157    if (fdivides (B, A))
    11581158      return G/Lc(G);
    11591159  }
    11601160
    1161   gcdlcAlcB= gcd (lcA, lcB); 
    1162  
     1161  gcdlcAlcB= gcd (lcA, lcB);
     1162
    11631163  int d= totaldegree (ppA, Variable (2), Variable (ppA.level()));
    11641164  int d0;
     
    11681168    if (substitute > 1)
    11691169      return N (reverseSubst (gcdcAcB, substitute));
    1170     else 
     1170    else
    11711171      return N(gcdcAcB);
    11721172  }
    11731173  d0= totaldegree (ppB, Variable (2), Variable (ppB.level()));
    11741174
    1175   if (d0 < d) 
     1175  if (d0 < d)
    11761176    d= d0;
    11771177
    1178   if (d == 0) 
     1178  if (d == 0)
    11791179  {
    11801180    if (substitute > 1)
    11811181      return N (reverseSubst (gcdcAcB, substitute));
    1182     else 
     1182    else
    11831183      return N(gcdcAcB);
    11841184  }
     
    11951195  topLevel= false;
    11961196  CFList source, dest;
    1197   do 
     1197  do
    11981198  {
    11991199    if (inextension)
     
    12061206      CFList list;
    12071207      TIMING_START (gcd_recursion);
    1208       G_random_element= 
    1209       GCD_small_p (ppA (random_element,x), ppB (random_element,x), topLevel, 
     1208      G_random_element=
     1209      GCD_small_p (ppA (random_element,x), ppB (random_element,x), topLevel,
    12101210      list);
    1211       TIMING_END_AND_PRINT (gcd_recursion, 
     1211      TIMING_END_AND_PRINT (gcd_recursion,
    12121212                            "time for recursive call: ");
    12131213      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
     
    12151215    else if (!fail && inextension)
    12161216    {
    1217       CFList list; 
     1217      CFList list;
    12181218      TIMING_START (gcd_recursion);
    1219       G_random_element= 
    1220       GCD_Fp_extension (ppA (random_element, x), ppB (random_element, x), alpha, 
     1219      G_random_element=
     1220      GCD_Fp_extension (ppA (random_element, x), ppB (random_element, x), alpha,
    12211221                        list, topLevel);
    1222       TIMING_END_AND_PRINT (gcd_recursion, 
     1222      TIMING_END_AND_PRINT (gcd_recursion,
    12231223                            "time for recursive call: ");
    1224       DEBOUTLN (cerr, "G_random_element= " << G_random_element);   
     1224      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
    12251225    }
    12261226    else if (fail && !inextension)
     
    12321232      int deg= 2;
    12331233      do {
    1234         mipo= randomIrredpoly (deg, x); 
     1234        mipo= randomIrredpoly (deg, x);
    12351235        alpha= rootOf (mipo);
    12361236        inextension= true;
    12371237        fail= false;
    1238         random_element= randomElement (m, alpha, l, fail); 
     1238        random_element= randomElement (m, alpha, l, fail);
    12391239        deg++;
    1240       } while (fail); 
     1240      } while (fail);
    12411241      list= CFList();
    12421242      TIMING_START (gcd_recursion);
    1243       G_random_element= 
    1244       GCD_Fp_extension (ppA (random_element, x), ppB (random_element, x), alpha, 
     1243      G_random_element=
     1244      GCD_Fp_extension (ppA (random_element, x), ppB (random_element, x), alpha,
    12451245                        list, topLevel);
    1246       TIMING_END_AND_PRINT (gcd_recursion, 
     1246      TIMING_END_AND_PRINT (gcd_recursion,
    12471247                            "time for recursive call: ");
    12481248      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
     
    12601260      CanonicalForm prim_elem, im_prim_elem;
    12611261      prim_elem= primitiveElement (alpha, V_buf2, prim_fail);
    1262        
     1262
    12631263      ASSERT (!prim_fail, "failure in integer factorizer");
    12641264      if (prim_fail)
     
    12711271
    12721272      inextensionextension= true;
    1273       for (CFListIterator i= l; i.hasItem(); i++) 
    1274         i.getItem()= mapUp (i.getItem(), alpha, V_buf, prim_elem, 
     1273      for (CFListIterator i= l; i.hasItem(); i++)
     1274        i.getItem()= mapUp (i.getItem(), alpha, V_buf, prim_elem,
    12751275                             im_prim_elem, source, dest);
    12761276      m= mapUp (m, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    12771277      G_m= mapUp (G_m, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    1278       newtonPoly= mapUp (newtonPoly, alpha, V_buf, prim_elem, im_prim_elem, 
     1278      newtonPoly= mapUp (newtonPoly, alpha, V_buf, prim_elem, im_prim_elem,
    12791279                          source, dest);
    12801280      ppA= mapUp (ppA, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    12811281      ppB= mapUp (ppB, alpha, V_buf, prim_elem, im_prim_elem, source, dest);
    1282       gcdlcAlcB= mapUp (gcdlcAlcB, alpha, V_buf, prim_elem, im_prim_elem, 
     1282      gcdlcAlcB= mapUp (gcdlcAlcB, alpha, V_buf, prim_elem, im_prim_elem,
    12831283                         source, dest);
    12841284      fail= false;
     
    12871287      CFList list;
    12881288      TIMING_START (gcd_recursion);
    1289       G_random_element= 
     1289      G_random_element=
    12901290      GCD_Fp_extension (ppA (random_element, x), ppB (random_element, x), V_buf,
    12911291                        list, topLevel);
    1292       TIMING_END_AND_PRINT (gcd_recursion, 
     1292      TIMING_END_AND_PRINT (gcd_recursion,
    12931293                            "time for recursive call: ");
    12941294      DEBOUTLN (cerr, "G_random_element= " << G_random_element);
    12951295      alpha= V_buf;
    1296     } 
    1297 
    1298     d0= totaldegree (G_random_element, Variable(2), 
     1296    }
     1297
     1298    d0= totaldegree (G_random_element, Variable(2),
    12991299                     Variable (G_random_element.level()));
    13001300
     
    13041304        return N (reverseSubst (gcdcAcB, substitute));
    13051305      else
    1306         return N(gcdcAcB); 
    1307     }
    1308     if (d0 >  d) 
    1309     { 
     1306        return N(gcdcAcB);
     1307    }
     1308    if (d0 >  d)
     1309    {
    13101310      if (!find (l, random_element))
    13111311        l.append (random_element);
     
    13141314
    13151315    G_random_element= (gcdlcAlcB(random_element,x)/uni_lcoeff(G_random_element))
    1316                        *G_random_element; 
    1317 
    1318    
    1319     d0= totaldegree (G_random_element, Variable(2), 
     1316                       *G_random_element;
     1317
     1318
     1319    d0= totaldegree (G_random_element, Variable(2),
    13201320                     Variable(G_random_element.level()));
    13211321
    1322     if (d0 <  d) 
     1322    if (d0 <  d)
    13231323    {
    13241324      m= gcdlcAlcB;
     
    13271327      d= d0;
    13281328    }
    1329      
     1329
    13301330    TIMING_START (newton_interpolation);
    13311331    H= newtonInterp (random_element, G_random_element, newtonPoly, G_m, x);
    1332     TIMING_END_AND_PRINT (newton_interpolation, 
     1332    TIMING_END_AND_PRINT (newton_interpolation,
    13331333                          "time for newton_interpolation: ");
    13341334
    13351335    //termination test
    1336     if (uni_lcoeff (H) == gcdlcAlcB) 
     1336    if (uni_lcoeff (H) == gcdlcAlcB)
    13371337    {
    13381338      cH= uni_content (H);
     
    13401340      ppH /= Lc (ppH);
    13411341      DEBOUTLN (cerr, "ppH= " << ppH);
    1342       if (fdivides (ppH, A) && fdivides (ppH, B)) 
     1342      if (fdivides (ppH, A) && fdivides (ppH, B))
    13431343      {
    13441344        if (substitute > 1)
  • factory/cf_gcd_smallp.h

    rc840d9 r806c18  
    55/** @file cf_gcd_smallp.h
    66 *
    7  * @author Martin Lee   
     7 * @author Martin Lee
    88 * @date   22.10.2009
    99 *
    10  * This file defines the functions GCD_Fp_extension which computes the GCD of 
    11  * two polynomials over \f$ F_{p}(\alpha ) \f$ , GCD_small_p which computes the 
    12  * GCD of two polynomials over  \f$ F_{p} \f$ , and GCD_GF which computes the 
    13  * GCD of two polynomials over GF. Algorithms are based on "On the Genericity of 
     10 * This file defines the functions GCD_Fp_extension which computes the GCD of
     11 * two polynomials over \f$ F_{p}(\alpha ) \f$ , GCD_small_p which computes the
     12 * GCD of two polynomials over  \f$ F_{p} \f$ , and GCD_GF which computes the
     13 * GCD of two polynomials over GF. Algorithms are based on "On the Genericity of
    1414 * the Modular Polynomial GCD Algorithm" by E. Kaltofen & M. Monagan
    1515 *
     
    1717 *   (c) by The SINGULAR Team, see LICENSE file
    1818 *
    19  * @internal 
     19 * @internal
    2020 * @version \$Id$
    2121 *
     
    2424
    2525#include <config.h>
    26 #include "assert.h" 
     26#include "assert.h"
    2727
    2828CanonicalForm GCD_Fp_extension (const CanonicalForm& F, const CanonicalForm& G,
    2929                  Variable & alpha, CFList& l, bool& top_level);
    3030
    31 /// GCD of A and B over \f$ F_{p}(\alpha ) \f$ 
    32 static inline CanonicalForm GCD_Fp_extension (const CanonicalForm& A, const CanonicalForm& B, 
    33                                 Variable & alpha) 
     31/// GCD of A and B over \f$ F_{p}(\alpha ) \f$
     32static inline CanonicalForm GCD_Fp_extension (const CanonicalForm& A, const CanonicalForm& B,
     33                                Variable & alpha)
    3434{
    3535  CFList list;
     
    5454
    5555/// GCD of A and B over GF
    56 static inline CanonicalForm GCD_GF (const CanonicalForm& A, const CanonicalForm& B) 
     56static inline CanonicalForm GCD_GF (const CanonicalForm& A, const CanonicalForm& B)
    5757{
    58   ASSERT (CFFactory::gettype() == GaloisFieldDomain, 
     58  ASSERT (CFFactory::gettype() == GaloisFieldDomain,
    5959          "GF as base field expected");
    6060  CFList list;
     
    6363}
    6464
    65 CanonicalForm 
     65CanonicalForm
    6666randomIrredpoly (int i, const Variable & x) ;
    6767#endif
  • factory/cf_generator.cc

    rc840d9 r806c18  
    5555    ASSERT( current != gf_q + 1, "no more items" );
    5656    if ( gf_iszero( current ) )
    57         current = 0;
     57        current = 0;
    5858    else  if ( current == gf_q1 - 1 )
    59         current = gf_q + 1;
     59        current = gf_q + 1;
    6060    else
    61         current++;
     61        current++;
    6262}
    6363
     
    137137    {
    138138      for ( int i = 0; i < n; i++ )
    139             result += power( algext, i ) * gensg[i]->item();
     139            result += power( algext, i ) * gensg[i]->item();
    140140    }
    141141    else
    142142    {
    143143      for ( int i = 0; i < n; i++ )
    144             result += power( algext, i ) * gensf[i]->item();
     144            result += power( algext, i ) * gensf[i]->item();
    145145    }
    146146    return result;
     
    156156      while ( ! stop && i < n )
    157157      {
    158         gensg[i]->next();
    159             if ( ! gensg[i]->hasItems() )
     158            gensg[i]->next();
     159            if ( ! gensg[i]->hasItems() )
    160160        {
    161               gensg[i]->reset();
    162               i++;
    163             }
    164             else
    165               stop = true;
     161              gensg[i]->reset();
     162              i++;
     163            }
     164            else
     165              stop = true;
    166166      }
    167167    }
     
    170170      while ( ! stop && i < n )
    171171      {
    172         gensf[i]->next();
    173             if ( ! gensf[i]->hasItems() )
     172            gensf[i]->next();
     173            if ( ! gensf[i]->hasItems() )
    174174        {
    175               gensf[i]->reset();
    176               i++;
    177             }
    178             else
    179               stop = true;
     175              gensf[i]->reset();
     176              i++;
     177            }
     178            else
     179              stop = true;
    180180      }
    181181    }
    182182    if ( ! stop )
    183         nomoreitems = true;
     183        nomoreitems = true;
    184184}
    185185
     
    188188    ASSERT( getCharacteristic() > 0, "not a finite field" );
    189189    if ( getGFDegree() > 1 )
    190         return new GFGenerator();
     190        return new GFGenerator();
    191191    else
    192         return new FFGenerator();
     192        return new FFGenerator();
    193193}
  • factory/cf_inline.cc

    rc840d9 r806c18  
    253253{
    254254    if ( (! is_imm( value )) && value->deleteObject() )
    255         delete value;
     255        delete value;
    256256}
    257257//}}}
     
    273273{
    274274    if ( this != &cf ) {
    275         if ( (! is_imm( value )) && value->deleteObject() )
    276             delete value;
    277         value = (is_imm( cf.value )) ? cf.value : cf.value->copyObject();
     275        if ( (! is_imm( value )) && value->deleteObject() )
     276            delete value;
     277        value = (is_imm( cf.value )) ? cf.value : cf.value->copyObject();
    278278    }
    279279    return *this;
     
    306306{
    307307    if ( (! is_imm( value )) && value->deleteObject() )
    308         delete value;
     308        delete value;
    309309    value = CFFactory::basic( cf );
    310310    return *this;
     
    351351// Use `mpz_cpm_ui()' resp. `mpz_sgn()' to check the underlying
    352352// mpi.
    353 // 
     353//
    354354//}}}
    355355CF_INLINE bool
     
    359359
    360360    if ( ! what )
    361         return value->isOne();
     361        return value->isOne();
    362362    else  if ( what == INTMARK )
    363         return imm_isone( value );
     363        return imm_isone( value );
    364364    else if ( what == FFMARK )
    365         return imm_isone_p( value );
     365        return imm_isone_p( value );
    366366    else
    367         return imm_isone_gf( value );
     367        return imm_isone_gf( value );
    368368}
    369369
     
    374374
    375375    if ( what == 0 )
    376         return value->isZero();
     376        return value->isZero();
    377377    else  if ( what == INTMARK )
    378         return imm_iszero( value );
     378        return imm_iszero( value );
    379379    else if ( what == FFMARK )
    380         return imm_iszero_p( value );
     380        return imm_iszero_p( value );
    381381    else
    382         return imm_iszero_gf( value );
     382        return imm_iszero_gf( value );
    383383}
    384384//}}}
     
    396396// has to be created.
    397397//
    398 // Type info: 
     398// Type info:
    399399// ----------
    400400// cf: CurrentPP
     
    441441
    442442    if ( ! what )
    443         result.value = result.value->neg();
     443        result.value = result.value->neg();
    444444    else  if ( what == INTMARK )
    445         result.value = imm_neg( result.value );
     445        result.value = imm_neg( result.value );
    446446    else if ( what == FFMARK )
    447         result.value = imm_neg_p( result.value );
     447        result.value = imm_neg_p( result.value );
    448448    else
    449         result.value = imm_neg_gf( result.value );
     449        result.value = imm_neg_gf( result.value );
    450450
    451451    return result;
  • factory/cf_irred.cc

    rc840d9 r806c18  
    2424    int i;
    2525    do {
    26         result = power( x, deg );
    27         for ( i = deg-1; i >= 0; i-- )
    28             result += gen.generate() * power( x, i );
     26        result = power( x, deg );
     27        for ( i = deg-1; i >= 0; i-- )
     28            result += gen.generate() * power( x, i );
    2929    } while ( ! is_irreducible( result ) );
    3030    return result;
  • factory/cf_iter_inline.cc

    rc840d9 r806c18  
    9090    ASSERT( hasterms, "lib error: iterator out of terms" );
    9191    if ( ispoly )
    92         return cursor->coeff;
     92        return cursor->coeff;
    9393    else
    94         return data;
     94        return data;
    9595}
    9696//}}}
     
    109109    ASSERT( hasterms, "lib error: iterator out of terms" );
    110110    if ( ispoly )
    111         return cursor->exp;
     111        return cursor->exp;
    112112    else
    113         return 0;
     113        return 0;
    114114}
    115115//}}}
     
    132132    ASSERT( hasterms, "lib error: iterator out of terms" );
    133133    if ( ispoly ) {
    134         cursor = cursor->next;
    135         hasterms = cursor != 0;
     134        cursor = cursor->next;
     135        hasterms = cursor != 0;
    136136    } else
    137         hasterms = false;
     137        hasterms = false;
    138138
    139139    return *this;
     
    145145    ASSERT( hasterms, "lib error: iterator out of terms" );
    146146    if ( ispoly ) {
    147         cursor = cursor->next;
    148         hasterms = cursor != 0;
     147        cursor = cursor->next;
     148        hasterms = cursor != 0;
    149149    } else
    150         hasterms = false;
     150        hasterms = false;
    151151
    152152    return *this;
  • factory/cf_map.cc

    rc840d9 r806c18  
    381381    degsg = degrees( g, degsg );
    382382    optvalues( degsf, degsg, n, p1, pe );
    383    
     383
    384384    i = 1; k = 1;
    385385    if ( pe > 1 )
  • factory/cf_map_ext.cc

    rc840d9 r806c18  
    33/** @file cf_map_ext.cc
    44 *
    5  * @author Martin Lee   
     5 * @author Martin Lee
    66 * @date   16.11.2009
    77 *
     
    1111 *   (c) by The SINGULAR Team, see LICENSE file
    1212 *
    13  * @internal 
     13 * @internal
    1414 * @version \$Id$
    1515 *
     
    3535#include "cf_map_ext.h"
    3636
    37 #ifdef HAVE_NTL 
     37#ifdef HAVE_NTL
    3838
    3939/// helper function
    4040static inline
    41 int findItem (const CFList& list, const CanonicalForm& item) 
    42 {
    43   int result= 1; 
    44   for (CFListIterator i= list; i.hasItem(); i++, result++) 
     41int findItem (const CFList& list, const CanonicalForm& item)
     42{
     43  int result= 1;
     44  for (CFListIterator i= list; i.hasItem(); i++, result++)
    4545  {
    4646    if (i.getItem() == item)
     
    5252/// helper function
    5353static inline
    54 CanonicalForm getItem (const CFList& list, const int& pos) 
     54CanonicalForm getItem (const CFList& list, const int& pos)
    5555{
    5656  int j= 1;
    5757  if (pos > list.length() || pos < 1) return 0;
    58   for (CFListIterator i= list; j <= pos; i++, j++) 
    59   {
    60     if (j == pos) 
     58  for (CFListIterator i= list; j <= pos; i++, j++)
     59  {
     60    if (j == pos)
    6161      return i.getItem();
    6262  }
    63 } 
    64 
    65 
    66 /// \f$ F_{p} (\alpha ) \subset F_{p}(\beta ) \f$ and \f$ \alpha \f$ is a 
    67 /// primitive element, returns the image of \f$ \alpha \f$ 
    68 static inline   
    69 CanonicalForm mapUp (const Variable& alpha, const Variable& beta) 
     63}
     64
     65
     66/// \f$ F_{p} (\alpha ) \subset F_{p}(\beta ) \f$ and \f$ \alpha \f$ is a
     67/// primitive element, returns the image of \f$ \alpha \f$
     68static inline
     69CanonicalForm mapUp (const Variable& alpha, const Variable& beta)
    7070{
    7171  int p= getCharacteristic ();
    7272  zz_p::init (p);
    73   zz_pX NTL_mipo= convertFacCF2NTLzzpX (getMipo (beta)); 
     73  zz_pX NTL_mipo= convertFacCF2NTLzzpX (getMipo (beta));
    7474  zz_pE::init (NTL_mipo);
    7575  zz_pEX NTL_alpha_mipo= convertFacCF2NTLzz_pEX (getMipo(alpha), NTL_mipo);
     
    7878}
    7979
    80 /// the CanonicalForm G is the output of map_up, returns F considered as an 
     80/// the CanonicalForm G is the output of map_up, returns F considered as an
    8181/// element over \f$ F_{p}(\alpha ) \f$, WARNING: make sure coefficients of F
    8282/// are really elements of a subfield of \f$ F_{p}(\beta ) \f$ which is
    83 /// isomorphic to \f$ F_{p}(\alpha ) \f$ 
    84 static inline
    85 CanonicalForm 
     83/// isomorphic to \f$ F_{p}(\alpha ) \f$
     84static inline
     85CanonicalForm
    8686mapDown (const CanonicalForm& F, const Variable& alpha, const
    87           CanonicalForm& G, CFList& source, CFList& dest) 
    88 {   
     87          CanonicalForm& G, CFList& source, CFList& dest)
     88{
    8989  CanonicalForm buf, buf2;
    9090  int counter= 0;
     
    9797  CanonicalForm alpha_power;
    9898  if (degree(F) == 0) return F;
    99   if (F.level() < 0 && F.isUnivariate()) 
     99  if (F.level() < 0 && F.isUnivariate())
    100100  {
    101101    buf= F;
    102102    remainder= mod (buf, G);
    103     ASSERT (remainder.isZero(), "alpha is not primitive"); 
     103    ASSERT (remainder.isZero(), "alpha is not primitive");
    104104    pos= findItem (source, buf);
    105105    if (pos == 0)
    106106      source.append (buf);
    107107    buf2= buf;
    108     while (degree (buf) != 0 && counter < bound) 
     108    while (degree (buf) != 0 && counter < bound)
    109109    {
    110110      buf /= G;
    111111      counter++;
    112112      if (buf == buf2) break;
    113     } 
    114     ASSERT (counter >= bound, "alpha is not primitive"); 
    115     if (pos == 0) 
     113    }
     114    ASSERT (counter >= bound, "alpha is not primitive");
     115    if (pos == 0)
    116116    {
    117117      alpha_power= power (alpha, counter);
     
    119119    }
    120120    else
    121       alpha_power= getItem (dest, pos);     
     121      alpha_power= getItem (dest, pos);
    122122    result = alpha_power*buf;
    123123    return result;
    124124  }
    125   else 
    126   {
    127     for (CFIterator i= F; i.hasTerms(); i++) 
     125  else
     126  {
     127    for (CFIterator i= F; i.hasTerms(); i++)
    128128    {
    129129      buf= mapDown (i.coeff(), alpha, G, source, dest);
     
    142142  char gf_name_buf= gf_name;
    143143  InternalCF* buf;
    144   if (F.inBaseDomain()) 
     144  if (F.inBaseDomain())
    145145  {
    146146    if (F.isOne()) return 1;
     
    149149    result= power (alpha, exp).mapinto();
    150150    return result;
    151   } 
     151  }
    152152  for (CFIterator i= F; i.hasTerms(); i++)
    153153    result += GF2FalphaHelper (i.coeff(), alpha)*power (F.mvar(), i.exp());
     
    155155}
    156156
    157 /// changes representation by primitive element to representation by residue 
    158 /// classes modulo a Conway polynomial 
    159 CanonicalForm GF2FalphaRep (const CanonicalForm& F, const Variable& alpha) 
     157/// changes representation by primitive element to representation by residue
     158/// classes modulo a Conway polynomial
     159CanonicalForm GF2FalphaRep (const CanonicalForm& F, const Variable& alpha)
    160160{
    161161  Variable beta= rootOf (gf_mipo);
     
    163163}
    164164
    165 /// change representation by residue classes modulo a Conway polynomial 
     165/// change representation by residue classes modulo a Conway polynomial
    166166/// to representation by primitive element
    167 CanonicalForm Falpha2GFRep (const CanonicalForm& F) 
     167CanonicalForm Falpha2GFRep (const CanonicalForm& F)
    168168{
    169169  CanonicalForm result= 0;
    170170  InternalCF* buf;
    171171
    172   if (F.inCoeffDomain()) 
     172  if (F.inCoeffDomain())
    173173  {
    174174    if (F.inBaseDomain())
    175175      return F.mapinto();
    176     else 
    177     {
    178       for (CFIterator i= F; i.hasTerms(); i++) 
     176    else
     177    {
     178      for (CFIterator i= F; i.hasTerms(); i++)
    179179      {
    180180        buf= int2imm_gf (i.exp());
     
    183183    }
    184184    return result;
    185   } 
    186   for (CFIterator i= F; i.hasTerms(); i++) 
     185  }
     186  for (CFIterator i= F; i.hasTerms(); i++)
    187187    result += Falpha2GFRep (i.coeff())*power (F.mvar(), i.exp());
    188188  return result;
     
    191191/// GF_map_up helper
    192192static inline
    193 CanonicalForm GFPowUp (const CanonicalForm & F, int k) 
     193CanonicalForm GFPowUp (const CanonicalForm & F, int k)
    194194{
    195195  if (F.isOne()) return F;
    196196  CanonicalForm result= 0;
    197   if (F.inBaseDomain()) 
     197  if (F.inBaseDomain())
    198198    return power(F, k);
    199   for (CFIterator i= F; i.hasTerms(); i++) 
     199  for (CFIterator i= F; i.hasTerms(); i++)
    200200    result += GFPowUp (i.coeff(), k)*power (F.mvar(), i.exp());
    201201  return result;
    202202}
    203203
    204 /// maps a polynomial over \f$ GF(p^{k}) \f$ to a polynomial over 
     204/// maps a polynomial over \f$ GF(p^{k}) \f$ to a polynomial over
    205205/// \f$ GF(p^{d}) \f$ , d needs to be a multiple of k
    206 CanonicalForm GFMapUp (const CanonicalForm & F, int k) 
    207 { 
     206CanonicalForm GFMapUp (const CanonicalForm & F, int k)
     207{
    208208  int d= getGFDegree();
    209209  ASSERT (d%k == 0, "multiple of GF degree expected");
     
    217217/// GFMapDown helper
    218218static inline
    219 CanonicalForm GFPowDown (const CanonicalForm & F, int k) 
     219CanonicalForm GFPowDown (const CanonicalForm & F, int k)
    220220{
    221221  if (F.isOne()) return F;
     
    223223  int exp;
    224224  InternalCF* buf;
    225   if (F.inBaseDomain()) 
     225  if (F.inBaseDomain())
    226226  {
    227227    buf= F.getval();
     
    229229    if ((exp % k) == 0)
    230230      exp= exp/k;
    231     else 
     231    else
    232232      return -1;
    233233
    234234    buf= int2imm_gf (exp);
    235235    return CanonicalForm (buf);
    236   } 
    237   for (CFIterator i= F; i.hasTerms(); i++) 
     236  }
     237  for (CFIterator i= F; i.hasTerms(); i++)
    238238    result += GFPowDown (i.coeff(), k)*power (F.mvar(), i.exp());
    239239  return result;
    240240}
    241241
    242 /// maps a polynomial over \f$ GF(p^{d}) \f$ to a polynomial over 
     242/// maps a polynomial over \f$ GF(p^{d}) \f$ to a polynomial over
    243243/// \f$ GF(p^{k})\f$ , d needs to be a multiple of k
    244 CanonicalForm GFMapDown (const CanonicalForm & F, int k) 
     244CanonicalForm GFMapDown (const CanonicalForm & F, int k)
    245245{
    246246  int d= getGFDegree();
     
    253253}
    254254
    255 static inline 
    256 CanonicalForm mapUp (const CanonicalForm& F, const CanonicalForm& G, 
    257                       const Variable& alpha, const CanonicalForm& H, 
     255static inline
     256CanonicalForm mapUp (const CanonicalForm& F, const CanonicalForm& G,
     257                      const Variable& alpha, const CanonicalForm& H,
    258258                      CFList& source, CFList& dest)
    259 { 
     259{
    260260  CanonicalForm buf, buf2;
    261261  int counter= 0;
     
    268268  CanonicalForm H_power;
    269269  if (degree(F) <= 0) return F;
    270   if (F.level() < 0 && F.isUnivariate()) 
     270  if (F.level() < 0 && F.isUnivariate())
    271271  {
    272272    buf= F;
    273273    remainder= mod (buf, G);
    274     ASSERT (remainder.isZero(), "alpha is not primitive"); 
     274    ASSERT (remainder.isZero(), "alpha is not primitive");
    275275    pos= findItem (source, buf);
    276276    if (pos == 0)
    277277      source.append (buf);
    278278    buf2= buf;
    279     while (degree (buf) != 0 && counter < bound) 
     279    while (degree (buf) != 0 && counter < bound)
    280280    {
    281281      buf /= G;
    282282      counter++;
    283283      if (buf == buf2) break;
    284     } 
    285     ASSERT (counter >= bound, "alpha is not primitive"); 
    286     if (pos == 0) 
     284    }
     285    ASSERT (counter >= bound, "alpha is not primitive");
     286    if (pos == 0)
    287287    {
    288288      H_power= power (H, counter);
     
    290290    }
    291291    else
    292       H_power= getItem (dest, pos);     
     292      H_power= getItem (dest, pos);
    293293    result = H_power*buf;
    294294    return result;
    295295  }
    296   else 
    297   {
    298     for (CFIterator i= F; i.hasTerms(); i++) 
     296  else
     297  {
     298    for (CFIterator i= F; i.hasTerms(); i++)
    299299    {
    300300      buf= mapUp (i.coeff(), G, alpha, H, source, dest);
     
    305305}
    306306
    307 /// determine a primitive element of \f$ F_{p} (\alpha ) \f$, 
    308 /// \f$ \beta \f$ is a primitive element of a field which is isomorphic to 
     307/// determine a primitive element of \f$ F_{p} (\alpha ) \f$,
     308/// \f$ \beta \f$ is a primitive element of a field which is isomorphic to
    309309/// \f$ F_{p}(\alpha ) \f$
    310 CanonicalForm 
    311 primitiveElement (const Variable& alpha, Variable& beta, bool fail) 
     310CanonicalForm
     311primitiveElement (const Variable& alpha, Variable& beta, bool fail)
    312312{
    313313  bool primitive= false;
     
    316316  if (fail)
    317317    return 0;
    318   if (primitive) 
     318  if (primitive)
    319319  {
    320320    beta= alpha;
    321321    return alpha;
    322322  }
    323   CanonicalForm mipo= getMipo (alpha); 
     323  CanonicalForm mipo= getMipo (alpha);
    324324  int d= degree (mipo);
    325325  int p= getCharacteristic ();
     
    331331  do
    332332  {
    333     BuildIrred (NTL_mipo, d); 
     333    BuildIrred (NTL_mipo, d);
    334334    mipo2= convertNTLzzpX2CF (NTL_mipo, Variable (1));
    335335    beta= rootOf (mipo2);
    336336    primitive= isPrimitive (beta, fail);
    337337    if (primitive)
    338       break; 
     338      break;
    339339    if (fail)
    340340      return 0;
     
    348348CanonicalForm
    349349mapDown (const CanonicalForm& F, const CanonicalForm& prim_elem, const
    350           CanonicalForm& im_prim_elem, const Variable& alpha, CFList& source, 
    351           CFList& dest) 
    352 {   
     350          CanonicalForm& im_prim_elem, const Variable& alpha, CFList& source,
     351          CFList& dest)
     352{
    353353  return mapUp (F, im_prim_elem, alpha, prim_elem, dest, source);
    354354}
    355355
    356356CanonicalForm
    357 mapUp (const CanonicalForm& F, const Variable& alpha, const Variable& beta, 
    358         const CanonicalForm& prim_elem, const CanonicalForm& im_prim_elem, 
    359         CFList& source, CFList& dest) 
    360 {
    361   if (prim_elem == alpha) 
     357mapUp (const CanonicalForm& F, const Variable& alpha, const Variable& beta,
     358        const CanonicalForm& prim_elem, const CanonicalForm& im_prim_elem,
     359        CFList& source, CFList& dest)
     360{
     361  if (prim_elem == alpha)
    362362    return F (im_prim_elem, alpha);
    363363  return mapUp (F, prim_elem, alpha, im_prim_elem, source, dest);
    364364}
    365365
    366 CanonicalForm 
    367 mapPrimElem (const CanonicalForm& prim_elem, const Variable& alpha, 
     366CanonicalForm
     367mapPrimElem (const CanonicalForm& prim_elem, const Variable& alpha,
    368368             const Variable& beta)
    369369{
     
    377377      result += power (im_alpha, i.exp())*i.coeff();
    378378    return result;
    379   } 
     379  }
    380380}
    381381
  • factory/cf_map_ext.h

    rc840d9 r806c18  
    55/** @file cf_map_ext.h
    66 *
    7  * @author Martin Lee   
     7 * @author Martin Lee
    88 * @date   16.11.2009
    99 *
     
    1313 *   (c) by The SINGULAR Team, see LICENSE file
    1414 *
    15  * @internal 
     15 * @internal
    1616 * @version \$Id$
    1717 *
     
    2626
    2727CanonicalForm
    28 mapUp (const CanonicalForm& F, const Variable& alpha, const Variable& beta, 
    29         const CanonicalForm& prim_elem, const CanonicalForm& im_prim_elem, 
     28mapUp (const CanonicalForm& F, const Variable& alpha, const Variable& beta,
     29        const CanonicalForm& prim_elem, const CanonicalForm& im_prim_elem,
    3030        CFList& source, CFList& dest);
    3131
    3232CanonicalForm
    3333mapDown (const CanonicalForm& F, const CanonicalForm& prim_elem, const
    34           CanonicalForm& im_prim_elem, const Variable& alpha, CFList& source, 
    35           CFList& dest); 
     34          CanonicalForm& im_prim_elem, const Variable& alpha, CFList& source,
     35          CFList& dest);
    3636
    37 CanonicalForm 
     37CanonicalForm
    3838primitiveElement (const Variable& alpha, Variable& beta, bool fail);
    3939
    40 CanonicalForm 
    41 mapPrimElem (const CanonicalForm& prim_elem, const Variable& alpha, 
     40CanonicalForm
     41mapPrimElem (const CanonicalForm& prim_elem, const Variable& alpha,
    4242             const Variable& beta);
    4343
  • factory/cf_primes.cc

    rc840d9 r806c18  
    1515    ASSERT( i >= 0 && i < NUMPRIMES, "index to primes too high" );
    1616    if ( i >= NUMSMALLPRIMES )
    17         return bigprimes[i-NUMSMALLPRIMES];
     17        return bigprimes[i-NUMSMALLPRIMES];
    1818    else
    19         return smallprimes[i];
     19        return smallprimes[i];
    2020}
    2121
  • factory/cf_random.cc

    rc840d9 r806c18  
    144144    CanonicalForm result;
    145145    for ( int i = 0; i < n; i++ )
    146         result += power( algext, i ) * gen->generate();
     146      result += power( algext, i ) * gen->generate();
    147147    return result;
    148148};
     
    156156{
    157157    if ( getCharacteristic() == 0 )
    158         return new IntRandom();
     158        return new IntRandom();
    159159    if ( getGFDegree() > 1 )
    160         return new GFRandom();
     160        return new GFRandom();
    161161    else
    162         return new FFRandom();
     162        return new FFRandom();
    163163}
    164164
     
    166166{
    167167    if ( n == 0 )
    168         return (int)ranGen.generate();
     168        return (int)ranGen.generate();
    169169    else
    170         return ranGen.generate() % n;
     170        return ranGen.generate() % n;
    171171}
    172172
  • factory/cf_resultant.cc

    rc840d9 r806c18  
    4848    // some checks on triviality
    4949    if ( f.isZero() || g.isZero() ) {
    50         trivialResult[0] = 0;
    51         return trivialResult;
     50        trivialResult[0] = 0;
     51        return trivialResult;
    5252    }
    5353
    5454    // make x main variable
    5555    if ( f.mvar() > x || g.mvar() > x ) {
    56         if ( f.mvar() > g.mvar() )
    57             X = f.mvar();
    58         else
    59             X = g.mvar();
    60         F = swapvar( f, X, x );
    61         G = swapvar( g, X, x );
     56        if ( f.mvar() > g.mvar() )
     57            X = f.mvar();
     58        else
     59            X = g.mvar();
     60        F = swapvar( f, X, x );
     61        G = swapvar( g, X, x );
    6262    }
    6363    else {
    64         X = x;
    65         F = f;
    66         G = g;
     64        X = x;
     65        F = f;
     66        G = g;
    6767    }
    6868    // at this point, we have to calculate the sequence of F and
     
    8383    // make sure that S[j+1] is regular and j < n
    8484    if ( m == n && j > 0 ) {
    85         S[j-1] = LC( S[j], X ) * psr( S[j+1], S[j], X );
    86         j--;
     85        S[j-1] = LC( S[j], X ) * psr( S[j+1], S[j], X );
     86        j--;
    8787    } else if ( m < n ) {
    88         S[j-1] = LC( S[j], X ) * LC( S[j], X ) * S[j+1];
    89         j--;
     88        S[j-1] = LC( S[j], X ) * LC( S[j], X ) * S[j+1];
     89        j--;
    9090    } else if ( m > n && j > 0 ) {
    91         // calculate first step
    92         r = degree( S[j], X );
    93         R = LC( S[j+1], X );
    94 
    95         // if there was a gap calculate similar polynomial
    96         if ( j > r && r >= 0 )
    97             S[r] = power( LC( S[j], X ), j - r ) * S[j] * power( R, j - r );
    98 
    99         if ( r > 0 ) {
    100             // calculate remainder
    101             S[r-1] = psr( S[j+1], S[j], X ) * power( -R, j - r );
    102             j = r-1;
    103         }
     91        // calculate first step
     92        r = degree( S[j], X );
     93        R = LC( S[j+1], X );
     94
     95        // if there was a gap calculate similar polynomial
     96        if ( j > r && r >= 0 )
     97            S[r] = power( LC( S[j], X ), j - r ) * S[j] * power( R, j - r );
     98
     99        if ( r > 0 ) {
     100            // calculate remainder
     101            S[r-1] = psr( S[j+1], S[j], X ) * power( -R, j - r );
     102            j = r-1;
     103        }
    104104    }
    105105
    106106    while ( j > 0 ) {
    107         // at this point, 0 < j < n and S[j+1] is regular
    108         r = degree( S[j], X );
    109         R = LC( S[j+1], X );
    110        
    111         // if there was a gap calculate similar polynomial
    112         if ( j > r && r >= 0 )
    113             S[r] = (power( LC( S[j], X ), j - r ) * S[j]) / power( R, j - r );
    114 
    115         if ( r <= 0 ) break;
    116         // calculate remainder
    117         S[r-1] = psr( S[j+1], S[j], X ) / power( -R, j - r + 2 );
    118 
    119         j = r-1;
    120         // again 0 <= j < r <= jOld and S[j+1] is regular
     107        // at this point, 0 < j < n and S[j+1] is regular
     108        r = degree( S[j], X );
     109        R = LC( S[j+1], X );
     110
     111        // if there was a gap calculate similar polynomial
     112        if ( j > r && r >= 0 )
     113            S[r] = (power( LC( S[j], X ), j - r ) * S[j]) / power( R, j - r );
     114
     115        if ( r <= 0 ) break;
     116        // calculate remainder
     117        S[r-1] = psr( S[j+1], S[j], X ) / power( -R, j - r + 2 );
     118
     119        j = r-1;
     120        // again 0 <= j < r <= jOld and S[j+1] is regular
    121121    }
    122122
    123123    for ( j = 0; j <= S.max(); j++ ) {
    124         // reswap variables if necessary
    125         if ( X != x ) {
    126             S[j] = swapvar( S[j], X, x );
    127         }
     124        // reswap variables if necessary
     125        if ( X != x ) {
     126            S[j] = swapvar( S[j], X, x );
     127        }
    128128    }
    129129
     
    148148    // f or g in R
    149149    if ( degree( f, x ) == 0 )
    150         return power( f, degree( g, x ) );
     150        return power( f, degree( g, x ) );
    151151    if ( degree( g, x ) == 0 )
    152         return power( g, degree( f, x ) );
     152        return power( g, degree( f, x ) );
    153153
    154154    // f and g are linear polynomials
     
    180180    // here because this may involve variable swapping.
    181181    if ( f.isZero() || g.isZero() )
    182         return 0;
     182        return 0;
    183183    if ( f.mvar() < x )
    184         return power( f, g.degree( x ) );
     184        return power( f, g.degree( x ) );
    185185    if ( g.mvar() < x )
    186         return power( g, f.degree( x ) );
     186        return power( g, f.degree( x ) );
    187187
    188188    // make x main variale
     
    190190    Variable X;
    191191    if ( f.mvar() > x || g.mvar() > x ) {
    192         if ( f.mvar() > g.mvar() )
    193             X = f.mvar();
    194         else
    195             X = g.mvar();
    196         F = swapvar( f, X, x );
    197         G = swapvar( g, X, x );
     192        if ( f.mvar() > g.mvar() )
     193            X = f.mvar();
     194        else
     195            X = g.mvar();
     196        F = swapvar( f, X, x );
     197        G = swapvar( g, X, x );
    198198    }
    199199    else {
    200         X = x;
    201         F = f;
    202         G = g;
     200        X = x;
     201        F = f;
     202        G = g;
    203203    }
    204204    // at this point, we have to calculate resultant( F, G, X )
     
    210210    // catch trivial cases
    211211    if ( m+n <= 2 || m == 0 || n == 0 )
    212         return swapvar( trivialResultant( F, G, X ), X, x );
     212        return swapvar( trivialResultant( F, G, X ), X, x );
    213213
    214214    // exchange F and G if necessary
    215215    int flipFactor;
    216216    if ( m < n ) {
    217         CanonicalForm swap = F;
    218         F = G; G = swap;
    219         int degswap = m;
    220         m = n; n = degswap;
    221         if ( m & 1 && n & 1 )
    222             flipFactor = -1;
    223         else
    224             flipFactor = 1;
     217        CanonicalForm swap = F;
     218        F = G; G = swap;
     219        int degswap = m;
     220        m = n; n = degswap;
     221        if ( m & 1 && n & 1 )
     222            flipFactor = -1;
     223        else
     224            flipFactor = 1;
    225225    } else
    226         flipFactor = 1;
     226        flipFactor = 1;
    227227
    228228    // this is not an effective way to calculate the resultant!
    229229    CanonicalForm extFactor;
    230230    if ( m == n ) {
    231         if ( n & 1 )
    232             extFactor = -LC( G, X );
    233         else
    234             extFactor = LC( G, X );
     231        if ( n & 1 )
     232            extFactor = -LC( G, X );
     233        else
     234            extFactor = LC( G, X );
    235235    } else
    236         extFactor = power( LC( F, X ), m-n-1 );
     236        extFactor = power( LC( F, X ), m-n-1 );
    237237
    238238    CanonicalForm result;
  • factory/cf_reval.cc

    rc840d9 r806c18  
    1515{
    1616    if ( e.gen == 0 )
    17         gen = 0;
     17        gen = 0;
    1818    else
    19         gen = e.gen->clone();
     19        gen = e.gen->clone();
    2020    values = e.values;
    2121}
     
    2424{
    2525    if ( gen != 0 )
    26         delete gen;
     26        delete gen;
    2727}
    2828
     
    3232    if ( this != &e ) {
    3333        if (gen!=0)
    34           delete gen;
    35         values = e.values;
    36         if ( e.gen == 0 )
    37             gen = 0;
    38         else
    39             gen = e.gen->clone();
     34          delete gen;
     35        values = e.values;
     36        if ( e.gen == 0 )
     37            gen = 0;
     38        else
     39            gen = e.gen->clone();
    4040    }
    4141    return *this;
     
    4747    int n = values.max();
    4848    for ( int i = values.min(); i <= n; i++ )
    49         values[i] = gen->generate();
     49        values[i] = gen->generate();
    5050}
  • factory/cf_switches.cc

    rc840d9 r806c18  
    2626{
    2727    for ( int i = 0; i < CFSwitchesMax; i++ )
    28         switches[i] = false;
     28        switches[i] = false;
    2929// and set the default (recommended) On-values:
    3030#ifdef HAVE_NTL
  • factory/debug.cc

    rc840d9 r806c18  
    1111    // deb_level == -1 iff we enter this function for the first time
    1212    if ( deb_level == -1 )
    13         deb_level = 0;
     13        deb_level = 0;
    1414    else
    15         delete [] deb_level_msg;
     15        delete [] deb_level_msg;
    1616
    1717    deb_level++;
    1818    deb_level_msg = new char[3*deb_level+1];
    1919    for ( i = 0; i < 3*deb_level; i++ )
    20         deb_level_msg[i] = ' ';
     20        deb_level_msg[i] = ' ';
    2121    deb_level_msg[3*deb_level] = '\0';
    2222}
     
    2525{
    2626    if ( deb_level > 0 ) {
    27         int i;
    28         deb_level--;
    29         delete [] deb_level_msg;
    30         deb_level_msg = new char[3*deb_level+1];
    31             for ( i = 0; i < 3*deb_level; i++ )
    32                 deb_level_msg[i] = ' ';
    33         deb_level_msg[3*deb_level] = '\0';
     27        int i;
     28        deb_level--;
     29        delete [] deb_level_msg;
     30        deb_level_msg = new char[3*deb_level+1];
     31            for ( i = 0; i < 3*deb_level; i++ )
     32                deb_level_msg[i] = ' ';
     33        deb_level_msg[3*deb_level] = '\0';
    3434    }
    3535}
  • factory/facAlgExt.cc

    rc840d9 r806c18  
    44 *
    55 * @author Martin Lee
    6  * @date 
     6 * @date
    77 *
    88 * Univariate factorization over algebraic extension of Q using Trager's
     
    1212 *   (c) by The SINGULAR Team, see LICENSE file
    1313 *
    14  * @internal 
     14 * @internal
    1515 * @version \$Id$
    1616 *
     
    3838  CanonicalForm G= deriv (F, F.mvar());
    3939  G= gcd (F, G);
    40   return F/G; 
     40  return F/G;
    4141}
    4242
     
    4949  CanonicalForm mipo= getMipo (alpha);
    5050  mipo= mipo (x, alpha);
    51  
     51
    5252  CanonicalForm norm= resultant (g, mipo, x);
    5353  i= 0;
     
    8888  ASSERT (F.isUnivariate(), "univariate input expected");
    8989  ASSERT (getCharacteristic() == 0, "characteristic 0 expected");
    90  
     90
    9191  On (SW_RATIONAL);
    92   CanonicalForm f= F; 
     92  CanonicalForm f= F;
    9393  int shift;
    9494  CanonicalForm norm= sqrfNorm (f, alpha, shift);
     
    9898  if (normFactors.length() <= 2)
    9999    return CFList (f);
    100    
     100
    101101  normFactors.removeFirst();
    102102  CanonicalForm buf;
     
    104104    buf= f (f.mvar() - shift*alpha, f.mvar());
    105105  else
    106     buf= f;   
     106    buf= f;
    107107  CanonicalForm factor;
    108108  for (CFFListIterator i= normFactors; i.hasItem(); i++)
     
    112112    buf /= factor;
    113113    if (shift != 0)
    114       factor= factor (f.mvar() + shift*alpha, f.mvar());     
     114      factor= factor (f.mvar() + shift*alpha, f.mvar());
    115115    factors.append (factor);
    116   } 
     116  }
    117117  ASSERT (degree (buf) <= 0, "incomplete factorization");
    118118  Off (SW_RATIONAL);
     
    120120}
    121121
    122 CFFList 
     122CFFList
    123123AlgExtFactorize (const CanonicalForm& F, const Variable& alpha)
    124124{
    125125  ASSERT (F.isUnivariate(), "univariate input expected");
    126126  ASSERT (getCharacteristic() == 0, "characteristic 0 expected");
    127  
     127
    128128  if (F.inCoeffDomain())
    129129    return CFFList (CFFactor (F, 1));
     
    135135  CanonicalForm buf= F/Lc (F);
    136136  CFFList factors;
    137   int multi; 
     137  int multi;
    138138  for (CFListIterator i= sqrfFactors; i.hasItem(); i++)
    139139  {
     
    146146    }
    147147    factors.append (CFFactor (i.getItem(), multi));
    148   } 
     148  }
    149149  Off (SW_RATIONAL);
    150150  factors.insert (CFFactor (Lc(F), 1));
    151151  ASSERT (degree (buf) <= 0, "bug in AlgExtFactorize");
    152   return factors; 
     152  return factors;
    153153}
    154154
  • factory/facAlgExt.h

    rc840d9 r806c18  
    44 *
    55 * @author Martin Lee
    6  * @date 
     6 * @date
    77 *
    88 * Univariate factorization over algebraic extension of Q using Trager's
     
    1212 *   (c) by The SINGULAR Team, see LICENSE file
    1313 *
    14  * @internal 
     14 * @internal
    1515 * @version \$Id$
    1616 *
     
    2424///factorize a univariate squarefree polynomial over algebraic extension of Q
    2525///
    26 /// @return @a AlgExtSqrfFactorize returns a list of factors of F 
    27 CFList 
     26/// @return @a AlgExtSqrfFactorize returns a list of factors of F
     27CFList
    2828AlgExtSqrfFactorize (const CanonicalForm& F, ///<[in] a univariate squarefree
    2929                                             ///< polynomial
     
    3333/// factorize a univariate polynomial over algebraic extension of Q
    3434///
    35 /// @return @a AlgExtFactorize returns a list of factors of F with multiplicity                   
    36 CFFList 
     35/// @return @a AlgExtFactorize returns a list of factors of F with multiplicity
     36CFFList
    3737AlgExtFactorize (const CanonicalForm& F, ///<[in] a univariate polynomial
    3838                 const Variable& alpha   ///<[in] an algebraic variable
  • factory/facFqBivar.cc

    rc840d9 r806c18  
    11/*****************************************************************************\
    2  * Computer Algebra System SINGULAR   
     2 * Computer Algebra System SINGULAR
    33\*****************************************************************************/
    44/** @file facFqBivar.cc
    5  * 
     5 *
    66 * This file provides functions for factorizing a bivariate polynomial over
    7  * \f$ F_{p} \f$ , \f$ F_{p}(\alpha ) \f$ or GF, based on "Modern Computer 
    8  * Algebra, Chapter 15" by J. von zur Gathen & J. Gerhard and "Factoring 
    9  * multivariate polynomials over a finite field" by L. Bernardin.   
     7 * \f$ F_{p} \f$ , \f$ F_{p}(\alpha ) \f$ or GF, based on "Modern Computer
     8 * Algebra, Chapter 15" by J. von zur Gathen & J. Gerhard and "Factoring
     9 * multivariate polynomials over a finite field" by L. Bernardin.
    1010 *
    11  * ABSTRACT: In contrast to biFactorizer() in facFqFactorice.cc we evaluate and 
    12  * factorize the polynomial in both variables. So far factor recombination is 
    13  * done naive!         
     11 * ABSTRACT: In contrast to biFactorizer() in facFqFactorice.cc we evaluate and
     12 * factorize the polynomial in both variables. So far factor recombination is
     13 * done naive!
    1414 *
    1515 * @author Martin Lee
     
    4343TIMING_DEFINE_PRINT(fac_factor_recombination);
    4444
    45 CanonicalForm prodMod0 (const CFList& L, const CanonicalForm& M) 
     45CanonicalForm prodMod0 (const CFList& L, const CanonicalForm& M)
    4646{
    4747  if (L.isEmpty())
     
    5757    CFList tmp1, tmp2;
    5858    CanonicalForm buf1, buf2;
    59     for (int j= 1; j <= l; j++, i++) 
     59    for (int j= 1; j <= l; j++, i++)
    6060      tmp1.append (i.getItem());
    6161    tmp2= Difference (L, tmp1);
     
    6666}
    6767