Changeset abb4787 in git
- Timestamp:
- May 9, 2011, 2:14:51 PM (12 years ago)
- 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
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/GNUmakefile.in
r0fb5991 rabb4787 187 187 gfops.cc \ 188 188 imm.cc \ 189 initgmp.cc \190 189 int_cf.cc \ 191 190 int_int.cc \ … … 303 302 # memory manager source files 304 303 basememmansrc := \ 304 initgmp.cc \ 305 305 newdelete.cc 306 306 newmemmansrc := \ … … 493 493 all: $(alltargets) 494 494 495 cf: factoryconf.h factory.h $(libfactory)libsingcf_g.a495 cf: factoryconf.h factory.h libsingcf.a libsingcf_g.a 496 496 497 497 mem: libcfmem.a … … 500 500 # - explicit targets. 501 501 # 502 $(libfactory): $(factoryobj)502 libsingcf.a: $(factoryobj) 503 503 $(AR) $(ARFLAGS) $@ $^ 504 504 $(RANLIB) $@ … … 732 732 # 733 733 clean: 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 \ 735 735 $(ftestexec) gengftables test_install \ 736 736 factoryconf.h factory.h *.o *.og *.op *.d *.dtmp -
factory/factory.template
r0fb5991 rabb4787 36 36 #endif /* ! NOSTREAMIO */ 37 37 38 #ifdef SINGULAR39 38 # include <factory/cf_gmp.h> 40 #else41 # include <gmp.h>42 #endif /* SINGULAR */43 39 44 40 #include <factory/templates/ftmpl_array.h> -
libpolys/coeffs/Makefile.am
r0fb5991 rabb4787 39 39 40 40 ## for testing... 41 AM_LDFLAGS = -L${top_builddir}/coeffs -L${top_builddir}/reporter -L${top_builddir}/resources -L${top_builddir}/misc -L${top_builddir}/../ omalloc41 AM_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 42 42 43 43 check_PROGRAMS = test test-g … … 46 46 test_g_SOURCES = test.cc 47 47 48 test_LDADD = -lcoeffs ${GMP_LIBS} -lresources -lreporter -lmisc -l omalloc49 test_g_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -l omalloc_debug48 test_LDADD = -lcoeffs ${GMP_LIBS} -lresources -lreporter -lmisc -lsingcf -lomalloc 49 test_g_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -lsingcf_g -lomalloc_debug 50 50 51 51 … … 54 54 test_g_CFLAGS = ${PIPE} 55 55 56 test_CXXFLAGS = -O3 -fomit-frame-pointer --no-rtti ${PIPE} ${CXXTEMPLFLAGS} 56 test_CXXFLAGS = -O3 -fomit-frame-pointer --no-rtti ${PIPE} ${CXXTEMPLFLAGS} -fimplicit-templates 57 57 test_g_CXXFLAGS = -g -Wextra -Wall -pedantic -Wno-long-long ${PIPE} ${CXXTEMPLFLAGS} 58 58 # -fdiagnostics-show-option -
libpolys/coeffs/coeffs.h
r0fb5991 rabb4787 157 157 #ifdef HAVE_FACTORY 158 158 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 ); 160 160 #endif 161 161 -
libpolys/coeffs/longrat.cc
r0fb5991 rabb4787 268 268 269 269 #ifdef HAVE_FACTORY 270 CanonicalForm nlConvSingNFactoryN( number n, const coeffs r ) 271 { 270 CanonicalForm nlConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r ) 271 { 272 if (setChar) setCharacteristic( 0 ); 273 272 274 CanonicalForm term; 273 275 if ( SR_HDL(n) & SR_INT ) -
libpolys/coeffs/modulop.cc
r0fb5991 rabb4787 322 322 } 323 323 #ifdef HAVE_FACTORY 324 CanonicalForm npConvSingNFactoryN( number n, const coeffs r ) 325 { 324 CanonicalForm npConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r ) 325 { 326 if (setChar) setCharacteristic( r->npPrimeM ); 326 327 CanonicalForm term(npInt( n,r )); 327 328 return term; -
libpolys/coeffs/numbers.cc
r0fb5991 rabb4787 121 121 122 122 #ifdef HAVE_FACTORY 123 CanonicalForm n pConvSingNFactoryN( number n, const coeffs r )123 CanonicalForm ndConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r ) 124 124 { 125 125 CanonicalForm term(0); … … 128 128 } 129 129 130 number n pConvFactoryNSingN( const CanonicalForm n, const coeffs r)130 number ndConvFactoryNSingN( const CanonicalForm n, const coeffs r) 131 131 { 132 132 Werror("no conversion from factory"); -
libpolys/coeffs/test.cc
r0fb5991 rabb4787 17 17 #include <coeffs/rmodulo2m.h> 18 18 #include <coeffs/rintegers.h> 19 #ifdef HAVE_FACTORY 20 #include <factory/factory.h> 21 #endif 19 22 20 23 #include <iostream> … … 22 25 using namespace std; 23 26 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 24 66 25 67 #pragma GCC diagnostic ignored "-Wwrite-strings" -
libpolys/polys/Makefile.am
r0fb5991 rabb4787 38 38 kbuckets.cc sbuckets.cc weight.cc weight0.c simpleideals.cc matpol.cc \ 39 39 ${USE_P_PROCS_STATIC_CC} ${USE_P_PROCS_DYNAMIC_CC} templates/mod_raw.cc \ 40 clapsing.cc ext_fields/algext.cc40 ext_fields/algext.cc clapsing.cc clapconv.cc 41 41 42 42 BUILT_SOURCES = templates/p_Procs.inc … … 53 53 monomials/p_polys.h monomials/polys-impl.h monomials/maps.h polys.h prCopy.h prCopyMacros.h \ 54 54 kbuckets.h sbuckets.h simpleideals.h weight.h matpol.h \ 55 clapsing.h ext_fields/algext.h55 ext_fields/algext.h clapsing.h clapconv.h 56 56 57 57 P_PROCS_CPPFLAGS_COMMON = -DHAVE_CONFIG_H -DDYNAMIC_VERSION -
libpolys/polys/clapconv.cc
r0fb5991 rabb4787 9 9 10 10 11 #include < kernel/mod2.h>11 #include <misc/auxiliary.h> 12 12 #ifdef HAVE_FACTORY 13 13 #include <omalloc/omalloc.h> 14 #include <kernel/structs.h>15 14 #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; 28 21 29 22 void out_cf(char *s1,const CanonicalForm &f,char *s2); … … 39 32 poly convFactoryPSingP ( const CanonicalForm & f, const ring r ) 40 33 { 41 // cerr << " f = " << f << endl;42 34 int n = rVar(r)+1; 43 35 /* ASSERT( level( f ) <= pVariables, "illegal number of variables" ); */ … … 71 63 for ( int i = 1; i <= r->N; i++ ) 72 64 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); 93 66 p_Setm( term, r ); 94 if ( n_IsZero(pGetCoeff(term), r ) )67 if ( n_IsZero(pGetCoeff(term), r->cf) ) 95 68 { 96 69 p_Delete(&term,r); … … 108 81 CanonicalForm result = 0; 109 82 int e, n = rVar(r); 110 111 while ( p!=NULL) 83 BOOLEAN setChar=TRUE; 84 85 while ( p!=NULL ) 112 86 { 113 87 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; 147 91 for ( int i = n; i >0; i-- ) 148 92 { … … 156 100 } 157 101 102 int convFactoryISingI( const CanonicalForm & f) 103 { 104 if (!f.isImm()) WerrorS("int overflow in det"); 105 return f.intval(); 106 } 107 #if 0 158 108 CanonicalForm convSingAPFactoryAP ( poly p , const Variable & a, const ring r) 159 109 { … … 211 161 else 212 162 { 213 napoly z=(napoly)convFactoryASingA( f,r );163 poly z=(poly)convFactoryASingA( f,r ); 214 164 if (z!=NULL) 215 165 { … … 240 190 } 241 191 242 CanonicalForm convSingAFactoryA ( napoly p , const Variable & a, const ring r )192 CanonicalForm convSingAFactoryA ( poly p , const Variable & a, const ring r ) 243 193 { 244 194 CanonicalForm result = 0; … … 312 262 } 313 263 314 napoly convFactoryASingA ( const CanonicalForm & f, const ring r )264 poly convFactoryASingA ( const CanonicalForm & f, const ring r ) 315 265 { 316 266 poly a=NULL; … … 506 456 } 507 457 508 int convFactoryISingI( const CanonicalForm & f)509 {510 if (!f.isImm()) WerrorS("int overflow in det");511 return f.intval();512 }513 458 #endif 459 #endif -
libpolys/polys/clapconv.h
r0fb5991 rabb4787 12 12 #define INCL_SINGCONV_H 13 13 14 //#include <kernel/structs.h>14 #include <polys/monomials/ring.h> 15 15 #include <polys/ext_fields/longtrans.h> 16 #include <polys/monomials/ring.h>17 16 #ifdef HAVE_FACTORY 18 17 # include <factory/factory.h> … … 21 20 poly convFactoryPSingP ( const CanonicalForm & f, const ring r ); 22 21 CanonicalForm convSingPFactoryP( poly p, const ring r ); 22 //CanonicalForm convSingIFactoryI( int i);// by constructor of CanonicalForm 23 int convFactoryISingI( const CanonicalForm & f); 23 24 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 ); 27 28 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 ); 30 31 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 ); 33 34 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 ); 36 37 37 // CanonicalForm convSingIFactoryI( int i);a <- by constructor of CanonicalForm38 int convFactoryISingI( const CanonicalForm & f);39 38 #endif /* INCL_SINGCONV_H */ -
libpolys/polys/clapsing.cc
r0fb5991 rabb4787 34 34 void out_cf(const char *s1,const CanonicalForm &f,const char *s2); 35 35 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 36 static poly singclap_gcd_r ( poly f, poly g, const ring r ) 37 { 40 38 poly res=NULL; 41 39 … … 52 50 } 53 51 54 // for now there is only the possibility to handle polynomials over55 // Q and Fp ...56 52 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); 104 61 Off(SW_RATIONAL); 105 62 return res; … … 147 104 if ((f==NULL) || (g==NULL)) 148 105 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 155 108 CanonicalForm F( convSingPFactoryP( f, r ) ), G( convSingPFactoryP( g, r ) ); 156 109 res=convFactoryPSingP( resultant( F, G, X ), r ); 157 110 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 } 214 112 resultant_returns_res: 215 113 p_Delete(&f,r); … … 285 183 res=NULL;pa=NULL;pb=NULL; 286 184 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 { 304 190 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"); 350 192 return TRUE; 351 193 } 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); 352 200 #ifndef NDEBUG 353 201 // checking the result of extgcd: … … 364 212 } 365 213 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 univariate369 // polynomials over370 // 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 else417 {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 else434 {435 WerrorS( feNotImplemented );436 return TRUE;437 }438 return FALSE;439 }440 441 214 poly singclap_pdivide ( poly f, poly g, const ring r ) 442 215 { 443 216 poly res=NULL; 444 217 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 ); 525 220 Off(SW_RATIONAL); 526 221 return res; … … 646 341 CanonicalForm F, FAC,Q,R; 647 342 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 ); 671 345 672 346 poly q; … … 680 354 if (R.isZero()) 681 355 { 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 ); 697 357 e++; p_Delete(&f,r); f=q; q=NULL; F=Q; 698 358 } … … 845 505 L = factorize( F ); 846 506 } 847 #if 0848 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 else858 {859 goto notImpl;860 }861 }862 #endif863 507 // and over Q(a) / Fp(a) 864 508 else if (rField_is_Extension(r)) 865 509 { 866 if (rField_is_Q_a(r)) setCharacteristic( 0 );867 else setCharacteristic( -rChar(r) );868 510 if (r->cf->algring->minideal!=NULL) 869 511 { … … 871 513 r->cf->algring); 872 514 Variable a=rootOf(mipo); 873 CanonicalForm F( convSing APFactoryAP( f,a,r ) );515 CanonicalForm F( convSingPFactoryP( f,r ) ); 874 516 if (rField_is_Zp_a(r)) 875 517 { … … 884 526 else 885 527 { 886 CanonicalForm F( convSing TrPFactoryP( f,r ) );528 CanonicalForm F( convSingPFactoryP( f,r ) ); 887 529 L = factorize( F ); 888 530 } … … 930 572 if (r->cf->algring->minideal==NULL) 931 573 { 932 if(!count_Factors(res,w,j,ff,convFactoryPSing TrP( J.getItem().factor(),r ),r))574 if(!count_Factors(res,w,j,ff,convFactoryPSingP( J.getItem().factor(),r ),r)) 933 575 { 934 576 if (w!=NULL) … … 939 581 else 940 582 { 941 if (!count_Factors(res,w,j,ff,convFactory APSingAP( J.getItem().factor(),r ),r))583 if (!count_Factors(res,w,j,ff,convFactoryPSingP( J.getItem().factor(),r ),r)) 942 584 { 943 585 if (w!=NULL) … … 1187 829 } 1188 830 #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 else1207 {1208 CanonicalForm F( convSingTrPFactoryP( f,r ) );1209 L = sqrFree( F );1210 }1211 }1212 831 else 1213 832 { … … 1223 842 for ( ; J.hasItem(); J++, j++ ) 1224 843 { 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 ); 1239 845 } 1240 846 if (res->m[0]==NULL) … … 1431 1037 { 1432 1038 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); 1433 1043 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; 1467 1045 err: 1468 WerrorS( feNotImplemented ); 1469 } 1470 return b; 1046 WerrorS( feNotImplemented ); 1047 return 0; 1471 1048 } 1472 1049 … … 1480 1057 } 1481 1058 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 ) ; 1535 1069 Off(SW_RATIONAL); 1536 1070 return res; -
libpolys/polys/clapsing.h
r0fb5991 rabb4787 22 22 23 23 poly singclap_gcd ( poly f, poly g, const ring r ); 24 poly singclap_gcd_r ( poly f, poly g, const ring r );25 24 /* 26 25 napoly singclap_alglcm ( napoly f, napoly g ); … … 31 30 32 31 BOOLEAN 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 );34 32 35 33 poly singclap_pdivide ( poly f, poly g, const ring r ); 36 poly singclap_pdivide_r ( poly f, poly g, const ring r );37 34 38 35 void singclap_divide_content ( poly f, const ring r); -
libpolys/polys/monomials/p_polys.cc
r0fb5991 rabb4787 1673 1673 { 1674 1674 number x, y; 1675 int i;1676 1675 1677 1676 y = pGetCoeff(p); … … 1679 1678 n_Delete(&y,r->cf); 1680 1679 pSetCoeff0(p,x); 1681 //for (i =pVariables; i!=0; i--)1680 //for (int i=pVariables; i!=0; i--) 1682 1681 //{ 1683 1682 // pAddExp(p,i, pGetExp(q,i)); … … 1694 1693 { 1695 1694 number x; 1696 int i;1697 1695 poly r = p_Init(rr); 1698 1696 … … 2023 2021 if (rField_is_Q_a(r)) 2024 2022 { 2025 number hzz = nlInit(1, r->cf);2023 //number hzz = nlInit(1, r->cf); 2026 2024 h = nlInit(1, r->cf); 2027 2025 p=ph; … … 2993 2991 void p_SetGlobals(const ring r, BOOLEAN complete) 2994 2992 { 2995 int i;2996 2993 if (r->ppNoether!=NULL) p_Delete(&r->ppNoether,r); 2997 2994 … … 3590 3587 poly p_JetW(poly p, int m, short *w, const ring R) 3591 3588 { 3592 poly t=NULL;3593 3589 while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R); 3594 3590 if (p==NULL) return NULL; … … 3692 3688 { 3693 3689 number n,nn; 3694 int i;3695 3690 pAssume(p1 != NULL && p2 != NULL); 3696 3691 -
libpolys/tests/Makefile.am
r0fb5991 rabb4787 27 27 rings_test_LDFLAGS = $(polys_test_LDFLAGS) 28 28 29 coeffs_test_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -l omalloc_debug29 coeffs_test_LDADD = -lcoeffs_g ${GMP_LIBS} -lresources_g -lreporter_g -lmisc_g -llibsingcf_g -lomalloc_debug 30 30 polys_test_LDADD = -lpolys_g ${USEPPROCSDYNAMICLD} $(coeffs_test_LDADD) 31 31 rings_test_LDADD = $(polys_test_LDADD)
Note: See TracChangeset
for help on using the changeset viewer.