Changeset 10b5cf in git
- Timestamp:
- Jan 9, 2014, 2:43:36 PM (10 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 87b94594069607a5ab9e57ef4d0949d46cd26b64
- Parents:
- 581ac1cf5cb5c2dd89cdcbcef7426758e27c3a60
- git-author:
- Martin Lee <martinlee84@web.de>2014-01-09 14:43:36+01:00
- git-committer:
- Martin Lee <martinlee84@web.de>2014-01-27 16:12:23+01:00
- Location:
- factory
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/NTLconvert.cc
r581ac1 r10b5cf 8 8 #include "canonicalform.h" 9 9 #include "cf_iter.h" 10 #include "fac_berlekamp.h"11 #include "fac_cantzass.h"12 #include "fac_univar.h"13 #include "fac_multivar.h"14 10 #include "fac_sqrfree.h" 15 11 #include "cf_algorithm.h" -
factory/NTLconvert.h
r581ac1 r10b5cf 9 9 #include "canonicalform.h" 10 10 #include "cf_iter.h" 11 #include "fac_berlekamp.h"12 #include "fac_cantzass.h"13 #include "fac_univar.h"14 #include "fac_multivar.h"15 11 #include "fac_sqrfree.h" 16 12 #include "cf_algorithm.h" -
factory/canonicalform.cc
r581ac1 r10b5cf 16 16 #include "imm.h" 17 17 #include "gfops.h" 18 #include "cf_binom.h"19 18 20 19 #include <factory/cf_gmp.h> … … 42 41 43 42 (void)initializeCharacteristic(); 44 initPT();45 43 initialized = true; 46 44 } -
factory/cf_char.cc
r581ac1 r10b5cf 12 12 #include "int_pp.h" 13 13 #include "cf_primes.h" 14 #include "cf_binom.h"15 14 #include "cf_util.h" 16 15 … … 41 40 if (c > 536870909) factoryError("characteristic is too large(max is 2^29)"); 42 41 ff_setprime( c ); 43 resetFPT();44 42 } 45 43 } -
factory/facFqBivar.h
r581ac1 r10b5cf 27 27 #include "cf_map.h" 28 28 #include "cfNewtonPolygon.h" 29 #include "fac_util.h" 29 30 30 31 TIMING_DEFINE_PRINT(fac_fq_bi_sqrf) -
factory/fac_util.cc
r581ac1 r10b5cf 96 96 97 97 CanonicalForm 98 remainder( const CanonicalForm & f, const CanonicalForm & g, const modpk & pk )99 {100 ASSERT( (f.inCoeffDomain() || f.isUnivariate()) && (g.inCoeffDomain() || g.isUnivariate()) && (f.inCoeffDomain() || g.inCoeffDomain() || f.mvar() == g.mvar()), "can not build remainder" );101 if ( f.inCoeffDomain() )102 if ( g.inCoeffDomain() )103 return pk( f % g );104 else105 return pk( f );106 else {107 Variable x = f.mvar();108 CanonicalForm result = f;109 int degg = g.degree();110 CanonicalForm invlcg = pk.inverse( g.lc() );111 CanonicalForm gg = pk( g*invlcg );112 if((gg.lc().isOne()))113 {114 while ( result.degree() >= degg )115 {116 result -= pk(lc( result ) * gg) * power( x, result.degree() - degg );117 result=pk(result);118 }119 }120 else121 // no inverse found122 {123 CanonicalForm ic=icontent(g);124 if (!ic.isOne())125 {126 gg=g/ic;127 return remainder(f,gg,pk);128 }129 while ( result.degree() >= degg )130 {131 if (gg.lc().isZero()) return result;132 CanonicalForm lcgf = result.lc() / gg.lc();133 if (lcgf.inZ())134 gg = pk( g*lcgf );135 else136 {137 //printf("!\n\n");138 return result;139 }140 result -= gg * power( x, result.degree() - degg );141 result=pk(result);142 }143 }144 return result;145 }146 }147 148 void149 divremainder( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & quot, CanonicalForm & rem, const modpk & pk )150 {151 ASSERT( (f.inCoeffDomain() || f.isUnivariate()) && (g.inCoeffDomain() || g.isUnivariate()) && (f.inCoeffDomain() || g.inCoeffDomain() || f.mvar() == g.mvar()), "can not build remainder" );152 if ( f.inCoeffDomain() )153 if ( g.inCoeffDomain() ) {154 divrem( f, g, quot, rem );155 quot = pk( quot );156 rem = pk( rem );157 }158 else {159 quot = 0;160 rem = pk( f );161 }162 else {163 Variable x = f.mvar();164 CanonicalForm invlcg = pk.inverse( g.lc() );165 rem = f;166 int degg = g.degree();167 while ( rem.degree() >= degg ) {168 quot += pk( lc( rem ) * invlcg ) * power( x, rem.degree() - degg );169 rem = pk( rem - lc( rem ) * invlcg * g * power( x, rem.degree() - degg ) );170 }171 }172 }173 174 CanonicalForm175 98 mappksymmetric ( const CanonicalForm & f ) 176 99 { … … 188 111 } 189 112 190 void191 extgcd ( const CanonicalForm & a, const CanonicalForm & b, CanonicalForm & S, CanonicalForm & T, const modpk & pk )192 {193 int p = pk.getp(), k = pk.getk(), j;194 CanonicalForm amodp, bmodp, smodp, tmodp, s, t, sigma, tau, e;195 CanonicalForm modulus = p, sigmat, taut, q;196 197 setCharacteristic( p );198 {199 amodp = mapinto( a ); bmodp = mapinto( b );200 (void)extgcd( amodp, bmodp, smodp, tmodp );201 }202 setCharacteristic( 0 );203 s = mapinto( smodp ); t = mapinto( tmodp );204 205 for ( j = 1; j < k; j++ ) {206 e = ( 1 - s * a - t * b ) / modulus;207 setCharacteristic( p );208 {209 e = mapinto( e );210 sigmat = smodp * e;211 taut = tmodp * e;212 divrem( sigmat, bmodp, q, sigma );213 tau = taut + q * amodp;214 }215 setCharacteristic( 0 );216 s += mapinto( sigma ) * modulus;217 t += mapinto( tau ) * modulus;218 modulus *= p;219 }220 S = s; T = t;221 }222 223 CanonicalForm224 sum ( const CFArray & a, int f, int l )225 {226 if ( f < a.min() ) f = a.min();227 if ( l > a.max() ) l = a.max();228 CanonicalForm s = 0;229 for ( int i = f; i <= l; i++ )230 s += a[i];231 return s;232 }233 234 CanonicalForm235 prod ( const CFArray & a, int f, int l )236 {237 if ( f < a.min() ) f = a.min();238 if ( l > a.max() ) l = a.max();239 CanonicalForm p = 1;240 for ( int i = f; i <= l; i++ )241 p *= a[i];242 return p;243 }244 245 CanonicalForm246 sum ( const CFArray & a )247 {248 return sum( a, a.min(), a.max() );249 }250 251 CanonicalForm252 prod ( const CFArray & a )253 {254 return prod( a, a.min(), a.max() );255 }256 257 CanonicalForm258 crossprod ( const CFArray & a, const CFArray & b )259 {260 ASSERT( a.size() == b.size(), "array size mismatch" );261 CanonicalForm s = 0;262 int fa = a.min();263 int fb = b.min();264 int n = a.max();265 for ( ; fa <= n; fa++, fb++ )266 s += a[fa] * b[fb];267 return s;268 } -
factory/fac_util.h
r581ac1 r10b5cf 34 34 CanonicalForm replaceLc( const CanonicalForm & f, const CanonicalForm & c ); 35 35 36 CanonicalForm remainder( const CanonicalForm & f, const CanonicalForm & g, const modpk & pk );37 38 void divremainder( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & quot, CanonicalForm & rem, const modpk & pk );39 40 bool Hensel ( const CanonicalForm & U, CFArray & G, const CFArray & lcG, const Evaluation & A, const modpk & bound, const Variable & x );41 42 /* some special array functions */43 44 CanonicalForm sum ( const CFArray & a, int f, int l );45 46 CanonicalForm prod ( const CFArray & a, int f, int l );47 48 CanonicalForm sum ( const CFArray & a );49 50 CanonicalForm prod ( const CFArray & a );51 52 CanonicalForm crossprod ( const CFArray & a, const CFArray & b );53 54 36 /*ENDPUBLIC*/ 55 37 -
factory/factory.template
r581ac1 r10b5cf 60 60 61 61 /*MAKEHEADER PUBLIC ONLY*/ 62 #include "cf_binom.h"63 64 /*MAKEHEADER PUBLIC ONLY*/65 62 #include "cf_algorithm.h" 66 63
Note: See TracChangeset
for help on using the changeset viewer.