Changeset de90c01 in git
- Timestamp:
- Jun 28, 2011, 5:24:13 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 010f3bf0c665c71ec55b5bb0d7d518fd24e73ed0
- Parents:
- f59722f94f8a42963b69fe4389c1ce3850e4f87e
- git-author:
- Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-06-28 17:24:13+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:39:10+01:00
- Location:
- libpolys
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/transext.cc
rf59722 rde90c01 30 30 /// our type has been defined as a macro in transext.h 31 31 /// and is accessible by 'ntID' 32 33 extern omBin fractionObjectBin = omGetSpecBin(sizeof(fractionObject)); 32 34 33 35 /// forward declarations … … 340 342 fraction fa = (fraction)a; 341 343 fraction fb = (fraction)b; 344 345 poly g = p_Copy(num(fa), ntRing); 346 if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing); 347 poly h = p_Copy(num(fb), ntRing); 348 if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing); 349 g = p_Add_q(g, h, ntRing); 350 351 if (g == NULL) return NULL; 352 342 353 poly f; 343 354 if (denIs1(fa) && denIs1(fb)) f = NULL; … … 347 358 p_Copy(den(fb), ntRing), 348 359 ntRing); 349 poly g = p_Copy(num(fa), ntRing); 350 if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing); 351 poly h = p_Copy(num(fb), ntRing); 352 if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing); 353 g = p_Add_q(g, h, ntRing); 360 354 361 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 355 362 num(result) = g; … … 368 375 fraction fa = (fraction)a; 369 376 fraction fb = (fraction)b; 377 378 poly g = p_Copy(num(fa), ntRing); 379 if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing); 380 poly h = p_Copy(num(fb), ntRing); 381 if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing); 382 g = p_Add_q(g, p_Neg(h, ntRing), ntRing); 383 384 if (g == NULL) return NULL; 385 370 386 poly f; 371 387 if (denIs1(fa) && denIs1(fb)) f = NULL; … … 375 391 p_Copy(den(fb), ntRing), 376 392 ntRing); 377 poly g = p_Copy(num(fa), ntRing); 378 if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing); 379 poly h = p_Copy(num(fb), ntRing); 380 if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing); 381 g = p_Add_q(g, p_Neg(h, ntRing), ntRing); 393 382 394 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 383 395 num(result) = g; … … 395 407 fraction fa = (fraction)a; 396 408 fraction fb = (fraction)b; 409 410 poly g = p_Copy(num(fa), ntRing); 411 poly h = p_Copy(num(fb), ntRing); 412 g = p_Mult_q(g, h, ntRing); 413 414 if (g == NULL) return NULL; /* may happen due to zero divisors */ 415 397 416 poly f; 398 417 if (denIs1(fa) && denIs1(fb)) f = NULL; … … 402 421 p_Copy(den(fb), ntRing), 403 422 ntRing); 404 poly g = p_Copy(num(fa), ntRing); 405 poly h = p_Copy(num(fb), ntRing); 406 g = p_Mult_q(g, h, ntRing); 423 407 424 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 408 425 num(result) = g; … … 421 438 fraction fa = (fraction)a; 422 439 fraction fb = (fraction)b; 440 441 poly g = p_Copy(num(fa), ntRing); 442 if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing); 443 444 if (g == NULL) return NULL; /* may happen due to zero divisors */ 445 423 446 poly f = p_Copy(num(fb), ntRing); 424 447 if (!denIs1(fa)) f = p_Mult_q(f, p_Copy(den(fa), ntRing), ntRing); 425 poly g = p_Copy(num(fa), ntRing); 426 if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing); 448 427 449 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 428 450 num(result) = g; … … 559 581 } 560 582 561 /* this just reads polynomials;562 the rest will be taken care of by the interpreter: When it encounters563 a "/", then it will impose a division that will finally lead to a564 rational function */565 583 const char * ntRead(const char *s, number *a, const coeffs cf) 566 584 { -
libpolys/polys/ext_fields/transext.h
rf59722 rde90c01 52 52 }; 53 53 typedef struct fractionObject * fraction; 54 55 omBin fractionObjectBin = omGetSpecBin(sizeof(fractionObject));56 54 57 55 /* constants for controlling the complexity of numbers */ -
libpolys/tests/polys_test.h
rf59722 rde90c01 16 16 17 17 #include <polys/ext_fields/algext.h> 18 #include <polys/ext_fields/transext.h> 18 19 #include <polys/monomials/ring.h> 19 20 #include <polys/monomials/p_polys.h> … … 21 22 #include <polys/simpleideals.h> 22 23 23 #if def HAVE_FACTORY24 #if 0 //ifdef HAVE_FACTORY 24 25 #include <polys/clapsing.h> 25 26 #include <factory/factory.h> … … 223 224 void checkInverse(number n, const coeffs cf) 224 225 { 225 clog << "n = "; n_Write(n, cf);226 clog << "n = "; p_Write((poly)n, cf->extRing); 226 227 number n1 = n_Invers(n, cf); 227 clog << "==> n^(-1) = "; n_Write(n1, cf);228 clog << "==> n^(-1) = "; p_Write((poly)n1, cf->extRing); 228 229 number n2 = n_Mult(n, n1, cf); 229 clog << " (check: n * n^(-1) = "; n_Write(n2, cf);230 clog << "check: n * n^(-1) = "; p_Write((poly)n2, cf->extRing); 230 231 TS_ASSERT( n_IsOne(n2, cf) ); 231 232 n_Delete(&n1, cf); n_Delete(&n2, cf); … … 858 859 859 860 Test(s); 860 /* 861 #ifdef HAVE_FACTORY 862 poly f = p_ISet(3, s); 863 p_SetExp(f, 1, 3, s); 864 p_SetExp(f, 2, 1, s); 865 p_SetExp(f, 3, 5, s); 866 p_Setm(f, r); // 3*u^3*v*w^5 867 plusTerm(f, -2, 1, 6, s); // -2*u^6 + 3*u^3*v*w^5 868 p_Write(f, s); 869 poly g = p_ISet(7, s); 870 p_SetExp(g, 1, 5, s); 871 p_SetExp(g, 2, 6, s); 872 p_SetExp(g, 3, 2, s); 873 p_Setm(g, r); // 7*u^5*v^6*w^2 874 plusTerm(g, 8, 1, 4, s); // 7*u^5*v^6*w^2 + 8*u^4 875 p_Write(g, s); 876 poly h = singclap_gcd(f, g, s); // at least u^3, destroys f and g 877 p_Write(h, s); 878 p_Test(h, s); 879 p_Delete(&h, s); 880 #endif 881 */ 861 882 862 rDelete(s); // kills 'cf' and 'r' as well 883 863 } 864 void test_Q_Ext_s_t() 865 { 866 clog << "Start by creating Q[s, t]..." << endl; 867 868 char* n[] = {"s", "t"}; 869 ring r = rDefault( 0, 2, n); // Q[s, t] 870 TS_ASSERT_DIFFERS( r, NULLp ); 871 872 PrintRing(r); 873 874 TS_ASSERT( rField_is_Domain(r) ); 875 TS_ASSERT( rField_is_Q(r) ); 876 877 TS_ASSERT( !rField_is_Zp(r) ); 878 TS_ASSERT( !rField_is_Zp(r, 17) ); 879 880 TS_ASSERT_EQUALS( rVar(r), 2); 881 882 n_coeffType type = nRegister(n_transExt, ntInitChar); 883 TS_ASSERT(type == n_transExt); 884 885 TransExtInfo extParam; 886 extParam.r = r; 887 888 clog << "Next create the rational function field Q(s, t)..." << endl; 889 890 const coeffs cf = nInitChar(type, &extParam); // Q(s, t) 891 892 if( cf == NULL ) 893 TS_FAIL("Could not get needed coeff. domain"); 894 895 TS_ASSERT_DIFFERS( cf->cfCoeffWrite, NULLp ); 896 897 if( cf->cfCoeffWrite != NULL ) 898 { 899 clog << "Coeff-domain: " << endl; 900 n_CoeffWrite(cf); PrintLn(); 901 } 902 903 TS_ASSERT( !nCoeff_is_algExt(cf) ); 904 TS_ASSERT( nCoeff_is_transExt(cf) ); 905 906 // some tests for the coefficient field represented by cf: 907 TestArithCf(cf); 908 TestSumCf(cf, 10); 909 TestSumCf(cf, 100); 910 TestSumCf(cf, 101); 911 TestSumCf(cf, 1001); 912 TestSumCf(cf, 9000); 913 914 clog << "Finally create the polynomial ring Q(s, t)[x, y, z]..." 915 << endl; 916 917 char* m[] = {"x", "y", "z"}; 918 ring s = rDefault(cf, 3, m); // Q(s, t)[x, y, z] 919 TS_ASSERT_DIFFERS(s, NULLp); 920 921 PrintRing(s); 922 923 TS_ASSERT( rField_is_Domain(s) ); 924 TS_ASSERT( !rField_is_Q(s) ); 925 TS_ASSERT( !rField_is_Zp(s) ); 926 TS_ASSERT( !rField_is_Zp(s, 11) ); 927 TS_ASSERT( !rField_is_Zp(s, 17) ); 928 TS_ASSERT( !rField_is_GF(s) ); 929 TS_ASSERT( rField_is_Extension(s) ); 930 TS_ASSERT( !rField_is_GF(s, 25) ); 931 TS_ASSERT_EQUALS(rVar(s), 3); 932 933 Test(s); 934 935 rDelete(s); // kills 'cf' and 'r' as well 936 } 884 937 }; 885 938
Note: See TracChangeset
for help on using the changeset viewer.