Changeset a38d45 in git for libfac


Ignore:
Timestamp:
Oct 25, 2007, 4:45:41 PM (16 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
e520c56ea1ed45204b85b9d87163d60d99556985
Parents:
4a4d6fc2217aa5457f704ed86513b02ed28c11f2
Message:
*hannes: homgfactor for alg.ext of Q


git-svn-id: file:///usr/local/Singular/svn/trunk@10344 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
libfac/factor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libfac/factor/Factor.cc

    r4a4d6fc ra38d45  
    11/* Copyright 1996 Michael Messollen. All rights reserved. */
    22///////////////////////////////////////////////////////////////////////////////
    3 static char * rcsid = "$Id: Factor.cc,v 1.36 2007-10-15 18:03:11 Singular Exp $ ";
     3static char * rcsid = "$Id: Factor.cc,v 1.37 2007-10-25 14:45:41 Singular Exp $ ";
    44static char * errmsg = "\nYou found a bug!\nPlease inform (Michael Messollen) michael@math.uni-sb.de \nPlease include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
    55///////////////////////////////////////////////////////////////////////////////
     
    2929
    3030#include "alg_factor.h"
     31void out_cf(char *s1,const CanonicalForm &f,char *s2);
     32void out_cff(CFFList &L);
     33
    3134
    3235#ifdef SINGULAR
     
    5356TIMING_DEFINE_PRINT(hensel_time);
    5457TIMING_DEFINE_PRINT(truefactor_time);
    55 
    56 void out_cf(char *s1,const CanonicalForm &f,char *s2);
    5758
    5859/*
     
    11231124Factorize(const CanonicalForm & F, const CanonicalForm & minpoly, int is_SqrFree )
    11241125{
     1126  //out_cf("Factorize: F=",F,"\n");
     1127  //out_cf("           minpoly:",minpoly,"\n");
    11251128  CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2;
    11261129  ListIterator<CFFactor> i,j;
     
    11471150    if (minpoly!=0)
    11481151    {
    1149       CFList as(minpoly);
    1150       CFFList sqF=sqrFree(F); // sqrFreeZ
    1151       CFFList G,H;
    1152       CanonicalForm fac;
    1153       int d;
    1154       ListIterator<CFFactor> i,k;
    1155       for ( i = sqF; i.hasItem(); ++i )
     1152      if ( F.isHomogeneous() )
    11561153      {
    1157         d = i.getItem().exp();
    1158         fac = i.getItem().factor();
    1159         G = newfactoras( fac, as, 1);
    1160         for ( k = G; k.hasItem(); ++k )
     1154        DEBOUTLN(CERR, "Poly is homogeneous! : ", F);
     1155        // Now we can substitute one variable to 1, factorize and then
     1156        // look on the resulting factors and their monomials for
     1157        // backsubstitution of the substituted variable.
     1158        Outputlist=HomogFactor(F, minpoly, 0);
     1159      }
     1160      else
     1161      {
     1162        CFList as(minpoly);
     1163        CFFList sqF=sqrFree(F); // sqrFreeZ
     1164        CFFList G,H;
     1165        CanonicalForm fac;
     1166        int d;
     1167        ListIterator<CFFactor> i,k;
     1168        for ( i = sqF; i.hasItem(); ++i )
    11611169        {
    1162           fac = k.getItem().factor();
    1163           int dd = k.getItem().exp();
    1164           H.append( CFFactor( fac , d*dd ) );
     1170          d = i.getItem().exp();
     1171          fac = i.getItem().factor();
     1172          G = newfactoras( fac, as, 1);
     1173          for ( k = G; k.hasItem(); ++k )
     1174          {
     1175            fac = k.getItem().factor();
     1176            int dd = k.getItem().exp();
     1177            H.append( CFFactor( fac , d*dd ) );
     1178          }
    11651179        }
    1166       }
    1167       //Outputlist = newfactoras( F, as, 1);
    1168       Outputlist = H;
     1180        //Outputlist = newfactoras( F, as, 1);
     1181        Outputlist = H;
     1182      }
    11691183    }
    11701184    else
     
    11781192    DEBDECLEVEL(CERR, "Factorize");
    11791193    TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
     1194    //out_cff(Outputlist);
    11801195    return Outputlist;
    11811196  }
     
    12971312  if(isOn(SW_USE_NTL_SORT)) Outputlist2.sort(cmpCF);
    12981313
     1314  //out_cff(Outputlist2);
    12991315  return Outputlist2;
    13001316}
     
    13021318/*
    13031319$Log: not supported by cvs2svn $
     1320Revision 1.36  2007/10/15 18:03:11  Singular
     1321*hannes: // debug stuff
     1322
    13041323Revision 1.35  2007/06/14 14:16:35  Singular
    13051324*hannes: Factorize2 etc.
  • libfac/factor/homogfactor.cc

    r4a4d6fc ra38d45  
    11/* Copyright 1997 Michael Messollen. All rights reserved. */
    22////////////////////////////////////////////////////////////
    3 // static char * rcsid = "$Id: homogfactor.cc,v 1.7 2006-05-16 14:46:50 Singular Exp $ ";
     3// static char * rcsid = "$Id: homogfactor.cc,v 1.8 2007-10-25 14:45:41 Singular Exp $ ";
    44////////////////////////////////////////////////////////////
    55// FACTORY - Includes
     
    2525#include "homogfactor.h"
    2626
     27void out_cf(char *s1,const CanonicalForm &f,char *s2);
     28
     29CFFList Factorize2(CanonicalForm F, const CanonicalForm & minpoly );
     30
    2731#ifdef HFACTORDEBUG
    2832#  define DEBUGOUTPUT
     
    134138// we assume g is square-free
    135139CFFList
    136 HomogFactor( const CanonicalForm & g, const CanonicalForm  & minpoly, const int Mainvar ){
     140HomogFactor( const CanonicalForm & g, const CanonicalForm  & minpoly, const int Mainvar )
     141{
    137142  DEBINCLEVEL(CERR, "HomogFactor");
    138143  Variable xn = get_max_degree_Variable(g);
    139144  int d_xn = degree(g,xn);
    140   CFMap n;
    141   CanonicalForm F = compress(g(1,xn),n); // must compress F!
     145  CanonicalForm F = g(1,xn);
    142146
    143147  DEBOUTLN(CERR, "xn= ", xn);
     
    148152  //
    149153  CFFList Intermediatelist;
    150   if ( getCharacteristic() > 0 )
    151      Intermediatelist = Factorized(F, minpoly, Mainvar);
    152   else
    153      Intermediatelist = factorize(F); // what support for char==0 ?
    154154  CFFList Homoglist;
    155155  CFFListIterator j;
    156   for ( j=Intermediatelist; j.hasItem(); j++ )
    157     Homoglist.append(CFFactor( n(j.getItem().factor()), j.getItem().exp()) );
     156  if ( getCharacteristic() > 0 )
     157  {
     158     CFMap n;
     159     Intermediatelist = Factorized(compress(F,n), minpoly, Mainvar);
     160     for ( j=Intermediatelist; j.hasItem(); j++ )
     161       Homoglist.append(CFFactor( n(j.getItem().factor()), j.getItem().exp()) );
     162  }
     163  else
     164     Homoglist = Factorize2(F, minpoly);
    158165  // Now we have uncompressed factors in Homoglist
    159166  DEBOUTLN(CERR, "F factors as: ", Homoglist);
    160167  CFFList Unhomoglist;
    161168  CanonicalForm unhomogelem;
    162   for ( j=Homoglist; j.hasItem(); j++ ){
    163     DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor());
    164     unhomogelem= homogenize(j.getItem().factor(),xn);
    165     DEBOUTLN(CERR, "      that is ", unhomogelem);
    166     Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp()));
    167     d_xn -= degree(unhomogelem,xn)*j.getItem().exp();
     169  if ((!minpoly.isZero()) &&(getCharacteristic() == 0) )
     170  {
     171    for ( j=Homoglist; j.hasItem(); j++ )
     172    {
     173      // assume that minpoly.level() < level of all "real" variables of g
     174      DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor());
     175      unhomogelem= homogenize(j.getItem().factor(),xn,
     176                         Variable(minpoly.level()+1),g.mvar());
     177      DEBOUTLN(CERR, "      that is ", unhomogelem);
     178      Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp()));
     179      d_xn -= degree(unhomogelem,xn)*j.getItem().exp();
     180    }
     181  }
     182  else
     183  {
     184    for ( j=Homoglist; j.hasItem(); j++ )
     185    {
     186      DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor());
     187      unhomogelem= homogenize(j.getItem().factor(),xn);
     188      DEBOUTLN(CERR, "      that is ", unhomogelem);
     189      Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp()));
     190      d_xn -= degree(unhomogelem,xn)*j.getItem().exp();
     191    }
    168192  }
    169193  DEBOUTLN(CERR, "Power of xn to append is ", d_xn);
     
    177201/*
    178202$Log: not supported by cvs2svn $
     203Revision 1.7  2006/05/16 14:46:50  Singular
     204*hannes: gcc 4.1 fixes
     205
    179206Revision 1.6  2005/12/09 08:36:11  Singular
    180207*hannes: stuff for homog. polys ->factory
Note: See TracChangeset for help on using the changeset viewer.