Changeset b86107 in git


Ignore:
Timestamp:
Aug 3, 2012, 1:00:23 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'cbf866d4f8c3861325311c042cb2033c053453b2')
Children:
c10f46e6c7991d296a0430998c801a958c5f4036
Parents:
4093f96acfcc6419c56ee983c447099c3b87a36e2d71dd455de206f556c8c2200d3bc739a4a48ebb
Message:
Merge pull request #163 from mmklee/libfac_fix_sw

Libfac fix sw
Location:
factory
Files:
48 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • factory/libfac/Makefile.am

    r4093f9 rb86107  
    4848EXTRA_DIST = factor/class.cc \
    4949      factor/test.cc test.cc testcs.cc header.tpl \
    50       tests charset/tests bin \
     50      charset/tests bin \
    5151      ChangeLog 00README
    5252
  • factory/libfac/charset/alg_factor.cc

    r4093f9 rb86107  
    22// emacs edit mode for this file is -*- C++ -*-
    33////////////////////////////////////////////////////////////
    4 ////////////////////////////////////////////////////////////
     4
    55// FACTORY - Includes
    66#include <factory.h>
     
    1818#include "alg_factor.h"
    1919
    20 void out_cf(char *s1,const CanonicalForm &f,char *s2);
     20void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
    2121
    2222#ifdef ALGFACTORDEBUG
     
    8080// replacement for factory's broken psr
    8181static CanonicalForm
    82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){
     82mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x )
     83{
    8384  CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue;
    8485  int dr, dv, d,n=0;
     
    104105// replacement for factory's broken resultant
    105106static CanonicalForm
    106 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){
     107resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v )
     108{
    107109  bool on_rational = isOn(SW_RATIONAL);
    108110  On(SW_RATIONAL);
     
    113115  if (!on_rational)  Off(SW_RATIONAL);
    114116
    115 return resultant(fz,gz,v);
     117  return resultant(fz,gz,v);
    116118}
    117119
     
    133135sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    134136           CFGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    135            CanonicalForm & R){
     137           CanonicalForm & R)
     138{
    136139  Variable y=PPalpha.mvar(),vf=f.mvar();
    137140  CanonicalForm temp, Palpha=PPalpha, t;
     
    147150
    148151  // Norm, resultante taken with respect to y
    149   while ( !sqfreetest ){
     152  while ( !sqfreetest )
     153  {
    150154    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
    151155    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
     
    160164      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
    161165    }
    162     else{
     166    else
     167    {
    163168      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    164169      // Look at SqrFreeTest!
     
    169174      if (getAlgVar(R,X))
    170175      {
    171         if (R.isUnivariate())
    172176          testlist=factorize( R, X );
    173         else
    174           testlist= Factorize(R, X, 0);
    175177      }
    176178      else
     
    183185      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
    184186    }
    185     if ( ! sqfreetest ){
     187    if ( ! sqfreetest )
     188    {
    186189      myrandom.next();
    187190      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
     
    198201sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    199202           AlgExtGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    200            CanonicalForm & R){
     203           CanonicalForm & R)
     204{
    201205  Variable y=PPalpha.mvar(),vf=f.mvar();
    202206  CanonicalForm temp, Palpha=PPalpha, t;
     
    212216
    213217  // Norm, resultante taken with respect to y
    214   while ( !sqfreetest ){
     218  while ( !sqfreetest )
     219  {
    215220    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
    216221    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
     
    225230      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
    226231    }
    227     else{
     232    else
     233    {
    228234      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    229235      // Look at SqrFreeTest!
     
    234240      if (getAlgVar(R,X))
    235241      {
    236         if (R.isUnivariate())
    237242          testlist=factorize( R, X );
    238         else
    239           testlist= Factorize(R, X, 0);
    240243      }
    241244      else
     
    248251      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
    249252    }
    250     if ( ! sqfreetest ){
     253    if ( ! sqfreetest )
     254    {
    251255      myrandom.next();
    252256      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
     
    264268sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha,
    265269           const Variable & Extension, CanonicalForm & s,  CanonicalForm & g,
    266            CanonicalForm & R){
    267 
     270           CanonicalForm & R)
     271{
    268272  DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
    269273  DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
    270   if ( getCharacteristic() == 0 ) {
     274  if ( getCharacteristic() == 0 )
     275  {
    271276    IntGenerator myrandom;
    272277    DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0");
     
    278283    DEBOUTLN(CERR, "sqrf_norm:      R= ", R);
    279284  }
    280   else if ( degree(Extension) > 0 ){ // working over Extensions
     285  else if ( degree(Extension) > 0 ) // working over Extensions
     286  {
    281287    DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension));
    282288    AlgExtGenerator myrandom(Extension);
    283289    sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R);
    284290  }
    285   else{
     291  else
     292  {
    286293    FFGenerator myrandom;
    287294    DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0");
     
    296303  Variable x;
    297304
    298   for ( VarlistIterator i=uord; i.hasItem(); i++){
     305  for ( VarlistIterator i=uord; i.hasItem(); i++)
     306  {
    299307    x=i.getItem();
    300     for ( CFListIterator j=Astar; j.hasItem(); j++ ){
     308    for ( CFListIterator j=Astar; j.hasItem(); j++ )
     309    {
    301310      elem= j.getItem();
    302       if ( degree(elem,x) > 0 ){ // x actually occures in Astar
     311      if ( degree(elem,x) > 0 ) // x actually occures in Astar
     312      {
    303313        output.append(x);
    304314        break;
     
    312322// Must be a power of p: i.e. y^{p^e}-x
    313323static int
    314 inseperable(const CFList & Astar){
     324inseperable(const CFList & Astar)
     325{
    315326  CanonicalForm elem;
    316327  int Counter= 1;
    317328
    318329  if ( Astar.length() == 0 ) return 0;
    319   for ( CFListIterator i=Astar; i.hasItem(); i++){
     330  for ( CFListIterator i=Astar; i.hasItem(); i++)
     331  {
    320332    elem= i.getItem();
    321333    if ( elem.deriv() == elem.genZero() ) return Counter;
     
    327339// calculate gcd of f and g in char=0
    328340static CanonicalForm
    329 gcd0( CanonicalForm f, CanonicalForm g ){
     341gcd0( CanonicalForm f, CanonicalForm g )
     342{
    330343  int charac= getCharacteristic();
    331344  int save=isOn(SW_RATIONAL);
     
    333346  CanonicalForm ff= mapinto(f), gg= mapinto(g);
    334347  CanonicalForm result= gcd(ff,gg);
    335   setCharacteristic(charac); 
     348  setCharacteristic(charac);
    336349  if (save) On(SW_RATIONAL);
    337350  return mapinto(result);
     
    344357// have enough elements to plug in.
    345358static int
    346 getextension( IntList & degreelist, int n){
     359getextension( IntList & degreelist, int n)
     360{
    347361  int charac= getCharacteristic();
    348362  setCharacteristic(0); // need it for k !
     
    543557
    544558static CFFList
    545 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){
     559endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord )
     560{
    546561  CanonicalForm F=f, g, q,r;
    547562  CFFList Output;
     
    551566  Variable vg;
    552567
    553   for (i=as; i.hasItem(); i++){
     568  for (i=as; i.hasItem(); i++)
     569  {
    554570    g= i.getItem();
    555     if (g.deriv() == 0 ){
     571    if (g.deriv() == 0 )
     572    {
    556573      DEBOUTLN(CERR, "Inseperable extension detected: ", g);
    557       for (j=uord; j.hasItem(); j++){
     574      for (j=uord; j.hasItem(); j++)
     575      {
    558576        if ( degree(g,j.getItem()) > 0 ) vg= j.getItem();
    559577      }
     
    568586      // Now transform all remaining polys in as:
    569587      int x=0;
    570       for (ii=i; ii.hasItem(); ii++){
    571         if ( x != 0 ){
     588      for (ii=i; ii.hasItem(); ii++)
     589      {
     590        if ( x != 0 )
     591        {
    572592          divrem(ii.getItem(), gg, q,r);
    573593//          CERR << ii.getItem() << " divided by " << gg << "\n";
     
    595615
    596616  // Transform back:
    597   for ( CFFListIterator k=factorlist; k.hasItem(); k++){
     617  for ( CFFListIterator k=factorlist; k.hasItem(); k++)
     618  {
    598619    CanonicalForm factor= k.getItem().factor();
    599620    ii=One;
    600     for (i=Two; i.hasItem(); i++){
     621    for (i=Two; i.hasItem(); i++)
     622    {
    601623      DEBOUTLN(CERR, "Mapping ", i.getItem());
    602624      DEBOUTLN(CERR, "     to ", ii.getItem());
     
    618640//           no transcendentals, seperable and inseperable extensions
    619641CFFList
    620 newfactoras( const CanonicalForm & f, const CFList & as, int &success){
     642newfactoras( const CanonicalForm & f, const CFList & as, int &success)
     643{
    621644  Variable vf=f.mvar();
    622645  CFListIterator i;
     
    751774
    752775CFFList
    753 newcfactor(const CanonicalForm & f, const CFList & as, int & success ){
     776newcfactor(const CanonicalForm & f, const CFList & as, int & success )
     777{
    754778  Off(SW_RATIONAL);
    755   CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL);
     779  CFFList Output, output, Factors=Factorize(f);
     780  On(SW_RATIONAL);
    756781  Factors.removeFirst();
    757782
     
    760785
    761786  success=1;
    762   for ( CFFListIterator i=Factors; i.hasItem(); i++ ){
     787  for ( CFFListIterator i=Factors; i.hasItem(); i++ )
     788  {
    763789    output=newfactoras(i.getItem().factor(),as, success);
    764790    for ( CFFListIterator j=output; j.hasItem(); j++)
  • factory/libfac/charset/charset.cc

    r4093f9 rb86107  
    493493    if ( degree(elem) > 1 ) // linear poly's are irreduzible
    494494    {
    495       qs = Factorize(elem);
     495      qs = factorize(elem);
    496496      // remove a constant
    497497      if (qs.getFirst().factor().degree()==0) qs.removeFirst();
  • factory/libfac/configure

    r4093f9 rb86107  
    530530libfac_name="\"Factorization and characteristic sets library\""
    531531
    532 libfac_version="3.1.3"
     532libfac_version="3.1.5"
    533533cat >> confdefs.h <<EOF
    534534#define LIBFAC_VERSION "$libfac_version"
     
    536536
    537537
    538 libfac_date="\"March 2011\""
     538libfac_date="\"July 2012\""
    539539cat >> confdefs.h <<EOF
    540540#define LIBFAC_DATE $libfac_date
  • factory/libfac/configure.in

    r4093f9 rb86107  
    1515libfac_name="\"Factorization and characteristic sets library\""
    1616AC_SUBST(libfac_name)
    17 libfac_version="3.1.3"
     17libfac_version="3.1.5"
    1818AC_DEFINE_UNQUOTED(LIBFAC_VERSION,"$libfac_version")
    1919AC_SUBST(libfac_version)
    20 libfac_date="\"March 2011\""
     20libfac_date="\"July 2012\""
    2121AC_DEFINE_UNQUOTED(LIBFAC_DATE,$libfac_date)
    2222AC_SUBST(libfac_date)
  • factory/libfac/factor/Factor.cc

    r4093f9 rb86107  
    2727
    2828#include "alg_factor.h"
    29 void out_cf(char *s1,const CanonicalForm &f,char *s2);
     29void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
    3030void out_cff(CFFList &L);
    3131
     
    5252* ( in factorize, alpha.level() must be < 0 )
    5353*/
     54static
    5455CFFList factorize2 ( const CanonicalForm & f,
    5556                     const Variable & alpha, const CanonicalForm & mipo )
     
    6162  else
    6263  {
    63     bool repl=(f.mvar() != alpha);
    6464    //out_cf("f2 - factor:",f,"\n");
    6565    //out_cf("f2 - ext:",alpha,"\n");
     
    6767    Variable X=rootOf(mipo);
    6868    CanonicalForm F=f;
    69     if (repl) F=replacevar(f,alpha,X);
     69    F=replacevar(f,alpha,X);
    7070    //out_cf("call - factor:",F,"\n");
    7171    //out_cf("call - ext:",X,"\n");
     
    7373    CFFList L=factorize(F,X);
    7474    CFFListIterator i=L;
    75     if (repl)
    7675    {
    7776      CFFList Outputlist;
     
    8281        i.getItem().exp()));
    8382      }
     83      //out_cff(Outputlist);
    8484      return Outputlist;
    8585    }
    86     else return L;
    8786  }
    8887}
     
    393392generate_mipo( int degree_of_Extension , const Variable & Extension ){
    394393  FFRandom gen;
    395   if ( degree(Extension) > 0 ) GFRandom gen;
    396   else {
    397     if ( degree(Extension) == 0 ) FFRandom gen;
    398     else
    399     {
    400       factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
    401     }
    402   }
     394  if (degree (Extension) < 0)
     395    factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
    403396  return find_irreducible( degree_of_Extension, gen, Variable(1) );
    404397}
     
    465458
    466459static int
    467 specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j){
     460specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j)
     461{
    468462  Variable minpoly= Extension;
    469463  int ok,extended= degree(Extension), working_over_extension;
     
    474468  // First try:
    475469  ok = try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
    476   while ( ! ok ){ // we have to extend!
     470  while ( ! ok ) // we have to extend!
     471  {
     472    SFormList origS=Substitutionlist;
    477473    extended+= 1;
    478     if ( ! working_over_extension ){
    479       minpoly= rootOf(generate_mipo( extended,Extension ));
     474    if ( ! working_over_extension )
     475    {
     476      if (!hasMipo(Extension))
     477        minpoly= rootOf (generate_mipo (extended, Extension));
     478      else
     479      {
     480        setReduce (Extension, false);
     481        setMipo (minpoly, generate_mipo ( extended, Extension));
     482        setReduce (Extension, true);
     483      }
    480484      Extension= minpoly;
    481485      ok= try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
     486      if (!ok)
     487        Substitutionlist=origS;
    482488    }
    483489    else
     
    804810{
    805811  //out_cf("Factorize ",F,"\n");
    806   CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2;
    807   ListIterator<CFFactor> i,j;
    808   CanonicalForm g=1,unit=1,r=1;
    809   Variable minpoly; // dummy
    810   int exp;
    811   CFMap m;
     812  CFFList Outputlist;
    812813
    813814  // INTERRUPTHANDLER
     
    831832    return Outputlist;
    832833  }
     834  CFFList SqrFreeList,Intermediatelist,Outputlist2;
     835  ListIterator<CFFactor> i,j;
     836  CanonicalForm g=1,unit=1,r=1;
     837  Variable minpoly; // dummy
     838  int exp;
     839  CFMap m;
    833840  TIMING_START(factorize_time);
    834841  // search an "optimal" main variavble
  • factory/variable.cc

    r4093f9 rb86107  
    215215}
    216216
    217 /*void setMipo ( const Variable & alpha, const CanonicalForm & mipo)
     217void setMipo ( const Variable & alpha, const CanonicalForm & mipo)
    218218{
    219219    ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
    220220    algextensions[-alpha.level()]= ext_entry((InternalPoly*)(conv2mipo( mipo, alpha ).getval()), true );
    221 }*/
     221}
    222222
    223223bool hasMipo( const Variable & alpha )
    224224{
    225     ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
    226     return ((algextensions!=NULL) && getReduce(alpha) );
     225    ASSERT( alpha.level() < 0, "illegal extension" );
     226    return (alpha.level() != LEVELBASE && (algextensions!=NULL) && getReduce(alpha) );
    227227}
    228228
  • factory/variable.h

    r4093f9 rb86107  
    7878inline char name( const Variable & v ) { return v.name(); }
    7979
     80void setReduce( const Variable & alpha, bool reduce );
     81void setMipo ( const Variable & alpha, const CanonicalForm & mipo);
    8082CanonicalForm getMipo( const Variable & alpha, const Variable & x );
    8183bool hasMipo( const Variable & alpha );
     
    9395InternalPoly * getInternalMipo ( const Variable & alpha );
    9496bool getReduce( const Variable & alpha );
    95 void setReduce( const Variable & alpha, bool reduce );
    9697
    9798#endif /* ! INCL_VARIABLE_H */
Note: See TracChangeset for help on using the changeset viewer.