Changeset c36096 in git
- Timestamp:
- Dec 9, 2011, 4:25:59 PM (11 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- 5116a21003035b0c48021bd4d49957a2f5436695
- Parents:
- da6156d890b0086d0bccbe11eabde6ad49d897e6
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-12-09 16:25:59+01:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-12-12 18:01:22+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test.cc
rda6156 rc36096 203 203 #include "polys.h" 204 204 205 int main( int, char *argv[] ) 205 void TestGBEngine() 206 206 { 207 feInitResources(argv[0]);208 209 StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");210 feStringAppendResources(0);211 PrintS(StringAppendS("\n"));212 213 207 208 // R = MPolynomialRing_polydict(QQ,5,'w,x,y,z,C', order='degrevlex') 209 // J = (w*w - x*z, w*x - y*z, x*x - w*y, x*y - z*z, y*y - w*z) 210 211 const short w = 1; 212 const short x = 2; 213 const short y = 3; 214 const short z = 4; 215 216 const short N = (z - w + 1); 217 218 char **n=(char**)omalloc(N*sizeof(char*)); 219 220 221 n[w-1]=omStrDup("w"); 222 n[x-1]=omStrDup("x"); 223 n[y-1]=omStrDup("y"); 224 n[z-1]=omStrDup("z"); 225 226 227 const int D = 3; 228 int *order = (int *) omAlloc0(D* sizeof(int)); 229 int *block0 = (int *)omAlloc0(D * sizeof(int)); 230 int *block1 = (int *)omAlloc0(D * sizeof(int)); 231 232 order[0] = ringorder_dp; 233 block0[0] = 1; 234 block1[0] = N; 235 236 order[1] = ringorder_C; 237 block0[1] = 1; 238 block1[1] = N; 239 240 ring R = rDefault(0, N, n, D, order, block0, block1); 241 242 // ring R = rDefault(0, N, n); 243 244 rWrite(R); PrintLn(); 245 246 #ifdef RDEBUG 247 rDebugPrint(R); 248 #endif 249 250 ideal I = idInit(5, 1); 251 252 int gen = 0; 253 254 { 255 // -xz 256 poly p = p_ISet(-1,R); 257 258 p_SetExp(p, x, 1, R); 259 p_SetExp(p, z, 1, R); 260 p_Setm(p, R); 261 262 assume( p_GetExp(p, x, R) == 1 ); 263 assume( p_GetExp(p, z, R) == 1 ); 264 assume( p_GetExp(p, w, R) == 0 ); 265 assume( p_GetExp(p, y, R) == 0 ); 266 267 // +w2 268 poly lp = p_ISet(1,R); 269 p_SetExp(lp, w, 2, R); 270 p_Setm(lp, R); 271 272 assume( p_GetExp(lp, w, R) == 2 ); 273 assume( p_GetExp(lp, x, R) == 0 ); 274 assume( p_GetExp(lp, y, R) == 0 ); 275 assume( p_GetExp(lp, z, R) == 0 ); 276 277 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // w2 - xz 278 } 279 280 { 281 // -yz 282 poly p = p_ISet(-1,R); 283 284 p_SetExp(p, y, 1, R); 285 p_SetExp(p, z, 1, R); 286 p_Setm(p, R); 287 288 assume( p_GetExp(p, y, R) == 1 ); 289 assume( p_GetExp(p, z, R) == 1 ); 290 assume( p_GetExp(p, w, R) == 0 ); 291 assume( p_GetExp(p, x, R) == 0 ); 292 293 // +wx 294 poly lp = p_ISet(1,R); 295 p_SetExp(lp, w, 1, R); 296 p_SetExp(lp, x, 1, R); 297 p_Setm(lp, R); 298 299 assume( p_GetExp(lp, w, R) == 1 ); 300 assume( p_GetExp(lp, x, R) == 1 ); 301 assume( p_GetExp(lp, y, R) == 0 ); 302 assume( p_GetExp(lp, z, R) == 0 ); 303 304 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // wx - yz 305 } 306 307 308 { 309 // -wy 310 poly p = p_ISet(-1,R); 311 312 p_SetExp(p, y, 1, R); 313 p_SetExp(p, w, 1, R); 314 p_Setm(p, R); 315 316 assume( p_GetExp(p, y, R) == 1 ); 317 assume( p_GetExp(p, w, R) == 1 ); 318 assume( p_GetExp(p, z, R) == 0 ); 319 assume( p_GetExp(p, x, R) == 0 ); 320 321 // +x2 322 poly lp = p_ISet(1,R); 323 p_SetExp(lp, x, 2, R); 324 p_Setm(lp, R); 325 326 assume( p_GetExp(lp, w, R) == 0 ); 327 assume( p_GetExp(lp, x, R) == 2 ); 328 assume( p_GetExp(lp, y, R) == 0 ); 329 assume( p_GetExp(lp, z, R) == 0 ); 330 331 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // x2 - wy 332 } 333 334 335 { 336 // -z2 337 poly p = p_ISet(-1,R); 338 339 p_SetExp(p, z, 2, R); 340 p_Setm(p, R); 341 342 assume( p_GetExp(p, y, R) == 0 ); 343 assume( p_GetExp(p, w, R) == 0 ); 344 assume( p_GetExp(p, z, R) == 2 ); 345 assume( p_GetExp(p, x, R) == 0 ); 346 347 // +xy 348 poly lp = p_ISet(1,R); 349 p_SetExp(lp, x, 1, R); 350 p_SetExp(lp, y, 1, R); 351 p_Setm(lp, R); 352 353 assume( p_GetExp(lp, w, R) == 0 ); 354 assume( p_GetExp(lp, x, R) == 1 ); 355 assume( p_GetExp(lp, y, R) == 1 ); 356 assume( p_GetExp(lp, z, R) == 0 ); 357 358 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // xy - z2 359 } 360 361 362 { 363 // -wz 364 poly p = p_ISet(-1,R); 365 366 p_SetExp(p, w, 1, R); 367 p_SetExp(p, z, 1, R); 368 p_Setm(p, R); 369 370 assume( p_GetExp(p, y, R) == 0 ); 371 assume( p_GetExp(p, w, R) == 1 ); 372 assume( p_GetExp(p, z, R) == 1 ); 373 assume( p_GetExp(p, x, R) == 0 ); 374 375 // +y2 376 poly lp = p_ISet(1,R); 377 p_SetExp(lp, y, 2, R); 378 p_Setm(lp, R); 379 380 assume( p_GetExp(lp, w, R) == 0 ); 381 assume( p_GetExp(lp, x, R) == 0 ); 382 assume( p_GetExp(lp, y, R) == 2 ); 383 assume( p_GetExp(lp, z, R) == 0 ); 384 385 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // y2 - wz 386 } 387 #ifdef PDEBUG 388 PrintS("I: "); 389 idShow(I, R, R, 0); 390 #endif 391 392 393 // ideal kStd(ideal F, ideal Q, tHomog h, intvec ** mw,intvec *hilb=NULL, 394 // int syzComp=0,int newIdeal=0, intvec *vw=NULL); 395 // make R the default ring: 396 rChangeCurrRing(R); 397 398 ideal G = kStd(I, currQuotient, testHomog, NULL); 399 400 #ifdef PDEBUG 401 PrintS("GB: "); 402 idShow(G, R, R, 0); 403 #endif 404 405 idDelete( &G, R); 406 407 ideal SYZ; 408 409 { 410 intvec *ww=NULL; 411 SYZ = idSyzygies(I, testHomog, &ww); 412 if (ww!=NULL) delete ww; 413 } 414 415 416 #ifdef PDEBUG 417 PrintS("SYZ: "); 418 idShow(SYZ, R, R, 0); 419 #endif 420 421 idDelete( &SYZ, R); 422 idDelete( &I, R); 423 424 rDelete(R); // should cleanup every belonging polynomial, right!? 425 426 } 427 428 429 430 void TestSimpleRingArithmetcs() 431 { 214 432 // Libpolys tests: 215 433 216 434 // construct the ring Z/32003[x,y,z] 217 435 // the variable names … … 229 447 #endif 230 448 231 449 232 450 poly p = p_ISet(1,R); p_SetExp(p,1,1, R); p_Setm(p, R); 233 451 234 452 assume( p_GetExp(p,1, R) == 1 ); 235 453 236 454 poly pp = pp_Mult_qq( p, p, R); 237 455 … … 242 460 243 461 p_Delete(&p, R); 244 462 245 463 assume( p_GetExp(pp,1, R) == 2 ); 246 464 247 465 p_Delete(&pp, R); 248 249 466 467 250 468 // rDelete(R); 251 469 252 470 // make R the default ring: 253 471 rChangeCurrRing(R); 254 472 255 473 // create the polynomial 1 256 474 poly p1=pISet(1); … … 273 491 // clean up: 274 492 // pDelete(&p1); 275 493 276 494 rDelete(R); // should cleanup every belonging polynomial, right!? 277 495 } 496 497 498 int main( int, char *argv[] ) 499 { 500 feInitResources(argv[0]); 501 502 StringSetS("ressources in use (as reported by feStringAppendResources(0):\n"); 503 feStringAppendResources(0); 504 PrintS(StringAppendS("\n")); 505 506 TestGBEngine(); 507 TestSimpleRingArithmetcs(); 278 508 279 509 return 0;
Note: See TracChangeset
for help on using the changeset viewer.