Changeset 19ee5eb in git
- Timestamp:
- Feb 1, 2021, 1:32:52 PM (2 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'cdfcdb8287f66bc6070028082cbbc6eff10e609b')
- Children:
- 4218c13e2434358d0a056b78d0a40377a11bcdb1
- Parents:
- f60ab1f6c47a09dc3472f9d3cabd270622c46327
- Location:
- libpolys/coeffs
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/flintcf_Qrat.cc
rf60ab1 r19ee5eb 446 446 const fmpq_rat_ptr y = (fmpq_rat_ptr) b; 447 447 const fmpq_ctx_ptr ctx = (fmpq_ctx_ptr) ((data_ptr)c->data)->ctx; 448 if (fmpq_mpoly_is_zero(y->num, ctx))449 {450 WerrorS(nDivBy0);451 return NULL;452 }453 448 fmpq_rat_ptr res = (fmpq_rat_ptr) omAlloc(sizeof(fmpq_rat_struct)); 454 449 fmpq_rat_init(res, c); 450 if (fmpq_mpoly_is_zero(y->num, ctx)) 451 { 452 WerrorS(nDivBy0); 453 return (number)res; 454 } 455 455 if (fmpq_mpoly_equal(x->den, y->num, ctx)) /* denominators equal */ 456 456 { … … 531 531 static number ExactDiv(number a, number b, const coeffs c) 532 532 { 533 fmpq_rat_ptr res = (fmpq_rat_ptr) omAlloc(sizeof(fmpq_rat_struct));534 533 const fmpq_rat_ptr x = (fmpq_rat_ptr) a; 535 534 const fmpq_rat_ptr y = (fmpq_rat_ptr) b; 536 535 const fmpq_ctx_ptr ctx = (fmpq_ctx_ptr) ((data_ptr)c->data)->ctx; 536 fmpq_rat_ptr res = (fmpq_rat_ptr) omAlloc(sizeof(fmpq_rat_struct)); 537 fmpq_rat_init(res, c); 537 538 if (fmpq_mpoly_is_zero(y->num, ctx)) 538 539 { 539 540 WerrorS(nDivBy0); 540 return NULL; 541 } 542 fmpq_rat_init(res, c); 541 return (number)res; 542 } 543 543 fmpq_mpoly_div(res->num, x->num, y->num, ctx); 544 544 assume(fmpq_mpoly_is_one(x->den, ctx)); -
libpolys/coeffs/gnumpc.cc
rf60ab1 r19ee5eb 142 142 { 143 143 WerrorS(nDivBy0); 144 r = new gmp_complex( 0 ); 144 145 } 145 146 else … … 194 195 // a/0 = error 195 196 WerrorS(nDivBy0); 196 return NULL;197 return (number)new gmp_complex( 0 ); 197 198 } 198 199 gmp_complex* res = new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) ); -
libpolys/coeffs/gnumpfl.cc
rf60ab1 r19ee5eb 139 139 { 140 140 WerrorS(nDivBy0); 141 f= new gmp_float( 0 ); 141 142 } 142 143 else … … 186 187 { 187 188 assume( getCoeffType(r) == n_long_R ); 188 189 190 gmp_float* f; 189 191 if ( ((gmp_float*)b)->isZero() ) 190 192 { 191 193 // a/0 = error 192 194 WerrorS(nDivBy0); 193 return NULL; 194 } 195 gmp_float* f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) ); 195 f= new gmp_float( 0 ); 196 } 197 else 198 { 199 f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) ); 200 } 196 201 return (number)f; 197 202 } -
libpolys/coeffs/modulop.cc
rf60ab1 r19ee5eb 234 234 else 235 235 { 236 if ((z==0)&&(n==0)) WerrorS(nDivBy0); 236 if ((z==0)&&(n==0)) 237 { 238 WerrorS(nDivBy0); 239 *a=(number)0L; 240 } 237 241 else 238 242 { -
libpolys/coeffs/rintegers2.cc
rf60ab1 r19ee5eb 227 227 } 228 228 229 static number nrzDiv (number a,number b, const coeffs) 230 { 231 mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin); 232 mpz_init(erg); 233 mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin); 234 mpz_init(r); 235 mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b); 236 //if (!nrzIsZero((number) r, R)) 237 //{ 238 // WerrorS("Division by non divisible element."); 239 // WerrorS("Result is without remainder."); 240 //} 241 mpz_clear(r); 242 omFreeBin(r, gmp_nrz_bin); 243 return (number) erg; 244 } 245 246 static number nrzExactDiv (number a,number b, const coeffs) 247 { 248 mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin); 249 mpz_init(erg); 250 mpz_tdiv_q(erg, (mpz_ptr) a, (mpz_ptr) b); 229 static number nrzDiv (number a,number b, const coeffs r) 230 { 231 mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin); 232 mpz_init(erg); 233 if (nrzIsZero(b,r)) 234 { 235 WerrorS(nDivBy0); 236 } 237 else 238 { 239 mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin); 240 mpz_init(r); 241 mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b); 242 mpz_clear(r); 243 omFreeBin(r, gmp_nrz_bin); 244 } 245 return (number) erg; 246 } 247 248 static number nrzExactDiv (number a,number b, const coeffs r) 249 { 250 mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin); 251 mpz_init(erg); 252 if (nrzIsZero(b,r)) 253 { 254 WerrorS(nDivBy0); 255 } 256 else 257 { 258 mpz_tdiv_q(erg, (mpz_ptr) a, (mpz_ptr) b); 259 } 251 260 return (number) erg; 252 261 } … … 331 340 { 332 341 WerrorS("Non invertible element."); 333 return (number)NULL;342 return nrzInit(0,r); 334 343 } 335 344 return nrzCopy(c,r); -
libpolys/coeffs/rintegers3.cc
rf60ab1 r19ee5eb 744 744 { 745 745 assume(SR_TO_INT(b)); 746 if (n_Z_IS_SMALL(a) && n_Z_IS_SMALL(b)) 746 if (nrzIsZero(b)) 747 { 748 WerrorS(nDivBy0); 749 return INT_TO_SR(0); 750 } 751 else if (n_Z_IS_SMALL(a) && n_Z_IS_SMALL(b)) 747 752 { 748 753 //if (SR_TO_INT(a) % SR_TO_INT(b)) … … 810 815 assume(SR_TO_INT(b)); 811 816 mpz_t aa, bb; 812 if (n_Z_IS_SMALL(a)) 817 if (nrzIsZero(b)) 818 { 819 WerrorS(nDivBy0); 820 return INT_TO_SR(0); 821 } 822 else if (n_Z_IS_SMALL(a)) 813 823 mpz_init_set_si(aa, SR_TO_INT(a)); 814 824 else … … 857 867 { 858 868 WerrorS("Non invertible element."); 859 return (number)NULL;869 return nrzInit(0,r); 860 870 } 861 871 return c; // has to be 1 or -1.... -
libpolys/coeffs/rmodulo2m.cc
rf60ab1 r19ee5eb 412 412 } 413 413 } 414 if ((unsigned long)b % 2 == 0) 414 if ((long)b==0L) 415 { 416 WerrorS(nDivBy0); 417 return (number)0L; 418 } 419 else if ((unsigned long)b % 2 == 0) 415 420 { 416 421 WerrorS("Division not possible, even by cancelling zero divisors."); -
libpolys/coeffs/rmodulon.cc
rf60ab1 r19ee5eb 248 248 mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin); 249 249 mpz_init(erg); 250 mpz_invert(erg, (mpz_ptr)c, r->modNumber); 250 if (nrnIsZero(c,r)) 251 { 252 WerrorS(nDivBy0); 253 } 254 else 255 { 256 mpz_invert(erg, (mpz_ptr)c, r->modNumber); 257 } 251 258 return (number) erg; 252 259 } … … 547 554 static number nrnDiv(number a, number b, const coeffs r) 548 555 { 549 if (r->is_field) 556 if (nrnIsZero(b,r)) 557 { 558 WerrorS(nDivBy0); 559 return nrnInit(0,r); 560 } 561 else if (r->is_field) 550 562 { 551 563 number inv=nrnInvers(b,r); … … 613 625 omFreeBin(g, gmp_nrz_bin); 614 626 return (number)rr; 615 }616 617 static number nrnIntDiv(number a, number b, const coeffs r)618 {619 mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);620 mpz_init(erg);621 mpz_tdiv_q(erg, (mpz_ptr)a, (mpz_ptr)b);622 return (number)erg;623 627 } 624 628
Note: See TracChangeset
for help on using the changeset viewer.