Changeset abb4787 in git


Ignore:
Timestamp:
May 9, 2011, 2:14:51 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
Children:
1983c3c1dac2d11f62464244e646a4296f558e7d
Parents:
0fb5991156fcc44bac3d225d54843f284bc9ac3f
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-05-09 14:14:51+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:31:39+01:00
Message:
conversion factory <->singular for poly
fix coeff tests for factory
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • factory/GNUmakefile.in

    r0fb5991 rabb4787  
    187187                gfops.cc \
    188188                imm.cc \
    189                 initgmp.cc \
    190189                int_cf.cc \
    191190                int_int.cc \
     
    303302# memory manager source files
    304303basememmansrc := \
     304                initgmp.cc \
    305305                newdelete.cc
    306306newmemmansrc := \
     
    493493all:            $(alltargets)
    494494
    495 cf:             factoryconf.h factory.h $(libfactory) libsingcf_g.a
     495cf:             factoryconf.h factory.h  libsingcf.a libsingcf_g.a
    496496
    497497mem:            libcfmem.a
     
    500500# - explicit targets.
    501501#
    502 $(libfactory):  $(factoryobj)
     502libsingcf.a:    $(factoryobj)
    503503                $(AR) $(ARFLAGS) $@ $^
    504504                $(RANLIB) $@
     
    732732#
    733733clean:          ftestclean
    734                 -rm -f $(libfactory) libcfmem.a libsingcf_g.a libsingcf_p.a \
     734                -rm -f libsingcf.a libcfmem.a libsingcf_g.a libsingcf_p.a \
    735735                  $(ftestexec) gengftables test_install \
    736736                  factoryconf.h factory.h *.o *.og *.op *.d *.dtmp
  • factory/factory.template

    r0fb5991 rabb4787  
    3636#endif /* ! NOSTREAMIO */
    3737
    38 #ifdef SINGULAR
    3938#  include <factory/cf_gmp.h>
    40 #else
    41 #  include <gmp.h>
    42 #endif /* SINGULAR */
    4339
    4440#include <factory/templates/ftmpl_array.h>
  • libpolys/coeffs/Makefile.am

    r0fb5991 rabb4787  
    3939
    4040## for testing...
    41 AM_LDFLAGS      = -L${top_builddir}/coeffs -L${top_builddir}/reporter -L${top_builddir}/resources -L${top_builddir}/misc -L${top_builddir}/../omalloc
     41AM_LDFLAGS      = -L${top_builddir}/coeffs -L${top_builddir}/reporter -L${top_builddir}/resources -L${top_builddir}/misc -L${top_builddir}/../factory -L${top_builddir}/../omalloc
    4242
    4343check_PROGRAMS = test test-g
     
    4646test_g_SOURCES = test.cc
    4747
    48 test_LDADD   = -lcoeffs ${GMP_LIBS} -lresources -lreporter -lmisc -lomalloc
    49 test_g_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -lomalloc_debug
     48test_LDADD   = -lcoeffs ${GMP_LIBS} -lresources -lreporter -lmisc -lsingcf -lomalloc
     49test_g_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -lsingcf_g -lomalloc_debug
    5050
    5151
     
    5454test_g_CFLAGS = ${PIPE}
    5555
    56 test_CXXFLAGS   = -O3 -fomit-frame-pointer --no-rtti ${PIPE} ${CXXTEMPLFLAGS}
     56test_CXXFLAGS   = -O3 -fomit-frame-pointer --no-rtti ${PIPE} ${CXXTEMPLFLAGS} -fimplicit-templates
    5757test_g_CXXFLAGS = -g -Wextra -Wall -pedantic -Wno-long-long ${PIPE} ${CXXTEMPLFLAGS}
    5858# -fdiagnostics-show-option
  • libpolys/coeffs/coeffs.h

    r0fb5991 rabb4787  
    157157#ifdef HAVE_FACTORY
    158158   number (*convFactoryNSingN)( const CanonicalForm n, const coeffs r);
    159    CanonicalForm (*convSingNFactoryN)( number n, const coeffs r );
     159   CanonicalForm (*convSingNFactoryN)( number n, BOOLEAN setChar, const coeffs r );
    160160#endif
    161161
  • libpolys/coeffs/longrat.cc

    r0fb5991 rabb4787  
    268268
    269269#ifdef HAVE_FACTORY
    270 CanonicalForm nlConvSingNFactoryN( number n, const coeffs r )
    271 {
     270CanonicalForm nlConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
     271{
     272  if (setChar) setCharacteristic( 0 );
     273
    272274  CanonicalForm term;
    273275  if ( SR_HDL(n) & SR_INT )
  • libpolys/coeffs/modulop.cc

    r0fb5991 rabb4787  
    322322}
    323323#ifdef HAVE_FACTORY
    324 CanonicalForm npConvSingNFactoryN( number n, const coeffs r )
    325 {
     324CanonicalForm npConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
     325{
     326  if (setChar) setCharacteristic( r->npPrimeM );
    326327  CanonicalForm term(npInt( n,r ));
    327328  return term;
  • libpolys/coeffs/numbers.cc

    r0fb5991 rabb4787  
    121121
    122122#ifdef HAVE_FACTORY
    123 CanonicalForm npConvSingNFactoryN( number n, const coeffs r )
     123CanonicalForm ndConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
    124124{
    125125  CanonicalForm term(0);
     
    128128}
    129129
    130 number npConvFactoryNSingN( const CanonicalForm n, const coeffs r)
     130number ndConvFactoryNSingN( const CanonicalForm n, const coeffs r)
    131131{
    132132  Werror("no conversion from factory");
  • libpolys/coeffs/test.cc

    r0fb5991 rabb4787  
    1717#include <coeffs/rmodulo2m.h>
    1818#include <coeffs/rintegers.h>
     19#ifdef HAVE_FACTORY
     20#include <factory/factory.h>
     21#endif
    1922
    2023#include <iostream>
     
    2225using namespace std;
    2326
     27// template stuff
     28#ifdef HAVE_FACTORY
     29  #include <factory/templates/ftmpl_list.cc>
     30  #include <factory/templates/ftmpl_array.cc>
     31  #include <factory/templates/ftmpl_factor.cc>
     32  #include <factory/templates/ftmpl_functions.h>
     33  #include <factory/templates/ftmpl_matrix.cc>
     34  template class Factor<CanonicalForm>;
     35  template class List<CFFactor>;
     36  template class ListItem<CFFactor>;
     37  template class ListItem<CanonicalForm>;
     38  template class ListIterator<CFFactor>;
     39  template class List<CanonicalForm>;
     40  template class List<List<CanonicalForm> >;
     41  template class ListIterator<CanonicalForm>;
     42  template class Array<CanonicalForm>;
     43  template class List<MapPair>;
     44  template class ListItem<MapPair>;
     45  template class ListIterator<MapPair>;
     46  template class Matrix<CanonicalForm>;
     47  template class SubMatrix<CanonicalForm>;
     48  template class Array<REvaluation>;
     49  template bool find ( const List<CanonicalForm> &, const CanonicalForm&);
     50  template List<CFFactor> Union ( const List<CFFactor>&, const List<CFFactor>& );
     51  template int operator == ( const Factor<CanonicalForm>&, const Factor<CanonicalForm>& );
     52
     53  template CanonicalForm tmax ( const CanonicalForm&, const CanonicalForm& );
     54  template CanonicalForm tmin ( const CanonicalForm&, const CanonicalForm& );
     55
     56  template Variable tmax ( const Variable&, const Variable& );
     57  template Variable tmin ( const Variable&, const Variable& );
     58
     59  template int tmax ( const int&, const int& );
     60  template int tmin ( const int&, const int& );
     61  template int tabs ( const int& );
     62
     63  int initializeGMP()
     64  { return 1; }
     65#endif
    2466
    2567#pragma GCC diagnostic ignored "-Wwrite-strings"
  • libpolys/polys/Makefile.am

    r0fb5991 rabb4787  
    3838        kbuckets.cc sbuckets.cc weight.cc weight0.c simpleideals.cc matpol.cc \
    3939        ${USE_P_PROCS_STATIC_CC} ${USE_P_PROCS_DYNAMIC_CC} templates/mod_raw.cc \
    40         clapsing.cc ext_fields/algext.cc
     40        ext_fields/algext.cc clapsing.cc clapconv.cc
    4141
    4242BUILT_SOURCES = templates/p_Procs.inc
     
    5353        monomials/p_polys.h monomials/polys-impl.h monomials/maps.h polys.h prCopy.h prCopyMacros.h \
    5454        kbuckets.h sbuckets.h simpleideals.h weight.h matpol.h \
    55         clapsing.h ext_fields/algext.h
     55        ext_fields/algext.h clapsing.h clapconv.h
    5656
    5757P_PROCS_CPPFLAGS_COMMON = -DHAVE_CONFIG_H -DDYNAMIC_VERSION
  • libpolys/polys/clapconv.cc

    r0fb5991 rabb4787  
    99
    1010
    11 #include <kernel/mod2.h>
     11#include <misc/auxiliary.h>
    1212#ifdef HAVE_FACTORY
    1313#include <omalloc/omalloc.h>
    14 #include <kernel/structs.h>
    1514#define SI_DONT_HAVE_GLOBAL_VARS
    16 #include <kernel/clapconv.h>
    17 #include <kernel/numbers.h>
    18 #include <kernel/modulop.h>
    19 #include <kernel/longalg.h>
    20 #include <kernel/longtrans.h>
    21 #include <kernel/polys.h>
    22 #include <kernel/febase.h>
    23 #include <kernel/ring.h>
    24 #include <kernel/sbuckets.h>
    25 #include <kernel/ffields.h>
    26 
    27 typedef __mpz_struct lint;
     15#include <coeffs/coeffs.h>
     16#include <polys/monomials/p_polys.h>
     17#include <polys/sbuckets.h>
     18#include <polys/clapconv.h>
     19
     20//typedef __mpz_struct lint;
    2821
    2922void out_cf(char *s1,const CanonicalForm &f,char *s2);
     
    3932poly convFactoryPSingP ( const CanonicalForm & f, const ring r )
    4033{
    41 //    cerr << " f = " << f << endl;
    4234  int n = rVar(r)+1;
    4335  /* ASSERT( level( f ) <= pVariables, "illegal number of variables" ); */
     
    7163    for ( int i = 1; i <= r->N; i++ )
    7264      p_SetExp( term, i, exp[i], r);
    73     //if (rRing_has_Comp(r)) p_SetComp(term, 0, r); // done by p_Init
    74     if ( f.isImm() )
    75       pGetCoeff( term ) = n_Init( f.intval(), r );
    76     else
    77     {
    78       number z=ALLOC_RNUMBER();
    79 #if defined(LDEBUG)
    80       z->debug=123456;
    81 #endif
    82       gmp_numerator( f, z->z );
    83       if ( f.den().isOne() )
    84         z->s = 3;
    85       else
    86       {
    87         gmp_denominator( f, z->n );
    88         z->s = 0;
    89         nlNormalize(z);
    90       }
    91       pGetCoeff( term ) = z;
    92     }
     65    pGetCoeff( term )=r->cf->convFactoryNSingN(f, r->cf);
    9366    p_Setm( term, r );
    94     if ( n_IsZero(pGetCoeff(term), r) )
     67    if ( n_IsZero(pGetCoeff(term), r->cf) )
    9568    {
    9669      p_Delete(&term,r);
     
    10881  CanonicalForm result = 0;
    10982  int e, n = rVar(r);
    110 
    111   while ( p!=NULL)
     83  BOOLEAN setChar=TRUE;
     84
     85  while ( p!=NULL )
    11286  {
    11387    CanonicalForm term;
    114     /* does only work for finite fields */
    115     if ( rField_is_Zp(r) )
    116     {
    117       term = npInt( pGetCoeff( p ),r );
    118     }
    119     else if (rField_is_Q(r))
    120     {
    121       if ( SR_HDL(pGetCoeff( p )) & SR_INT )
    122         term = SR_TO_INT( pGetCoeff( p ) );
    123       else
    124       {
    125         if ( pGetCoeff( p )->s == 3 )
    126         {
    127           lint dummy;
    128           mpz_init_set( &dummy, (pGetCoeff( p )->z) );
    129           term = make_cf( dummy );
    130         }
    131         else
    132         {
    133           // assume s==0 or s==1
    134           lint num, den;
    135           On(SW_RATIONAL);
    136           mpz_init_set( &num, (pGetCoeff( p )->z) );
    137           mpz_init_set( &den, (pGetCoeff( p )->n) );
    138           term = make_cf( num, den, ( pGetCoeff( p )->s != 1 ));
    139         }
    140       }
    141     }
    142     else
    143     {
    144       WerrorS("conversion error");
    145       return result;
    146     }
     88    term=r->cf->convSingNFactoryN(pGetCoeff( p ),setChar, r->cf);
     89    if (errorreported) break;
     90    setChar=FALSE;
    14791    for ( int i = n; i >0; i-- )
    14892    {
     
    156100}
    157101
     102int convFactoryISingI( const CanonicalForm & f)
     103{
     104  if (!f.isImm()) WerrorS("int overflow in det");
     105  return f.intval();
     106}
     107#if 0
    158108CanonicalForm convSingAPFactoryAP ( poly p , const Variable & a, const ring r)
    159109{
     
    211161  else
    212162  {
    213     napoly z=(napoly)convFactoryASingA( f,r );
     163    poly z=(poly)convFactoryASingA( f,r );
    214164    if (z!=NULL)
    215165    {
     
    240190}
    241191
    242 CanonicalForm convSingAFactoryA ( napoly p , const Variable & a, const ring r )
     192CanonicalForm convSingAFactoryA ( poly p , const Variable & a, const ring r )
    243193{
    244194  CanonicalForm result = 0;
     
    312262}
    313263
    314 napoly convFactoryASingA ( const CanonicalForm & f, const ring r )
     264poly convFactoryASingA ( const CanonicalForm & f, const ring r )
    315265{
    316266  poly a=NULL;
     
    506456}
    507457
    508 int convFactoryISingI( const CanonicalForm & f)
    509 {
    510   if (!f.isImm()) WerrorS("int overflow in det");
    511   return f.intval();
    512 }
    513458#endif
     459#endif
  • libpolys/polys/clapconv.h

    r0fb5991 rabb4787  
    1212#define INCL_SINGCONV_H
    1313
    14 //#include <kernel/structs.h>
     14#include <polys/monomials/ring.h>
    1515#include <polys/ext_fields/longtrans.h>
    16 #include <polys/monomials/ring.h>
    1716#ifdef HAVE_FACTORY
    1817#  include <factory/factory.h>
     
    2120poly convFactoryPSingP ( const CanonicalForm & f, const ring r );
    2221CanonicalForm convSingPFactoryP( poly p, const ring r );
     22//CanonicalForm convSingIFactoryI( int i);// by constructor of CanonicalForm
     23int convFactoryISingI( const CanonicalForm & f);
    2324
    24 CanonicalForm convSingAPFactoryAP ( poly p , const Variable & a, const ring r );
    25 poly convFactoryAPSingAP ( const CanonicalForm & f, const ring r );
    26 poly convFactoryAPSingAP_R ( const CanonicalForm & f, int par_start, int var_start );
     25//CanonicalForm convSingAPFactoryAP ( poly p , const Variable & a, const ring r );
     26//poly convFactoryAPSingAP ( const CanonicalForm & f, const ring r );
     27//poly convFactoryAPSingAP_R ( const CanonicalForm & f, int par_start, int var_start );
    2728
    28 CanonicalForm convSingGFFactoryGF ( poly p, const ring r );
    29 poly convFactoryGFSingGF ( const CanonicalForm & f, const ring r );
     29//CanonicalForm convSingGFFactoryGF ( poly p, const ring r );
     30//poly convFactoryGFSingGF ( const CanonicalForm & f, const ring r );
    3031
    31 CanonicalForm convSingAFactoryA ( number p , const Variable & a, const ring r );
    32 number convFactoryASingA ( const CanonicalForm & f, const ring r );
     32//CanonicalForm convSingAFactoryA ( number p , const Variable & a, const ring r );
     33//number convFactoryASingA ( const CanonicalForm & f, const ring r );
    3334
    34 CanonicalForm convSingTrPFactoryP ( poly p, const ring r );
    35 poly convFactoryPSingTrP ( const CanonicalForm & f, const ring r );
     35//CanonicalForm convSingTrPFactoryP ( poly p, const ring r );
     36//poly convFactoryPSingTrP ( const CanonicalForm & f, const ring r );
    3637
    37 // CanonicalForm convSingIFactoryI( int i);a <- by constructor of CanonicalForm
    38 int convFactoryISingI( const CanonicalForm & f);
    3938#endif /* INCL_SINGCONV_H */
  • libpolys/polys/clapsing.cc

    r0fb5991 rabb4787  
    3434void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
    3535
    36 poly singclap_gcd_r ( poly f, poly g, const ring r )
    37 {
    38   // assume p_Cleardenom is done
    39   // assume f!=0, g!=0
     36static poly singclap_gcd_r ( poly f, poly g, const ring r )
     37{
    4038  poly res=NULL;
    4139
     
    5250  }
    5351
    54   // for now there is only the possibility to handle polynomials over
    55   // Q and Fp ...
    5652  Off(SW_RATIONAL);
    57   if (rField_is_Q(r) || (rField_is_Zp(r)))
    58   {
    59     setCharacteristic( rChar(r) );
    60     CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g, r ) );
    61     res=convFactoryPSingP( gcd( F, G ) , r);
    62   }
    63   // and over Q(a) / Fp(a)
    64   else if ( rField_is_Extension(r))
    65   {
    66     if ( rField_is_Q_a(r)) setCharacteristic( 0 );
    67     else                   setCharacteristic( -rChar(r) );
    68     if (r->cf->algring->minideal!=NULL)
    69     {
    70       bool b1=isOn(SW_USE_QGCD);
    71       bool b2=isOn(SW_USE_fieldGCD);
    72       if ( rField_is_Q_a(r) ) On(SW_USE_QGCD);
    73       else                   On(SW_USE_fieldGCD);
    74       CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    75                                            r->cf->algring);
    76       Variable a=rootOf(mipo);
    77       CanonicalForm F( convSingAPFactoryAP( f,a,r ) ),
    78                     G( convSingAPFactoryAP( g,a,r ) );
    79       res= convFactoryAPSingAP( gcd( F, G ),r );
    80       if (!b1) Off(SW_USE_QGCD);
    81       if (!b2) Off(SW_USE_fieldGCD);
    82     }
    83     else
    84     {
    85       CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) );
    86       res= convFactoryPSingTrP( gcd( F, G ),r );
    87     }
    88   }
    89   #if 0
    90   else if (( n_GetChar(r)>1 )&&(r->parameter!=NULL)) /* GF(q) */
    91   {
    92     int p=rChar(r);
    93     int n=2;
    94     int t=p*p;
    95     while (t!=n_Char(r)) { t*=p;n++; }
    96     setCharacteristic(p,n,'a');
    97     CanonicalForm F( convSingGFFactoryGF( f,r ) ), G( convSingGFFactoryGF( g,r ) );
    98     res= convFactoryGFSingGF( gcd( F, G ),r );
    99   }
    100   #endif
    101   else
    102     WerrorS( feNotImplemented );
    103 
     53  CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g, r ) );
     54  bool b1=isOn(SW_USE_QGCD);
     55  bool b2=isOn(SW_USE_fieldGCD);
     56  if ( rField_is_Q_a(r) ) On(SW_USE_QGCD);
     57  else                   On(SW_USE_fieldGCD);
     58  res=convFactoryPSingP( gcd( F, G ) , r);
     59  if (!b1) Off(SW_USE_QGCD);
     60  if (!b2) Off(SW_USE_fieldGCD);
    10461  Off(SW_RATIONAL);
    10562  return res;
     
    147104  if ((f==NULL) || (g==NULL))
    148105    goto resultant_returns_res;
    149   // for now there is only the possibility to handle polynomials over
    150   // Q and Fp ...
    151   if (rField_is_Zp(r) || rField_is_Q(r))
    152   {
    153     Variable X(i);
    154     setCharacteristic( rChar(r) );
     106  { 
     107    Variable X(i); // TODO: consider extensions
    155108    CanonicalForm F( convSingPFactoryP( f, r ) ), G( convSingPFactoryP( g, r ) );
    156109    res=convFactoryPSingP( resultant( F, G, X ), r );
    157110    Off(SW_RATIONAL);
    158     goto resultant_returns_res;
    159   }
    160   // and over Q(a) / Fp(a)
    161   else if (rField_is_Extension(r))
    162   {
    163     if (rField_is_Q_a(r)) setCharacteristic( 0 );
    164     else               setCharacteristic( - rChar(r) );
    165     Variable X(i+rPar(r));
    166     if (r->cf->algring->minideal!=NULL)
    167     {
    168       //Variable X(i);
    169       CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    170                                            r->cf->algring);
    171       Variable a=rootOf(mipo);
    172       CanonicalForm F( convSingAPFactoryAP( f,a,r ) ),
    173                     G( convSingAPFactoryAP( g,a,r ) );
    174       res= convFactoryAPSingAP( resultant( F, G, X ),r );
    175     }
    176     else
    177     {
    178       //Variable X(i+rPar(currRing));
    179       number nf,ng;
    180       p_Cleardenom_n(f, r,nf);p_Cleardenom_n(g, r,ng);
    181       int ef,eg;
    182       ef=pGetExp_Var(f,i,r);
    183       eg=pGetExp_Var(g,i,r);
    184       CanonicalForm F( convSingTrPFactoryP( f, r ) ), G( convSingTrPFactoryP( g, r ) );
    185       res= convFactoryPSingTrP( resultant( F, G, X ), r );
    186       if ((nf!=NULL)&&(!n_IsOne(nf,r->cf))&&(!n_IsZero(nf,r->cf)))
    187       {
    188         number n=n_Invers(nf,r->cf);
    189         while(eg>0)
    190         {
    191           res=p_Mult_nn(res,n,r);
    192           eg--;
    193         }
    194         n_Delete(&n,r->cf);
    195       }
    196       n_Delete(&nf, r->cf);
    197       if ((ng!=NULL)&&(!n_IsOne(ng, r->cf))&&(!n_IsZero(ng,r->cf)))
    198       {
    199         number n=n_Invers(ng,r->cf);
    200         while(ef>0)
    201         {
    202           res=p_Mult_nn(res,n,r);
    203           ef--;
    204         }
    205         n_Delete(&n,r->cf);
    206       }
    207       n_Delete(&ng,r->cf);
    208     }
    209     Off(SW_RATIONAL);
    210     goto resultant_returns_res;
    211   }
    212   else
    213     WerrorS( feNotImplemented );
     111  }
    214112resultant_returns_res:
    215113  p_Delete(&f,r);
     
    285183  res=NULL;pa=NULL;pb=NULL;
    286184  On(SW_SYMMETRIC_FF);
    287   if (rField_is_Zp(r) || rField_is_Q(r))
    288   {
    289     setCharacteristic( rChar(r) );
    290     CanonicalForm F( convSingPFactoryP( f, r ) ), G( convSingPFactoryP( g, r ) );
    291     CanonicalForm FpG=F+G;
    292     if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
    293     //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
    294     {
    295       Off(SW_RATIONAL);
    296       WerrorS("not univariate");
    297       return TRUE;
    298     }
    299     CanonicalForm Fa,Gb;
    300     On(SW_RATIONAL);
    301     res=convFactoryPSingP( extgcd( F, G, Fa, Gb ), r );
    302     pa=convFactoryPSingP(Fa, r);
    303     pb=convFactoryPSingP(Gb, r);
     185  CanonicalForm F( convSingPFactoryP( f, r ) ), G( convSingPFactoryP( g, r ) );
     186  CanonicalForm FpG=F+G;
     187  if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
     188  //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
     189  {
    304190    Off(SW_RATIONAL);
    305   }
    306   // and over Q(a) / Fp(a)
    307   else if (rField_is_Extension(r))
    308   {
    309     if (rField_is_Q_a(r)) setCharacteristic( 0 );
    310     else               setCharacteristic( - rChar(r) );
    311     CanonicalForm Fa,Gb;
    312     if (r->cf->algring->minideal!=NULL)
    313     {
    314       CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    315                                            r->cf->algring);
    316       Variable a=rootOf(mipo);
    317       CanonicalForm F( convSingAPFactoryAP( f,a,r ) ),
    318                     G( convSingAPFactoryAP( g,a,r ) );
    319       CanonicalForm FpG=F+G;
    320       if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
    321       //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
    322       {
    323         WerrorS("not univariate");
    324         return TRUE;
    325       }
    326       res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ),r );
    327       pa=convFactoryAPSingAP(Fa,r);
    328       pb=convFactoryAPSingAP(Gb,r);
    329     }
    330     else
    331     {
    332       CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) );
    333       CanonicalForm FpG=F+G;
    334       if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
    335       //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
    336       {
    337         Off(SW_RATIONAL);
    338         WerrorS("not univariate");
    339         return TRUE;
    340       }
    341       res= convFactoryPSingTrP( extgcd( F, G, Fa, Gb ),r );
    342       pa=convFactoryPSingTrP(Fa,r);
    343       pb=convFactoryPSingTrP(Gb,r);
    344     }
    345     Off(SW_RATIONAL);
    346   }
    347   else
    348   {
    349     WerrorS( feNotImplemented );
     191    WerrorS("not univariate");
    350192    return TRUE;
    351193  }
     194  CanonicalForm Fa,Gb;
     195  On(SW_RATIONAL);
     196  res=convFactoryPSingP( extgcd( F, G, Fa, Gb ), r );
     197  pa=convFactoryPSingP(Fa, r);
     198  pb=convFactoryPSingP(Gb, r);
     199  Off(SW_RATIONAL);
    352200#ifndef NDEBUG
    353201  // checking the result of extgcd:
     
    364212}
    365213
    366 BOOLEAN singclap_extgcd_r ( poly f, poly g, poly &res, poly &pa, poly &pb, const ring r )
    367 {
    368   // for now there is only the possibility to handle univariate
    369   // polynomials over
    370   // Q and Fp ...
    371   res=NULL;pa=NULL;pb=NULL;
    372   On(SW_SYMMETRIC_FF);
    373   if ( rField_is_Q(r) || rField_is_Zp(r) )
    374   {
    375     setCharacteristic( rChar(r) );
    376     CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r) );
    377     CanonicalForm FpG=F+G;
    378     if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
    379     //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
    380     {
    381       Off(SW_RATIONAL);
    382       WerrorS("not univariate");
    383       return TRUE;
    384     }
    385     CanonicalForm Fa,Gb;
    386     On(SW_RATIONAL);
    387     res=convFactoryPSingP( extgcd( F, G, Fa, Gb ),r );
    388     pa=convFactoryPSingP(Fa,r);
    389     pb=convFactoryPSingP(Gb,r);
    390     Off(SW_RATIONAL);
    391   }
    392   // and over Q(a) / Fp(a)
    393   else if ( rField_is_Extension(r))
    394   {
    395     if (rField_is_Q_a(r)) setCharacteristic( 0 );
    396     else                 setCharacteristic( - rChar(r) );
    397     CanonicalForm Fa,Gb;
    398     if (r->cf->algring->minideal!=NULL)
    399     {
    400       CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    401                                            r->cf->algring);
    402       Variable a=rootOf(mipo);
    403       CanonicalForm F( convSingAPFactoryAP( f,a,r ) ),
    404                     G( convSingAPFactoryAP( g,a,r ) );
    405       CanonicalForm FpG=F+G;
    406       if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
    407       //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
    408       {
    409         WerrorS("not univariate");
    410         return TRUE;
    411       }
    412       res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ),r );
    413       pa=convFactoryAPSingAP(Fa,r);
    414       pb=convFactoryAPSingAP(Gb,r);
    415     }
    416     else
    417     {
    418       CanonicalForm F( convSingTrPFactoryP( f, r ) ), G( convSingTrPFactoryP( g, r ) );
    419       CanonicalForm FpG=F+G;
    420       if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
    421       //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
    422       {
    423         Off(SW_RATIONAL);
    424         WerrorS("not univariate");
    425         return TRUE;
    426       }
    427       res= convFactoryPSingTrP( extgcd( F, G, Fa, Gb ), r );
    428       pa=convFactoryPSingTrP(Fa, r);
    429       pb=convFactoryPSingTrP(Gb, r);
    430     }
    431     Off(SW_RATIONAL);
    432   }
    433   else
    434   {
    435     WerrorS( feNotImplemented );
    436     return TRUE;
    437   }
    438   return FALSE;
    439 }
    440 
    441214poly singclap_pdivide ( poly f, poly g, const ring r )
    442215{
    443216  poly res=NULL;
    444217  On(SW_RATIONAL);
    445   if (rField_is_Zp(r) || rField_is_Q(r))
    446   {
    447     setCharacteristic( rChar(r) );
    448     CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r ) );
    449     res = convFactoryPSingP( F / G, r );
    450   }
    451   else if (rField_is_Extension(r))
    452   {
    453     if (rField_is_Q_a(r)) setCharacteristic( 0 );
    454     else               setCharacteristic( - rChar(r) );
    455     if (r->cf->algring->minideal!=NULL)
    456     {
    457       CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    458                                            r->cf->algring);
    459       Variable a=rootOf(mipo);
    460       CanonicalForm F( convSingAPFactoryAP( f,a,r ) ),
    461                     G( convSingAPFactoryAP( g,a,r ) );
    462       res= convFactoryAPSingAP(  F / G,r );
    463     }
    464     else
    465     {
    466       CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) );
    467       res= convFactoryPSingTrP(  F / G,r  );
    468     }
    469   }
    470   #if 0 // not yet working
    471   else if (rField_is_GF())
    472   {
    473     //Print("GF(%d^%d)\n",nfCharP,nfMinPoly[0]);
    474     setCharacteristic( nfCharP,nfMinPoly[0], currRing->parameter[0][0] );
    475     CanonicalForm F( convSingGFFactoryGF( f ) ), G( convSingGFFactoryGF( g ) );
    476     res = convFactoryGFSingGF( F / G );
    477   }
    478   #endif
    479   else
    480     WerrorS( feNotImplemented );
    481   Off(SW_RATIONAL);
    482   return res;
    483 }
    484 
    485 poly singclap_pdivide_r ( poly f, poly g, const ring r )
    486 {
    487   poly res=NULL;
    488   On(SW_RATIONAL);
    489   if (rField_is_Zp(r) || rField_is_Q(r))
    490   {
    491     setCharacteristic( rChar(r) );
    492     CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r ) );
    493     res = convFactoryPSingP( F / G,r );
    494   }
    495   else if (rField_is_Extension(r))
    496   {
    497     if (rField_is_Q_a(r)) setCharacteristic( 0 );
    498     else               setCharacteristic( - rChar(r) );
    499     if (r->cf->algring->minideal!=NULL)
    500     {
    501       CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    502                                            r->cf->algring);
    503       Variable a=rootOf(mipo);
    504       CanonicalForm F( convSingAPFactoryAP( f,a,r ) ),
    505                     G( convSingAPFactoryAP( g,a,r ) );
    506       res= convFactoryAPSingAP(  F / G, r  );
    507     }
    508     else
    509     {
    510       CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) );
    511       res= convFactoryPSingTrP(  F / G,r  );
    512     }
    513   }
    514   #if 0 // not yet working
    515   else if (rField_is_GF())
    516   {
    517     //Print("GF(%d^%d)\n",nfCharP,nfMinPoly[0]);
    518     setCharacteristic( nfCharP,nfMinPoly[0], currRing->parameter[0][0] );
    519     CanonicalForm F( convSingGFFactoryGF( f ) ), G( convSingGFFactoryGF( g ) );
    520     res = convFactoryGFSingGF( F / G );
    521   }
    522   #endif
    523   else
    524     WerrorS( feNotImplemented );
     218  CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r ) );
     219  res = convFactoryPSingP( F / G,r );
    525220  Off(SW_RATIONAL);
    526221  return res;
     
    646341    CanonicalForm F, FAC,Q,R;
    647342    Variable a;
    648     if (rField_is_Zp(r) || rField_is_Q(r))
    649     {
    650       F=convSingPFactoryP( f,r );
    651       FAC=convSingPFactoryP( fac,r );
    652     }
    653     else if (rField_is_Extension(r))
    654     {
    655       if (r->cf->algring->minideal!=NULL)
    656       {
    657         CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    658                                              r->cf->algring);
    659         a=rootOf(mipo);
    660         F=convSingAPFactoryAP( f,a,r );
    661         FAC=convSingAPFactoryAP( fac,a,r );
    662       }
    663       else
    664       {
    665         F=convSingTrPFactoryP( f,r );
    666         FAC=convSingTrPFactoryP( fac,r );
    667       }
    668     }
    669     else
    670       WerrorS( feNotImplemented );
     343    F=convSingPFactoryP( f,r );
     344    FAC=convSingPFactoryP( fac,r );
    671345
    672346    poly q;
     
    680354      if (R.isZero())
    681355      {
    682         if (rField_is_Zp(r) || rField_is_Q(r))
    683         {
    684           q = convFactoryPSingP( Q,r );
    685         }
    686         else if (rField_is_Extension(r))
    687         {
    688           if (r->cf->algring->minideal!=NULL)
    689           {
    690             q= convFactoryAPSingAP(  Q,r  );
    691           }
    692           else
    693           {
    694             q= convFactoryPSingTrP(  Q,r  );
    695           }
    696         }
     356        q = convFactoryPSingP( Q,r );
    697357        e++; p_Delete(&f,r); f=q; q=NULL; F=Q;
    698358      }
     
    845505    L = factorize( F );
    846506  }
    847   #if 0
    848   else if (rField_is_GF())
    849   {
    850     int c=rChar(currRing);
    851     setCharacteristic( c, primepower(c) );
    852     CanonicalForm F( convSingGFFactoryGF( f ) );
    853     if (F.isUnivariate())
    854     {
    855       L = factorize( F );
    856     }
    857     else
    858     {
    859       goto notImpl;
    860     }
    861   }
    862   #endif
    863507  // and over Q(a) / Fp(a)
    864508  else if (rField_is_Extension(r))
    865509  {
    866     if (rField_is_Q_a(r)) setCharacteristic( 0 );
    867     else                 setCharacteristic( -rChar(r) );
    868510    if (r->cf->algring->minideal!=NULL)
    869511    {
     
    871513                                           r->cf->algring);
    872514      Variable a=rootOf(mipo);
    873       CanonicalForm F( convSingAPFactoryAP( f,a,r ) );
     515      CanonicalForm F( convSingPFactoryP( f,r ) );
    874516      if (rField_is_Zp_a(r))
    875517      {
     
    884526    else
    885527    {
    886       CanonicalForm F( convSingTrPFactoryP( f,r ) );
     528      CanonicalForm F( convSingPFactoryP( f,r ) );
    887529      L = factorize( F );
    888530    }
     
    930572        if (r->cf->algring->minideal==NULL)
    931573        {
    932           if(!count_Factors(res,w,j,ff,convFactoryPSingTrP( J.getItem().factor(),r ),r))
     574          if(!count_Factors(res,w,j,ff,convFactoryPSingP( J.getItem().factor(),r ),r))
    933575          {
    934576            if (w!=NULL)
     
    939581        else
    940582        {
    941           if (!count_Factors(res,w,j,ff,convFactoryAPSingAP( J.getItem().factor(),r ),r))
     583          if (!count_Factors(res,w,j,ff,convFactoryPSingP( J.getItem().factor(),r ),r))
    942584          {
    943585            if (w!=NULL)
     
    1187829  }
    1188830  #endif
    1189   // and over Q(a) / Fp(a)
    1190   else if (rField_is_Extension(r))
    1191   {
    1192     if (rField_is_Q_a(r)) setCharacteristic( 0 );
    1193     else                 setCharacteristic( -rChar(r) );
    1194     if (r->cf->algring->minideal!=NULL)
    1195     {
    1196       CanonicalForm mipo=convSingPFactoryP(r->cf->algring->minideal->m[0],
    1197                                            r->cf->algring);
    1198       Variable a=rootOf(mipo);
    1199       CanonicalForm F( convSingAPFactoryAP( f,a,r ) );
    1200       CFFList SqrFreeMV( const CanonicalForm & f , const CanonicalForm & mipo=0) ;
    1201 
    1202       L = SqrFreeMV( F,mipo );
    1203       //WarnS("L = sqrFree( F,mipo );");
    1204       //L = sqrFree( F );
    1205     }
    1206     else
    1207     {
    1208       CanonicalForm F( convSingTrPFactoryP( f,r ) );
    1209       L = sqrFree( F );
    1210     }
    1211   }
    1212831  else
    1213832  {
     
    1223842    for ( ; J.hasItem(); J++, j++ )
    1224843    {
    1225       if (rField_is_Zp(r) || rField_is_Q(r))           /* Q, Fp */
    1226         //count_Factors(res,*v,f, j, convFactoryPSingP( J.getItem().factor() );
    1227         res->m[j] = convFactoryPSingP( J.getItem().factor(),r );
    1228       #if 0
    1229       else if (rField_is_GF())
    1230         res->m[j] = convFactoryGFSingGF( J.getItem().factor() );
    1231       #endif
    1232       else if (rField_is_Extension(r))     /* Q(a), Fp(a) */
    1233       {
    1234         if (r->cf->algring->minideal==NULL)
    1235           res->m[j]=convFactoryPSingTrP( J.getItem().factor(),r );
    1236         else
    1237           res->m[j]=convFactoryAPSingAP( J.getItem().factor(),r );
    1238       }
     844      res->m[j] = convFactoryPSingP( J.getItem().factor(),r );
    1239845    }
    1240846    if (res->m[0]==NULL)
     
    14311037{
    14321038  BOOLEAN b=FALSE;
     1039  CanonicalForm F( convSingPFactoryP( f,r ) );
     1040  if((r->cf->type==n_Zp)&&(!F.isUnivariate()))
     1041      goto err;
     1042  b=(BOOLEAN)isSqrFree(F);
    14331043  Off(SW_RATIONAL);
    1434   //  Q / Fp
    1435   if (((rChar(r) == 0) || (rChar(r) > 1) )
    1436   &&(rPar(r)==0))
    1437   {
    1438     setCharacteristic( rChar(r) );
    1439     CanonicalForm F( convSingPFactoryP( f,r ) );
    1440     if((rChar(r)>1)&&(!F.isUnivariate()))
    1441       goto err;
    1442     b=(BOOLEAN)isSqrFree(F);
    1443   }
    1444   // and over Q(a) / Fp(a)
    1445   else if (( rChar(r)==1 ) /* Q(a) */
    1446   || (rChar(r) <-1))       /* Fp(a) */
    1447   {
    1448     if (rChar(r)==1) setCharacteristic( 0 );
    1449     else               setCharacteristic( -rChar(r) );
    1450     //if (r->minpoly!=NULL)
    1451     //{
    1452     //  CanonicalForm mipo=convSingPFactoryP(((lnumber)r->minpoly)->z,
    1453     //                                             r->algring);
    1454     //  Variable a=rootOf(mipo);
    1455     //  CanonicalForm F( convSingAPFactoryAP( f,a ) );
    1456     //  ...
    1457     //}
    1458     //else
    1459     {
    1460       CanonicalForm F( convSingTrPFactoryP( f,r ) );
    1461       b=(BOOLEAN)isSqrFree(F);
    1462     }
    1463     Off(SW_RATIONAL);
    1464   }
    1465   else
    1466   {
     1044  return b;
    14671045err:
    1468     WerrorS( feNotImplemented );
    1469   }
    1470   return b;
     1046  WerrorS( feNotImplemented );
     1047  return 0;
    14711048}
    14721049
     
    14801057  }
    14811058  poly res=NULL;
    1482   if (( s->cf->ch == 0 || s->cf->ch > 1 )
    1483   && (rPar(s)==0))
    1484   {
    1485     setCharacteristic( s->cf->ch );
    1486     CFMatrix M(r,r);
    1487     int i,j;
    1488     for(i=r;i>0;i--)
    1489     {
    1490       for(j=r;j>0;j--)
    1491       {
    1492         M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s);
    1493       }
    1494     }
    1495     res= convFactoryPSingP( determinant(M,r),s ) ;
    1496   }
    1497   // and over Q(a) / Fp(a)
    1498   else if (( s->cf->ch==1 ) /* Q(a) */
    1499   || (s->cf->ch <-1))       /* Fp(a) */
    1500   {
    1501     if (s->cf->ch==1) setCharacteristic( 0 );
    1502     else               setCharacteristic( -s->cf->ch );
    1503     CFMatrix M(r,r);
    1504     poly res;
    1505     if (rField_is_Extension(s)&& s->cf->algring->minideal!=NULL)
    1506     {
    1507       CanonicalForm mipo=convSingPFactoryP(s->cf->algring->minideal->m[0],
    1508                                            s->cf->algring);
    1509       Variable a=rootOf(mipo);
    1510       int i,j;
    1511       for(i=r;i>0;i--)
    1512       {
    1513         for(j=r;j>0;j--)
    1514         {
    1515           M(i,j)=convSingAPFactoryAP(MATELEM(m,i,j),a,s);
    1516         }
    1517       }
    1518       res= convFactoryAPSingAP( determinant(M,r),s ) ;
    1519     }
    1520     else
    1521     {
    1522       int i,j;
    1523       for(i=r;i>0;i--)
    1524       {
    1525         for(j=r;j>0;j--)
    1526         {
    1527           M(i,j)=convSingTrPFactoryP(MATELEM(m,i,j),s);
    1528         }
    1529       }
    1530       res= convFactoryPSingTrP( determinant(M,r),s );
    1531     }
    1532   }
    1533   else
    1534     WerrorS( feNotImplemented );
     1059  CFMatrix M(r,r);
     1060  int i,j;
     1061  for(i=r;i>0;i--)
     1062  {
     1063    for(j=r;j>0;j--)
     1064    {
     1065      M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s);
     1066    }
     1067  }
     1068  res= convFactoryPSingP( determinant(M,r),s ) ;
    15351069  Off(SW_RATIONAL);
    15361070  return res;
  • libpolys/polys/clapsing.h

    r0fb5991 rabb4787  
    2222
    2323poly singclap_gcd ( poly f, poly g, const ring r );
    24 poly singclap_gcd_r ( poly f, poly g, const ring r );
    2524/*
    2625napoly singclap_alglcm ( napoly f, napoly g );
     
    3130
    3231BOOLEAN singclap_extgcd ( poly f, poly g, poly &res, poly &pa, poly &pb , const ring r);
    33 BOOLEAN singclap_extgcd_r ( poly f, poly g, poly &res, poly &pa, poly &pb, const ring r );
    3432
    3533poly singclap_pdivide ( poly f, poly g, const ring r );
    36 poly singclap_pdivide_r ( poly f, poly g, const ring r );
    3734
    3835void singclap_divide_content ( poly f, const ring r);
  • libpolys/polys/monomials/p_polys.cc

    r0fb5991 rabb4787  
    16731673{
    16741674  number x, y;
    1675   int i;
    16761675
    16771676  y = pGetCoeff(p);
     
    16791678  n_Delete(&y,r->cf);
    16801679  pSetCoeff0(p,x);
    1681   //for (i=pVariables; i!=0; i--)
     1680  //for (int i=pVariables; i!=0; i--)
    16821681  //{
    16831682  //  pAddExp(p,i, pGetExp(q,i));
     
    16941693{
    16951694  number x;
    1696   int i;
    16971695  poly r = p_Init(rr);
    16981696
     
    20232021    if (rField_is_Q_a(r))
    20242022    {
    2025       number hzz = nlInit(1, r->cf);
     2023      //number hzz = nlInit(1, r->cf);
    20262024      h = nlInit(1, r->cf);
    20272025      p=ph;
     
    29932991void p_SetGlobals(const ring r, BOOLEAN complete)
    29942992{
    2995   int i;
    29962993  if (r->ppNoether!=NULL) p_Delete(&r->ppNoether,r);
    29972994
     
    35903587poly p_JetW(poly p, int m, short *w, const ring R)
    35913588{
    3592   poly t=NULL;
    35933589  while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R);
    35943590  if (p==NULL) return NULL;
     
    36923688{
    36933689  number n,nn;
    3694   int i;
    36953690  pAssume(p1 != NULL && p2 != NULL);
    36963691
  • libpolys/tests/Makefile.am

    r0fb5991 rabb4787  
    2727rings_test_LDFLAGS = $(polys_test_LDFLAGS)
    2828
    29 coeffs_test_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -lomalloc_debug
     29coeffs_test_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -llibsingcf_g -lomalloc_debug
    3030polys_test_LDADD = -lpolys_g ${USEPPROCSDYNAMICLD} $(coeffs_test_LDADD)
    3131rings_test_LDADD = $(polys_test_LDADD)
Note: See TracChangeset for help on using the changeset viewer.