Changeset 28ffaa in git


Ignore:
Timestamp:
Aug 22, 2001, 4:20:47 PM (22 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '91fdef05f09f54b8d58d92a472e9c4a43aa4656f')
Children:
b6249e47ee58f2e950b5e85af745e7f054b42516
Parents:
a90dc01e741c2f1ba1d72b616559669433395640
Message:
* hannes: added search for main var to factorize


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

Legend:

Unmodified
Added
Removed
  • factory/cf_factor.cc

    ra90dc0 r28ffaa  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_factor.cc,v 1.10 1998-03-12 10:27:41 schmidt Exp $ */
     2/* $Id: cf_factor.cc,v 1.11 2001-08-22 14:20:47 Singular Exp $ */
    33
    44//{{{ docu
     
    3737}
    3838
     39void find_exp(const CanonicalForm & f, int * exp_f)
     40{
     41  if ( ! f.inCoeffDomain() )
     42  {
     43    int e=f.level();
     44    CFIterator i = f;
     45    if (i.exp() > exp_f[e]) exp_f[e]=i.exp();
     46    for (; i.hasTerms(); i++ )
     47    {
     48      find_exp(i.coeff(), exp_f);
     49    }
     50  }
     51}
     52
     53int find_mvar(const CanonicalForm & f)
     54{
     55  int mv=f.level();
     56  int *exp_f=new int[mv+1];
     57  int i;
     58  for(i=mv;i>0;i--) exp_f[i]=0;
     59  find_exp(f,exp_f);
     60  for(i=mv;i>0;i--)
     61  {
     62    if ((exp_f[i]>0) && (exp_f[i]<exp_f[mv]))
     63    {
     64      mv=i;
     65    }
     66  }
     67  delete[] exp_f;
     68  return mv;
     69}
     70
    3971CFFList factorize ( const CanonicalForm & f, bool issqrfree )
    4072{
    4173    if ( f.inCoeffDomain() )
    42         return CFFList( f );
     74        return CFFList( f );
    4375    if ( getCharacteristic() > 0 ) {
    44         ASSERT( f.isUnivariate(), "multivariate factorization not implemented" );
    45         if ( isOn( SW_BERLEKAMP ) )
    46             return FpFactorizeUnivariateB( f, issqrfree );
    47         else
    48             return FpFactorizeUnivariateCZ( f, issqrfree, 0, Variable(), Variable() );
     76        ASSERT( f.isUnivariate(), "multivariate factorization not implemented" );
     77        if ( isOn( SW_BERLEKAMP ) )
     78            return FpFactorizeUnivariateB( f, issqrfree );
     79        else
     80            return FpFactorizeUnivariateCZ( f, issqrfree, 0, Variable(), Variable() );
    4981    }
    5082    else {
     83        int mv=f.level();
     84        if (! f.isUnivariate() )
     85        {
     86          mv=find_mvar(f);
     87          if (mv!=f.level())
     88          {
     89            swapvar(f,Variable(mv),f.mvar());
     90          }
     91        }
    5192        CanonicalForm cd = bCommonDen( f );
    5293        CanonicalForm fz = f * cd;
     
    5495        bool on_rational = isOn(SW_RATIONAL);
    5596        Off(SW_RATIONAL);
    56         if ( f.isUnivariate() )
    57             F = ZFactorizeUnivariate( fz, issqrfree );
    58         else
    59             F = ZFactorizeMultivariate( fz, issqrfree );
     97        if ( f.isUnivariate() )
     98            F = ZFactorizeUnivariate( fz, issqrfree );
     99        else
     100            F = ZFactorizeMultivariate( fz, issqrfree );
    60101        if ( on_rational )
    61102            On(SW_RATIONAL);
     
    69110                F.insert( CFFactor( 1/cd ) );
    70111            }
     112        }
     113        if ((mv!=f.level()) && (! f.isUnivariate() ))
     114        {
     115          CFFListIterator J=F;
     116          for ( ; J.hasItem(); J++)
     117          {
     118            swapvar(J.getItem().factor(),Variable(mv),f.mvar());
     119          }
     120          swapvar(f,Variable(mv),f.mvar());
    71121        }
    72122        return F;
     
    88138
    89139    if ( getCharacteristic() == 0 )
    90         result = sqrFreeZ( f );
     140        result = sqrFreeZ( f );
    91141    else
    92         result = sqrFreeFp( f );
     142        result = sqrFreeFp( f );
    93143
    94144    return ( sort ? sortCFFList( result ) : result );
     
    99149//    ASSERT( f.isUnivariate(), "multivariate factorization not implemented" );
    100150    if ( getCharacteristic() == 0 )
    101         return isSqrFreeZ( f );
     151        return isSqrFreeZ( f );
    102152    else
    103         return isSqrFreeFp( f );
     153        return isSqrFreeFp( f );
    104154}
Note: See TracChangeset for help on using the changeset viewer.