Changeset 4a7a45 in git
- Timestamp:
- Jul 29, 2020, 5:33:12 PM (3 years ago)
- Branches:
- (u'spielwiese', 'd1ba061a762c62d3a25159d8da8b6e17332291fa')
- Children:
- 700b89d0131c4b3d214f49af1eeb67501875ec89
- Parents:
- 4772b1b4621f2ab68acc9d2b5a568604d4d5e790
- Location:
- factory
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/canonicalform.cc
r4772b1 r4a7a45 15 15 #include "cf_algorithm.h" 16 16 #include "imm.h" 17 #include "int_pp.h" 17 18 #include "gfops.h" 18 19 #include "facMul.h" 19 20 #include "facAlgFuncUtil.h" 20 21 #include "FLINTconvert.h" 22 #include "cf_binom.h" 21 23 22 24 #ifndef NOSTREAMIO … … 204 206 } 205 207 208 206 209 CanonicalForm 207 210 CanonicalForm::mapinto () const … … 216 219 else 217 220 return *this; 221 else if ( CFFactory::gettype() == PrimePowerDomain ) 222 return CanonicalForm( CFFactory::basic( imm2int( value ) ) ); 218 223 else if ( getGFDegree() == 1 ) 219 224 return CanonicalForm( int2imm_p( ff_norm( imm2int( value ) ) ) ); … … 222 227 else if ( value->inBaseDomain() ) 223 228 if ( getCharacteristic() == 0 ) 224 return *this; 229 if ( value->levelcoeff() == PrimePowerDomain ) 230 { 231 mpz_t d; 232 getmpi( value,d); 233 if ( mpz_cmp( InternalPrimePower::primepowhalf, d ) < 0 ) 234 mpz_sub( d, d, InternalPrimePower::primepow ); 235 return CFFactory::basic( d ); 236 } 237 else 238 return *this; 239 else if ( CFFactory::gettype() == PrimePowerDomain ) 240 { 241 ASSERT( value->levelcoeff() == PrimePowerDomain || value->levelcoeff() == IntegerDomain, "no proper map defined" ); 242 if ( value->levelcoeff() == PrimePowerDomain ) 243 return *this; 244 else 245 { 246 mpz_t d; 247 getmpi(value,d); 248 if ( mpz_cmp( InternalPrimePower::primepowhalf, d ) < 0 ) 249 mpz_sub( d, d, InternalPrimePower::primepow ); 250 return CFFactory::basic( d ); 251 } 252 } 225 253 else 226 254 { … … 248 276 } 249 277 } 250 251 278 /** CanonicalForm CanonicalForm::lc (), Lc (), LC (), LC ( v ) const 252 279 * … … 1935 1962 return cf_glob_switches.isOn( sw ); 1936 1963 } 1964 1965 #ifndef HAVE_NTL 1966 static int initialized=0; 1967 int 1968 initCanonicalForm( void ) 1969 { 1970 if ( ! initialized ) 1971 { 1972 initPT(); 1973 initialized = true; 1974 } 1975 } 1976 #endif 1977 -
factory/canonicalform.h
r4772b1 r4a7a45 404 404 /*ENDPUBLIC*/ 405 405 406 int initCanonicalForm( void ); 407 static int cf_is_initialized_now = initCanonicalForm(); 406 408 #endif /* ! INCL_CANONICALFORM_H */ -
factory/cf_binom.h
r4772b1 r4a7a45 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_binom.h 12231 2009-11-02 10:12:22Z hannes $ */ 2 3 3 4 #ifndef INCL_CF_BINOM_H 4 5 #define INCL_CF_BINOM_H 5 6 6 // #include "config.h" 7 #include <config.h> 7 8 8 9 #include "canonicalform.h" -
factory/cf_factory.cc
r4772b1 r4a7a45 14 14 #include "int_rat.h" 15 15 #include "int_poly.h" 16 #include "int_pp.h" 16 17 #include "imm.h" 17 18 … … 46 47 case GaloisFieldDomain: 47 48 return int2imm_gf( gf_int2gf( value ) ); 49 case PrimePowerDomain: 50 return new InternalPrimePower( value ); 48 51 default: { 49 52 ASSERT( 0, "illegal basic domain!" ); … … 260 263 void getmpi ( InternalCF * value, mpz_t mpi) 261 264 { 262 ASSERT( ! is_imm( value ) && (value->levelcoeff() == IntegerDomain ), "illegal operation" );265 ASSERT( ! is_imm( value ) && (value->levelcoeff() == IntegerDomain || value->levelcoeff() == PrimePowerDomain), "illegal operation" ); 263 266 mpz_init_set (mpi, ((InternalInteger*)value)->thempi); 264 267 } 265 -
factory/cf_factory.h
r4772b1 r4a7a45 29 29 static void settype ( int type ) 30 30 { 31 ASSERT( type==FiniteFieldDomain || type==GaloisFieldDomain || type==IntegerDomain || type==RationalDomain , "illegal basic domain!" );31 ASSERT( type==FiniteFieldDomain || type==GaloisFieldDomain || type==IntegerDomain || type==RationalDomain || type==PrimePowerDomain, "illegal basic domain!" ); 32 32 currenttype = type; 33 33 }; … … 46 46 47 47 void getmpi ( InternalCF * value, mpz_t mpi); 48 49 48 #endif /* ! INCL_CF_FACTORY_H */ -
factory/fac_distrib.cc
r4772b1 r4a7a45 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 3 4 #include "config.h" 5 6 7 #include "cf_assert.h" 2 /* $Id: fac_distrib.cc 14344 2011-07-25 14:08:17Z mlee $ */ 3 4 #include <config.h> 5 6 #include "assert.h" 8 7 #include "debug.h" 9 8 … … 16 15 17 16 #ifndef HAVE_NTL 17 18 18 bool 19 19 nonDivisors ( CanonicalForm omega, CanonicalForm delta, const CFArray & F, CFArray & d ) -
factory/fac_distrib.h
r4772b1 r4a7a45 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_distrib.h 12231 2009-11-02 10:12:22Z hannes $ */ 2 3 3 4 #ifndef INCL_FAC_DISTRIB_H 4 5 #define INCL_FAC_DISTRIB_H 5 6 6 // #include "config.h" 7 #include <config.h> 7 8 8 9 #include "canonicalform.h" -
factory/fac_multihensel.cc
r4772b1 r4a7a45 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 3 4 #include "config.h" 5 6 7 #include "cf_assert.h" 2 /* $Id: fac_multihensel.cc 12231 2009-11-02 10:12:22Z hannes $ */ 3 4 #include <config.h> 5 6 #include "assert.h" 8 7 #include "debug.h" 9 8 #include "timing.h" … … 14 13 #include "fac_util.h" 15 14 #include "fac_iterfor.h" 16 #include "fac_multihensel.h"17 15 #include "cf_iter.h" 18 16 19 17 #ifndef HAVE_NTL 20 18 21 TIMING_DEFINE_PRINT(fac_solve) 22 TIMING_DEFINE_PRINT(fac_modpk) 23 TIMING_DEFINE_PRINT(fac_corrcoeff) 24 TIMING_DEFINE_PRINT(fac_extgcd) 19 TIMING_DEFINE_PRINT(fac_solve); 20 TIMING_DEFINE_PRINT(fac_modpk); 21 TIMING_DEFINE_PRINT(fac_corrcoeff); 22 TIMING_DEFINE_PRINT(fac_extgcd); 25 23 26 24 static void 27 extgcdrest ( const CanonicalForm & a, const CanonicalForm & b, const CanonicalForm & s, const CanonicalForm & t, const CanonicalForm & c, CanonicalForm & S, CanonicalForm & T, const modpk & /*pk*/)25 extgcdrest ( const CanonicalForm & a, const CanonicalForm & b, const CanonicalForm & s, const CanonicalForm & t, const CanonicalForm & c, CanonicalForm & S, CanonicalForm & T, const modpk & pk ) 28 26 { 29 27 CanonicalForm sigma = s * c, tau = t * c; … … 169 167 A[i] = remainder( pk( a[i] * C0 ), P0[i], pk ); 170 168 DEBOUTLN( cerr, "the first approximation of the correction coefficients is " << A ); 171 /*#ifdef DEBUGOUTPUT169 #ifdef DEBUGOUTPUT 172 170 if ( check_dummy( A, P, Q ) - C != 0 ) 173 171 { … … 177 175 DEBOUTLN( cerr, " Q " << Q ); 178 176 } 179 #endif */177 #endif 180 178 for ( m = 0; m <= h && ( m == 0 || Dm != 0 ); m++ ) 181 179 { … … 219 217 DEBOUTLN( cerr, "the correction coefficients at step " << m ); 220 218 DEBOUTLN( cerr, "are now " << A ); 221 /*#ifdef DEBUGOUTPUT219 #ifdef DEBUGOUTPUT 222 220 if ( check_dummy( A, P, Q ) - C != 0 ) { 223 221 DEBOUTLN( cerr, "there is an error detected, the correction coefficients do not" ); … … 226 224 DEBOUTLN( cerr, " Q " << Q ); 227 225 } 228 #endif */226 #endif 229 227 } 230 228 DEBDECLEVEL( cerr, "findCorrCoeffs" ); … … 326 324 327 325 bool 328 Hensel ( const CanonicalForm & U, CFArray & G, const CFArray & lcG, const Evaluation & A, const modpk & bound, const Variable & /*x*/)326 Hensel ( const CanonicalForm & U, CFArray & G, const CFArray & lcG, const Evaluation & A, const modpk & bound, const Variable & x ) 329 327 { 330 328 DEBINCLEVEL( cerr, "Hensel" ); -
factory/fac_multivar.cc
r4772b1 r4a7a45 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 3 4 #include "config.h" 5 6 7 #include "cf_assert.h" 2 /* $Id: fac_multivar.cc 14377 2011-09-01 13:40:30Z mlee $ */ 3 4 #include <config.h> 5 6 #include "assert.h" 8 7 #include "debug.h" 9 8 #include "timing.h" … … 21 20 #include "fac_distrib.h" 22 21 #include "fac_multihensel.h" 22 #include "facBivar.h" 23 23 24 24 #ifndef HAVE_NTL 25 25 26 void out_cf(const char *s1,const CanonicalForm &f,const char *s2); 26 27 void out_cff(CFFList &L); 27 28 28 TIMING_DEFINE_PRINT(fac_content) 29 TIMING_DEFINE_PRINT(fac_findeval) 30 TIMING_DEFINE_PRINT(fac_distrib) 31 TIMING_DEFINE_PRINT(fac_hensel) 29 TIMING_DEFINE_PRINT(fac_content); 30 TIMING_DEFINE_PRINT(fac_findeval); 31 TIMING_DEFINE_PRINT(fac_distrib); 32 TIMING_DEFINE_PRINT(fac_hensel); 32 33 33 34 static CFArray … … 69 70 70 71 static modpk 71 coeffBound ( const CanonicalForm & f, int p )72 coeffBound_old ( const CanonicalForm & f, int p ) 72 73 { 73 74 int * degs = degrees( f ); … … 148 149 } 149 150 150 #ifdef HAVE_NTL 151 VARint prime_number=0;151 152 static int prime_number=0; 152 153 void find_good_prime(const CanonicalForm &f, int &start) 153 154 { … … 199 200 } 200 201 } 201 #endif202 203 202 static CFArray ZFactorizeMulti ( const CanonicalForm & arg ) 204 203 { 204 prime_number=0; 205 bool is_rat=isOn(SW_RATIONAL); 206 Off(SW_RATIONAL); 205 207 DEBINCLEVEL( cerr, "ZFactorizeMulti" ); 206 208 CFMap M; … … 264 266 G = conv_to_factor_array( factorize( U0, false ) ); 265 267 DEBOUTLN( cerr, "which factorizes into " << G ); 266 #ifdef HAVE_NTL267 268 { 268 269 int i=prime_number; … … 279 280 else if (((i==0)||(i!=prime_number))) 280 281 { 281 b = coeffBound ( U, p );282 b = coeffBound_old( U, p ); 282 283 prime_number=i; 283 284 } 284 285 // p!=0: 285 modpk bb=coeffBound (U0,p);286 modpk bb=coeffBound_old(U0,p); 286 287 if (bb.getk() > b.getk() ) b=bb; 287 bb=coeffBound (arg,p);288 bb=coeffBound_old(arg,p); 288 289 if (bb.getk() > b.getk() ) b=bb; 289 290 } 290 #else291 b = coeffBound( U, getZFacModulus().getp() );292 291 if ( getZFacModulus().getpk() > b.getpk() ) 293 292 b = getZFacModulus(); 294 #endif295 293 //printf("p=%d, k=%d\n",b.getp(),b.getk()); 296 294 DEBOUTLN( cerr, "the coefficient bound of the factors of U is " << b.getpk() ); … … 342 340 G[1] = -G[1]; 343 341 DEBDECLEVEL( cerr, "ZFactorMulti" ); 342 if(is_rat) On(SW_RATIONAL); 344 343 return G; 345 344 } … … 364 363 { 365 364 if ( i.getItem().factor().inCoeffDomain() ) 366 R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) ); 365 { 366 if ( ! i.getItem().factor().isOne() ) 367 R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) ); 368 } 367 369 else 368 370 { -
factory/fac_multivar.h
r4772b1 r4a7a45 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: fac_multivar.h 12231 2009-11-02 10:12:22Z hannes $ */ 2 3 3 4 #ifndef INCL_FAC_MULTIVAR_H 4 5 #define INCL_FAC_MULTIVAR_H 5 6 6 // #include "config.h" 7 #include <config.h> 7 8 8 9 #include "canonicalform.h" -
factory/int_pp.h
r4772b1 r4a7a45 30 30 STATIC_VAR int prime; 31 31 STATIC_VAR int exp; 32 static void initialize(); 33 public: 34 mpz_ptr MPI( const InternalCF * const c ); 32 35 STATIC_VAR mpz_t primepow; 33 36 STATIC_VAR mpz_t primepowhalf; 34 static void initialize();35 static mpz_ptr MPI( const InternalCF * const c );36 public:37 37 InternalPrimePower(); 38 38 InternalPrimePower( const InternalCF& ) … … 91 91 92 92 int sign() const; 93 friend mpz_ptr getmpi ( InternalCF * value, bool symmetric);93 friend void getmpi ( InternalCF * value, mpz_t ); 94 94 }; 95 95
Note: See TracChangeset
for help on using the changeset viewer.