Changeset 3835a88 in git
- Timestamp:
- Jul 19, 2011, 2:21:54 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 7021758acc8d05ef28d445be496dbd3cca92007f
- Parents:
- 31f1262751310d366c99e1a3d2914e859f8ea5c0
- git-author:
- mlee <martinlee84@web.de>2011-07-19 14:21:54+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:40:00+01:00
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/spectrum.cc
r31f1262 r3835a88 22 22 23 23 #include <coeffs/numbers.h> 24 #include <polys/polys.h> 25 #include <kernel/ideals.h> 24 #include <polys/monomials/p_polys.h> 25 #include <polys/simpleideals.h> 26 #include <misc/intvec.h> 27 #include <polys/monomials/ring.h> 28 //extern ring currRing; 29 26 30 #include <kernel/kstd1.h> 27 31 #include <kernel/stairc.h> 28 #include <misc/intvec.h>29 #include <polys/monomials/ring.h>30 31 32 #include <kernel/multicnt.h> 32 33 #include <kernel/GMPrat.h> … … 40 41 // ---------------------------------------------------------------------------- 41 42 42 BOOLEAN hasTermOfDegree( poly h, int d )43 BOOLEAN hasTermOfDegree( poly h, int d, const ring r ) 43 44 { 44 45 do 45 46 { 46 if( p Totaldegree( h)== d )47 if( p_Totaldegree( h,r )== d ) 47 48 return TRUE; 48 49 pIter(h); … … 57 58 // ---------------------------------------------------------------------------- 58 59 59 static BOOLEAN inline hasConstTerm( poly h )60 { 61 return hasTermOfDegree(h,0 );60 static BOOLEAN inline hasConstTerm( poly h, const ring r ) 61 { 62 return hasTermOfDegree(h,0,r); 62 63 } 63 64 … … 66 67 // ---------------------------------------------------------------------------- 67 68 68 static BOOLEAN inline hasLinearTerm( poly h )69 { 70 return hasTermOfDegree(h,1 );69 static BOOLEAN inline hasLinearTerm( poly h, const ring r ) 70 { 71 return hasTermOfDegree(h,1,r); 71 72 } 72 73 … … 75 76 // ---------------------------------------------------------------------------- 76 77 77 BOOLEAN hasAxis( ideal J,int k )78 BOOLEAN hasAxis( ideal J,int k, const ring r ) 78 79 { 79 80 int i; … … 81 82 for( i=0; i<IDELEMS(J); i++ ) 82 83 { 83 if (p IsPurePower( J->m[i]) == k) return TRUE;84 if (p_IsPurePower( J->m[i],r ) == k) return TRUE; 84 85 } 85 86 return FALSE; … … 90 91 // ---------------------------------------------------------------------------- 91 92 92 int hasOne( ideal J )93 int hasOne( ideal J, const ring r ) 93 94 { 94 95 int i; … … 96 97 for( i=0; i<IDELEMS(J); i++ ) 97 98 { 98 if (p IsConstant(J->m[i])) return TRUE;99 if (p_IsConstant(J->m[i],r)) return TRUE; 99 100 } 100 101 return FALSE; … … 104 105 // ---------------------------------------------------------------------------- 105 106 106 int isMultiple( poly f,poly m )107 int isMultiple( poly f,poly m, const ring r ) 107 108 { 108 109 while( f!=NULL ) … … 112 113 // --------------------------------------------------- 113 114 114 if( p LmCmp( f,m)>=0 )115 { 116 if( p LmDivisibleByNoComp( f,m) )115 if( p_LmCmp( f,m,r )>=0 ) 116 { 117 if( p_LmDivisibleByNoComp( f,m,r ) ) 117 118 { 118 119 return TRUE; … … 136 137 // ---------------------------------------------------------------------------- 137 138 138 poly computeWC( const newtonPolygon &np,Rational max_weight )139 { 140 poly m = p One();139 poly computeWC( const newtonPolygon &np,Rational max_weight, const ring r ) 140 { 141 poly m = p_One(r); 141 142 poly wc = NULL; 142 143 int mdegree; 143 144 144 for( int i=1; i<= pVariables; i++ )145 for( int i=1; i<=r->N; i++ ) 145 146 { 146 147 mdegree = 1; 147 p SetExp( m,i,mdegree);148 p_SetExp( m,i,mdegree,r ); 148 149 // pSetm( m ); 149 150 // np.weight_shift does not need pSetm( m ), postpone it 150 151 151 while( np.weight_shift( m )<max_weight )152 while( np.weight_shift( m,r )<max_weight ) 152 153 { 153 154 mdegree++; 154 p SetExp( m,i,mdegree);155 p_SetExp( m,i,mdegree,r ); 155 156 // pSetm( m ); 156 157 // np.weight_shift does not need pSetm( m ), postpone it 157 158 } 158 p Setm( m);159 160 if( i==1 || p Cmp( m,wc)<0 )161 { 162 p Delete( &wc);163 wc = p Head( m);164 } 165 166 p SetExp( m,i,0);167 } 168 169 p Delete( &m);159 p_Setm( m,r ); 160 161 if( i==1 || p_Cmp( m,wc,r )<0 ) 162 { 163 p_Delete( &wc,r ); 164 wc = p_Head( m,r ); 165 } 166 167 p_SetExp( m,i,0,r ); 168 } 169 170 p_Delete( &m,r ); 170 171 171 172 return wc; … … 176 177 // ---------------------------------------------------------------------------- 177 178 178 static inline poly normalFormHC( poly f,poly hc )179 static inline poly normalFormHC( poly f,poly hc, const ring r ) 179 180 { 180 181 poly *ptr = &f; … … 182 183 while( (*ptr)!=NULL ) 183 184 { 184 if( p LmCmp( *ptr,hc)>=0 )185 if( p_LmCmp( *ptr,hc,r )>=0 ) 185 186 { 186 187 ptr = &(pNext( *ptr )); … … 188 189 else 189 190 { 190 p Delete( ptr );191 p_Delete( ptr,r ); 191 192 return f; 192 193 } … … 200 201 // ---------------------------------------------------------------------------- 201 202 202 static inline poly normalFormZ( poly f,poly Z )203 static inline poly normalFormZ( poly f,poly Z, const ring r ) 203 204 { 204 205 poly *ptr = &f; … … 206 207 while( (*ptr)!=NULL ) 207 208 { 208 if( !isMultiple( Z,*ptr ) )209 if( !isMultiple( Z,*ptr,r ) ) 209 210 { 210 211 ptr = &(pNext( *ptr )); … … 212 213 else 213 214 { 214 p LmDelete(ptr);215 p_LmDelete(ptr,r); 215 216 } 216 217 } … … 228 229 // ---------------------------------------------------------------------------- 229 230 230 static inline int isLeadMonomial( poly m,ideal stdJ )231 static inline int isLeadMonomial( poly m,ideal stdJ, const ring r ) 231 232 { 232 233 int length = INT_MAX; … … 235 236 for( int i=0; i<IDELEMS(stdJ); i++ ) 236 237 { 237 if( p Cmp( stdJ->m[i],m )>=0 && pDivisibleBy( stdJ->m[i],m) )238 if( p_Cmp( stdJ->m[i],m,r )>=0 && p_DivisibleBy( stdJ->m[i],m,r ) ) 238 239 { 239 240 int tmp = pLength( stdJ->m[i] ); … … 254 255 // ---------------------------------------------------------------------------- 255 256 256 static void setExp( poly m,int *r )257 { 258 for( int i= pVariables; i>0; i-- )259 { 260 p SetExp( m,i,r[i-1]);261 } 262 p Setm( m);257 static void setExp( poly m,int *r, const ring s ) 258 { 259 for( int i=s->N; i>0; i-- ) 260 { 261 p_SetExp( m,i,r[i-1],s ); 262 } 263 p_Setm( m,s ); 263 264 } 264 265 … … 268 269 // ---------------------------------------------------------------------------- 269 270 270 static BOOLEAN isWell( void)271 { 272 int b = rBlocks( currRing);271 static BOOLEAN isWell( const ring r ) 272 { 273 int b = rBlocks( r ); 273 274 274 275 if( b==3 && 275 ( currRing->order[0] == ringorder_ds ||276 currRing->order[0] == ringorder_Ds ||277 currRing->order[0] == ringorder_ws ||278 currRing->order[0] == ringorder_Ws ) )276 ( r->order[0] == ringorder_ds || 277 r->order[0] == ringorder_Ds || 278 r->order[0] == ringorder_ws || 279 r->order[0] == ringorder_Ws ) ) 279 280 { 280 281 return TRUE; 281 282 } 282 283 else if( b>=3 283 && (( currRing->order[0] ==ringorder_a284 && currRing->block1[0]==pVariables)285 || ( currRing->order[0]==ringorder_M286 && currRing->block1[0]==pVariables*pVariables)))287 { 288 for( int i= pVariables-1; i>=0; i-- )289 { 290 if( currRing->wvhdl[0][i]>=0 )284 && (( r->order[0] ==ringorder_a 285 && r->block1[0]==r->N ) 286 || (r->order[0]==ringorder_M 287 && r->block1[0]==r->N*r->N ))) 288 { 289 for( int i=r->N-1; i>=0; i-- ) 290 { 291 if( r->wvhdl[0][i]>=0 ) 291 292 { 292 293 return FALSE; … … 303 304 // ---------------------------------------------------------------------------- 304 305 305 void computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF )306 void computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF, const ring r ) 306 307 { 307 308 int carry,k; 308 multiCnt C( pVariables,0 );309 multiCnt C( r->N,0 ); 309 310 poly Z = NULL; 310 311 311 int well = isWell( 312 int well = isWell(r); 312 313 313 314 do 314 315 { 315 poly m = p One();316 setExp( m,C.cnt );316 poly m = p_One(r); 317 setExp( m,C.cnt,r ); 317 318 318 319 carry = FALSE; 319 320 320 k = isLeadMonomial( m,stdJ );321 k = isLeadMonomial( m,stdJ,r ); 321 322 322 323 if( k < 0 ) … … 328 329 NF->insert_node( m,NULL ); 329 330 } 330 else if( isMultiple( Z,m ) )331 else if( isMultiple( Z,m,r ) ) 331 332 { 332 333 // ------------------------------------ … … 334 335 // ------------------------------------ 335 336 336 p Delete( &m);337 p_Delete( &m,r ); 337 338 carry = TRUE; 338 339 } 339 else if( p Cmp( m,hc ) < 0 || pCmp( m,wc) < 0 )340 else if( p_Cmp( m,hc,r ) < 0 || p_Cmp( m,wc,r ) < 0 ) 340 341 { 341 342 // ------------------- … … 343 344 // ------------------- 344 345 345 p Delete( &m);346 p_Delete( &m,r ); 346 347 carry = TRUE; 347 348 } … … 352 353 // -------------------------- 353 354 354 poly multiplicant = p Divide( m,stdJ->m[k]);355 pGetCoeff( multiplicant ) = n Init(1);356 357 poly nf = p Mult_mm( pCopy( stdJ->m[k] ), multiplicant);358 359 p Delete( &multiplicant);360 361 nf = normalFormHC( nf,hc );355 poly multiplicant = p_Divide( m,stdJ->m[k],r ); 356 pGetCoeff( multiplicant ) = n_Init(1,r->cf); 357 358 poly nf = p_Mult_mm( p_Copy( stdJ->m[k],r ), multiplicant,r ); 359 360 p_Delete( &multiplicant,r ); 361 362 nf = normalFormHC( nf,hc,r ); 362 363 363 364 if( pNext( nf )==NULL ) … … 367 368 // ---------------------------------- 368 369 369 p Delete( &nf);370 p_Delete( &nf,r ); 370 371 NF->delete_monomial( m ); 371 Z = p Add( Z,m);372 Z = p_Add_q( Z,m,r ); 372 373 carry = TRUE; 373 374 } 374 375 else 375 376 { 376 nf = normalFormZ( nf,Z );377 nf = normalFormZ( nf,Z,r ); 377 378 378 379 if( pNext( nf )==NULL ) … … 382 383 // ---------------------------------- 383 384 384 p Delete( &nf);385 p_Delete( &nf,r ); 385 386 NF->delete_monomial( m ); 386 Z = p Add( Z,m);387 Z = p_Add_q( Z,m,r ); 387 388 carry = TRUE; 388 389 } … … 393 394 // ------------------------------------ 394 395 395 p Norm( nf);396 p_Norm( nf,r ); 396 397 if( well==TRUE ) 397 398 { … … 401 402 { 402 403 poly nfhard = kNF( stdJ,(ideal)NULL,pNext( nf ),0,0 ); 403 nfhard = normalFormHC( nfhard,hc );404 nfhard = normalFormZ ( nfhard,Z );404 nfhard = normalFormHC( nfhard,hc,r ); 405 nfhard = normalFormZ ( nfhard,Z,r ); 405 406 406 407 if( nfhard==NULL ) 407 408 { 408 409 NF->delete_monomial( m ); 409 Z = p Add( Z,m);410 Z = p_Add_q( Z,m,r ); 410 411 carry = TRUE; 411 412 } 412 413 else 413 414 { 414 p Delete( &pNext( nf ));415 p_Delete( &pNext( nf ),r ); 415 416 pNext( nf ) = nfhard; 416 417 NF->insert_node( m,nf ); … … 448 449 } while( not_finished ); 449 450 450 p Delete( &Z);451 p_Delete( &Z,r ); 451 452 } 452 453 … … 455 456 // ---------------------------------------------------------------------------- 456 457 457 BOOLEAN ringIsLocal( void)458 { 459 poly m = p One();460 poly one = p One();458 BOOLEAN ringIsLocal( const ring r ) 459 { 460 poly m = p_One(r); 461 poly one = p_One(r); 461 462 BOOLEAN res=TRUE; 462 463 463 for( int i= pVariables; i>0; i-- )464 { 465 p SetExp( m,i,1);466 p Setm( m);467 468 if( p Cmp( m,one)>0 )464 for( int i=r->N; i>0; i-- ) 465 { 466 p_SetExp( m,i,1,r ); 467 p_Setm( m,r ); 468 469 if( p_Cmp( m,one,r )>0 ) 469 470 { 470 471 res=FALSE; 471 472 break; 472 473 } 473 p SetExp( m,i,0);474 } 475 476 p Delete( &m);477 p Delete( &one);474 p_SetExp( m,i,0,r ); 475 } 476 477 p_Delete( &m,r ); 478 p_Delete( &one,r ); 478 479 479 480 return res; -
kernel/spectrum.h
r31f1262 r3835a88 17 17 BOOLEAN semicProc ( leftv,leftv,leftv ); 18 18 BOOLEAN semicProc3 ( leftv,leftv,leftv,leftv ); 19 BOOLEAN hasTermOfDegree( poly h, int d );20 int hasOne( ideal J );21 BOOLEAN hasAxis( ideal J,int k );22 poly computeWC( const newtonPolygon &np,Rational max_weight );23 void computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF );19 BOOLEAN hasTermOfDegree( poly h, int d, const ring r ); 20 int hasOne( ideal J, const ring r ); 21 BOOLEAN hasAxis( ideal J,int k, const ring r ); 22 poly computeWC( const newtonPolygon &np,Rational max_weight, const ring r ); 23 void computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF, const ring r ); 24 24 void spectrumPrintError(spectrumState state); 25 BOOLEAN ringIsLocal( void);25 BOOLEAN ringIsLocal( const ring r); 26 26 27 BOOLEAN inline hasConstTerm( poly h )28 { return hasTermOfDegree(h,0 ); }29 BOOLEAN inline hasLinearTerm( poly h )30 { return hasTermOfDegree(h,1 ); }27 BOOLEAN inline hasConstTerm( poly h, const ring r ) 28 { return hasTermOfDegree(h,0,r); } 29 BOOLEAN inline hasLinearTerm( poly h, const ring r ) 30 { return hasTermOfDegree(h,1,r); } 31 31 32 32
Note: See TracChangeset
for help on using the changeset viewer.