Changeset 14b1e65 in git for libfac/factor/SqrFree.cc


Ignore:
Timestamp:
Aug 8, 2001, 1:59:13 PM (23 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
456842ed1cd4bb0af35f859e0befe623c3991393
Parents:
c794a95c85e7ae1437369ab150d85b7c4ff17fd0
Message:
*hannes: Dan's NOSTREAMIO changes


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

Legend:

Unmodified
Added
Removed
  • libfac/factor/SqrFree.cc

    rc794a9 r14b1e65  
    22///////////////////////////////////////////////////////////////////////////////
    33// emacs edit mode for this file is -*- C++ -*-
    4 static char * rcsid = "$Id: SqrFree.cc,v 1.4 1997-11-18 16:39:06 Singular Exp $";
     4static char * rcsid = "$Id: SqrFree.cc,v 1.5 2001-08-08 11:59:13 Singular Exp $";
    55static char * errmsg = "\nYou found a bug!\nPlease inform (Michael Messollen) michael@math.uni-sb.de .\n Please include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
    66///////////////////////////////////////////////////////////////////////////////
    77// FACTORY - Includes
    88#include<factory.h>
     9#ifndef NOSTREAMIO
     10#include <iostream.h>
     11#endif
    912// Factor - Includes
    1013#include "tmpl_inst.h"
     
    3033
    3134
    32 static inline CFFactor 
    33 Powerup( const CFFactor & F , int exp=1){ 
    34   return CFFactor(F.factor(), exp*F.exp()) ; 
    35 }
    36 
    37 static CFFList 
     35static inline CFFactor
     36Powerup( const CFFactor & F , int exp=1){
     37  return CFFactor(F.factor(), exp*F.exp()) ;
     38}
     39
     40static CFFList
    3841Powerup( const CFFList & Inputlist , int exp=1 ){
    3942  CFFList Outputlist;
     
    4952// Domain is q=p^m , f a uni/multivariate polynomial         //
    5053///////////////////////////////////////////////////////////////
    51 static CanonicalForm 
     54static CanonicalForm
    5255PthRoot( const CanonicalForm & f ){
    5356  CanonicalForm RES, R = f;
    5457  int n= max(level(R),getNumVars(R)), p= getCharacteristic();
    55  
     58
    5659  if (n==0){ // constant
    5760    if (R.inExtension()) // not in prime field; f over |F(q=p^k)
     
    9093    g = mygcd(f,g);
    9194    if ( g.isOne() || (-g).isOne() ) return 1;
    92     else 
     95    else
    9396      if ( getNumVars(g) == 0 ) return 1;// <- totaldegree!!!
    9497      else return 0 ;
     
    99102      // g = 1 || -1 : sqr-free, g poly : not sqr-free, g number : opt helps
    100103      if ( ! (g.isOne() || (-g).isOne() || getNumVars(g)==0 ) ) {
    101         if ( opt==0 ) return 0;
    102         else {
    103           if ( SqrFreeTest(g,1) == 0 ) return 0;
    104           g = swapvar(g,k,n);
    105           f /=g ;
    106         }
     104        if ( opt==0 ) return 0;
     105        else {
     106          if ( SqrFreeTest(g,1) == 0 ) return 0;
     107          g = swapvar(g,k,n);
     108          f /=g ;
     109        }
    107110      }
    108111    }
     
    110113    n = level(f); // maybe less indeterminants
    111114    //    if ( totaldegree(f) <= 1 ) return 1;
    112    
     115
    113116    // Let`s look if it is a Pth root
    114117    if ( getCharacteristic() > 0 )
    115118      for (int k=1; k<=n; k++ ) {
    116         g=swapvar(f,k,n); g=g.deriv();
    117         if ( ! g.isZero() ) break ;
    118         else if ( k==n) return 0 ; // really is Pth root
     119        g=swapvar(f,k,n); g=g.deriv();
     120        if ( ! g.isZero() ) break ;
     121        else if ( k==n) return 0 ; // really is Pth root
    119122      }
    120123    g = f.deriv() ;
     
    128131  WerrorS("libfac: ERROR: SqrFreeTest: we should never fall trough here!");
    129132#else
    130   cerr << "\nlibfac: ERROR: SqrFreeTest: we should never fall trough here!\n" 
     133  cerr << "\nlibfac: ERROR: SqrFreeTest: we should never fall trough here!\n"
    131134       << rcsid << errmsg << endl;
    132135#endif
     
    141144// needs not to be 1 !!!!!                                   //
    142145///////////////////////////////////////////////////////////////
    143 static CFFList 
     146static CFFList
    144147SqrFreed( const CanonicalForm & r ){
    145148  CanonicalForm h, g, f = r;
     
    154157  }
    155158
    156 // We look if we do have a content; if so, SqrFreed the content 
     159// We look if we do have a content; if so, SqrFreed the content
    157160// and continue computations with pp(f)
    158161  for (int k=1; k<=n; k++) {
     
    161164      g = swapvar(g,k,n);
    162165      DEBOUTLN(cout, "We have a content: ", g);
    163       Outputlist = myUnion(InternalSqrFree(g),Outputlist); // should we add a 
     166      Outputlist = myUnion(InternalSqrFree(g),Outputlist); // should we add a
    164167                                                // SqrFreeTest(g) first ?
    165168      DEBOUTLN(cout, "Outputlist is now: ", Outputlist);
     
    177180      f /= g;
    178181    }
    179     Outputlist = Union(sqrFree(f),Outputlist) ; 
     182    Outputlist = Union(sqrFree(f),Outputlist) ;
    180183    DEBOUTLN(cout, "Outputlist after univ. sqrFree(f) = ", Outputlist);
    181184    DEBDECLEVEL(cout, "SqrFreed");
     
    197200      g=swapvar(f,k,n) ; g = g.deriv();
    198201      if ( ! g.isZero() ){ // can`t be Pth root
    199         CFFList Outputlist2= SqrFreed(swapvar(f,k,n));
    200         for (CFFListIterator inter=Outputlist2; inter.hasItem(); inter++){
    201           Outputlist= myappend(Outputlist, CFFactor(swapvar(inter.getItem().factor(),k,n), inter.getItem().exp()));
    202         }
    203         return Outputlist;
     202        CFFList Outputlist2= SqrFreed(swapvar(f,k,n));
     203        for (CFFListIterator inter=Outputlist2; inter.hasItem(); inter++){
     204          Outputlist= myappend(Outputlist, CFFactor(swapvar(inter.getItem().factor(),k,n), inter.getItem().exp()));
     205        }
     206        return Outputlist;
    204207      }
    205       else 
    206         if ( k==n ) { // really is Pth power
     208      else
     209        if ( k==n ) { // really is Pth power
    207210          DEBOUTLN(cout, "f is a p'th root: ", f);
    208           CFMap m;
     211          CFMap m;
    209212          g = compress(f,m);
    210           f = m(PthRoot(g));
     213          f = m(PthRoot(g));
    211214          DEBOUTLN(cout, "  that is       : ", f);
    212           // now : Outputlist union ( SqrFreed(f) )^getCharacteristic()
    213           Outputlist=myUnion(Powerup(InternalSqrFree(f),getCharacteristic()),Outputlist);
    214           DEBDECLEVEL(cout, "SqrFreed");
    215           return Outputlist ;
    216         }
     215          // now : Outputlist union ( SqrFreed(f) )^getCharacteristic()
     216          Outputlist=myUnion(Powerup(InternalSqrFree(f),getCharacteristic()),Outputlist);
     217          DEBDECLEVEL(cout, "SqrFreed");
     218          return Outputlist ;
     219        }
    217220    }
    218221  }
     
    254257  WerrorS("libfac: ERROR: SqrFreed: we should never fall trough here!");
    255258#else
    256   cerr << "\nlibfac: ERROR: SqrFreed: we should never fall trough here!\n" 
     259  cerr << "\nlibfac: ERROR: SqrFreed: we should never fall trough here!\n"
    257260       << rcsid << errmsg << endl;
    258261#endif
     
    265268// Input can have a constant as content                      //
    266269///////////////////////////////////////////////////////////////
    267 CFFList 
     270CFFList
    268271InternalSqrFree( const CanonicalForm & r ){
    269272  CanonicalForm g=icontent(r), f = r;
     
    285288      f /= g;
    286289      if ( getNumVars(f) != 0 ) // a real polynomial
    287         Outputlist=myUnion(SqrFreed(f),Outputlist) ;
     290        Outputlist=myUnion(SqrFreed(f),Outputlist) ;
    288291  }
    289292  DEBOUTLN(cout,"Outputlist = ", Outputlist);
     
    331334/*
    332335$Log: not supported by cvs2svn $
     336Revision 1.4  1997/11/18 16:39:06  Singular
     337* hannes: moved WerrorS from C++ to C
     338     (Factor.cc MVMultiHensel.cc SqrFree.cc Truefactor.cc)
     339
    333340Revision 1.3  1997/09/12 07:19:50  Singular
    334341* hannes/michael: libfac-0.3.0
Note: See TracChangeset for help on using the changeset viewer.