Changeset e1634d in git
- Timestamp:
- Jul 3, 2009, 4:38:34 PM (15 years ago)
- Branches:
- (u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
- Children:
- 52696b20f5e20bdcd5f1882fed6a5d8305356070
- Parents:
- 6ea941e4848eccc89aab2b61d4293cb289fe287c
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/rmodulo2m.cc
r6ea941 re1634d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: rmodulo2m.cc,v 1.2 5 2009-07-03 13:14:10 seelischExp $ */4 /* $Id: rmodulo2m.cc,v 1.26 2009-07-03 14:38:34 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: numbers modulo 2^m … … 370 370 */ 371 371 NATNUMBER g = 1; 372 NATNUMBER b_div = b;372 NATNUMBER b_div = (NATNUMBER)b; 373 373 if (b_div < 0) b_div = - b_div; // b_div now represents |b| 374 374 NATNUMBER r = 0; -
kernel/rmodulon.cc
r6ea941 re1634d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: rmodulon.cc,v 1.3 5 2009-07-03 13:14:10 seelischExp $ */4 /* $Id: rmodulon.cc,v 1.36 2009-07-03 14:38:34 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: numbers modulo n … … 338 338 fulfills (1) and (2), i.e. r := t is the correct result. Hence 339 339 in this third case, r is the remainder of division of a by g in Z. 340 Remark: according to mpz_mod: a,b are always non-negative 340 341 */ 341 342 int_number g = (int_number) omAllocBin(gmp_nrn_bin); 342 int_number b_abs = (int_number) omAllocBin(gmp_nrn_bin);343 343 int_number r = (int_number) omAllocBin(gmp_nrn_bin); 344 344 mpz_init(g); 345 mpz_init_set(b_abs,(int_number)b);346 345 mpz_init_set_si(r,(long)0); 347 if (mpz_isNeg(b_abs)) mpz_neg(b_abs, b_abs); // b_abs now represents |b| 348 mpz_gcd(g, (int_number) nrnModul, b_abs); // g is now as above 346 mpz_gcd(g, (int_number) nrnModul, (int_number)b); // g is now as above 349 347 if (mpz_cmp_si(g, (long)1) != 0) mpz_mod(r, (int_number)a, g); // the case g <> 1 350 348 mpz_clear(g); 351 mpz_clear(b_abs);352 349 omFreeBin(g, gmp_nrn_bin); 353 omFreeBin(b_abs, gmp_nrn_bin);354 350 return (number)r; 355 351 }
Note: See TracChangeset
for help on using the changeset viewer.