- Timestamp:
- Feb 24, 2016, 4:38:10 PM (8 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 687bb23a84a85e15ae9f061e66026f6178e92a83
- Parents:
- 7d73a532007715a4f89189b31ac860fe961b9bd580f8f6cd42a3bd43241967f63a3004b77db6d11b
- Location:
- libpolys
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/bigintmat.h
r7d73a53 rca5f5ec 273 273 void extendCols (int i); 274 274 275 bool add(bigintmat *b); ///< Addiert zur Matrix die Matrix b dazu. Return false => an error occur ed275 bool add(bigintmat *b); ///< Addiert zur Matrix die Matrix b dazu. Return false => an error occurred 276 276 bool sub(bigintmat *b); ///< Subtrahiert ... 277 277 bool skalmult(number b, coeffs c); ///< Multipliziert zur Matrix den Skalar b hinzu -
libpolys/coeffs/coeffs.h
r80f8f6c rca5f5ec 613 613 /// raises an error if 'b' is not invertible in r 614 614 /// exception in Z: raises an error if 'a' is not divisible by 'b' 615 /// always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a 615 616 static FORCE_INLINE number n_Div(number a, number b, const coeffs r) 616 617 { STATISTIC(n_Div); assume(r != NULL); assume(r->cfDiv!=NULL); return r->cfDiv(a,b,r); } … … 624 625 625 626 /// for r a field, return n_Init(0,r) 626 /// otherwise: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a 627 /// always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a 628 /// n_IntMod(a,b,r) >=0 627 629 static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r) 628 630 { STATISTIC(n_IntMod); assume(r != NULL); return r->cfIntMod(a,b,r); } -
libpolys/coeffs/longrat.cc
r80f8f6c rca5f5ec 160 160 #define mpz_limb_size(A) ((A)->_mp_size) 161 161 #define mpz_limb_d(A) ((A)->_mp_d) 162 #define MPZ_DIV(A,B,C) mpz_tdiv_q((A),(B),(C))163 #define MPZ_EXACTDIV(A,B,C) mpz_divexact((A),(B),(C))164 162 165 163 void _nlDelete_NoImm(number *a); … … 624 622 long ul; 625 623 mpz_init(tmp); 626 MPZ_DIV(tmp,i->z,i->n);624 mpz_tdiv_q(tmp,i->z,i->n); 627 625 if(mpz_size1(tmp)>MP_SMALL) ul=0; 628 626 else … … 648 646 } 649 647 number tmp=nlRInit(1); 650 MPZ_DIV(tmp->z,i->z,i->n);648 mpz_tdiv_q(tmp->z,i->z,i->n); 651 649 tmp=nlShort3(tmp); 652 650 return tmp; … … 769 767 /* u=a/b */ 770 768 u->s = 3; 771 MPZ_EXACTDIV(u->z,a->z,b->z);769 mpz_divexact(u->z,a->z,b->z); 772 770 if (bb!=NULL) 773 771 { … … 803 801 return nlRInit(POW_2_28); 804 802 } 805 long aa=SR_TO_INT(a); 806 long bb=SR_TO_INT(b); 807 return INT_TO_SR(aa/bb); 808 } 803 LONG aa=SR_TO_INT(a); 804 LONG bb=SR_TO_INT(b); 805 LONG rr=aa%bb; 806 if (rr<0) rr+=ABS(bb); 807 LONG cc=(aa-rr)/bb; 808 return INT_TO_SR(cc); 809 } 810 number aa=NULL; 809 811 if (SR_HDL(a) & SR_INT) 810 812 { … … 817 819 } 818 820 } 819 /* a is a small and b is a large int: -> 0 */820 return INT_TO_SR(0);821 aa=nlRInit(SR_TO_INT(a)); 822 a=aa; 821 823 } 822 824 number bb=NULL; … … 835 837 /* u=u/b */ 836 838 u->s = 3; 837 MPZ_DIV(u->z,u->z,b->z); 839 number rr=nlIntMod(a,b,r); 840 if (SR_HDL(rr) & SR_INT) mpz_sub_ui(u->z,u->z,SR_TO_INT(rr)); 841 else mpz_sub(u->z,u->z,rr->z); 842 mpz_divexact(u->z,u->z,b->z); 843 if (aa!=NULL) 844 { 845 mpz_clear(aa->z); 846 #if defined(LDEBUG) 847 aa->debug=654324; 848 #endif 849 FREE_RNUMBER(aa); 850 } 838 851 if (bb!=NULL) 839 852 { … … 864 877 if (SR_HDL(a) & SR_HDL(b) & SR_INT) 865 878 { 879 LONG aa=SR_TO_INT(a); 866 880 LONG bb=SR_TO_INT(b); 867 LONG c=SR_TO_INT(a) % bb; 881 LONG c=aa % bb; 882 if (c<0) c+=ABS(bb); 868 883 return INT_TO_SR(c); 869 884 } 870 885 if (SR_HDL(a) & SR_INT) 871 886 { 887 LONG ai=SR_TO_INT(a); 872 888 mpz_t aa; 873 mpz_init(aa); 874 mpz_set_si(aa, SR_TO_INT(a)); 889 mpz_init_set_si(aa, ai); 875 890 u=ALLOC_RNUMBER(); 876 891 #if defined(LDEBUG) … … 879 894 u->s = 3; 880 895 mpz_init(u->z); 881 mpz_t q; 882 mpz_init(q); 883 mpz_tdiv_qr(q,u->z, aa, b->z); 884 mpz_clear(q); 896 mpz_mod(u->z, aa, b->z); 885 897 mpz_clear(aa); 886 898 u=nlShort3(u); … … 900 912 mpz_init(u->z); 901 913 u->s = 3; 902 mpz_t q; 903 mpz_init(q); 904 mpz_tdiv_qr(q, u->z, a->z, b->z); 905 mpz_clear(q); 914 mpz_mod(u->z, a->z, b->z); 906 915 if (bb!=NULL) 907 916 { … … 1349 1358 if (mpz_cmp_si(gcd,(long)1)!=0) 1350 1359 { 1351 MPZ_EXACTDIV(x->z,x->z,gcd);1352 MPZ_EXACTDIV(x->n,x->n,gcd);1360 mpz_divexact(x->z,x->z,gcd); 1361 mpz_divexact(x->n,x->n,gcd); 1353 1362 if (mpz_cmp_si(x->n,(long)1)==0) 1354 1363 { … … 1394 1403 mpz_t bt; 1395 1404 mpz_init_set(bt,b->n); 1396 MPZ_EXACTDIV(bt,bt,gcd);1405 mpz_divexact(bt,bt,gcd); 1397 1406 if (SR_HDL(a) & SR_INT) 1398 1407 mpz_mul_si(result->z,bt,SR_TO_INT(a)); … … 1646 1655 if (mpz_cmp_si(gcd,(long)1)!=0) 1647 1656 { 1648 MPZ_EXACTDIV(x->z,x->z,gcd);1649 MPZ_EXACTDIV(x->n,x->n,gcd);1657 mpz_divexact(x->z,x->z,gcd); 1658 mpz_divexact(x->n,x->n,gcd); 1650 1659 if (mpz_cmp_si(x->n,(long)1)==0) 1651 1660 { … … 2803 2812 else 2804 2813 { 2805 if (mpz_isNeg(a->z)) 2806 { 2807 if (mpz_isNeg(b->z)) 2808 { 2809 mpz_add(a->z,a->z,b->z); 2810 } 2811 else 2812 { 2813 mpz_sub(a->z,a->z,b->z); 2814 } 2815 mpz_add_ui(a->z,a->z,1); 2816 } 2817 else 2818 { 2819 if (mpz_isNeg(b->z)) 2820 { 2821 mpz_sub(a->z,a->z,b->z); 2822 } 2823 else 2824 { 2825 mpz_add(a->z,a->z,b->z); 2826 } 2827 mpz_sub_ui(a->z,a->z,1); 2828 } 2829 MPZ_DIV(a->z,a->z,b->z); 2814 number rr=nlIntMod(a,b,r); 2815 if (SR_HDL(rr) & SR_INT) mpz_sub_ui(a->z,a->z,SR_TO_INT(rr)); 2816 else mpz_sub(a->z,a->z,rr->z); 2817 mpz_divexact(a->z,a->z,b->z); 2830 2818 a=nlShort3_noinline(a); 2831 2819 } -
libpolys/misc/auxiliary.h.in
r7d73a53 rca5f5ec 221 221 makes sure that all poly operations in your file are done with 222 222 PDEBUG == 2 223 To break after an error occur ed, set a debugger breakpoint on223 To break after an error occurred, set a debugger breakpoint on 224 224 dErrorBreak. 225 225 */ … … 285 285 Some tips on possible values of OM_TRACK, OM_CHECK, OM_KEEP: 286 286 + To find out about an address that has been freed twice, first locate the 287 file(s) where the error occur ed, and then at the beginning of these files:287 file(s) where the error occurred, and then at the beginning of these files: 288 288 #define OM_CHECK 3 289 289 #define OM_TRACK 5 … … 293 293 Under dynamic scope, do (e.g., from within the debugger): 294 294 om_Opts.MinCheck = 3; om_Opts.MinTrack = 5; omOpts.Keep = LONG_MAX; 295 + to find out where "memory corruption" occur ed, increase value of295 + to find out where "memory corruption" occurred, increase value of 296 296 OM_CHECK - the higher this value is, the more consistency checks are 297 297 done (However a value > 3 checks the entire memory each time an omalloc … … 315 315 defined, then the "real" alloc/realloc/free macros are used, and all 316 316 omTest, omDebug and omCheck routines are undefined 317 + to break after an omError occur ed within a debugger,317 + to break after an omError occurred within a debugger, 318 318 set a breakpoint on dErrorBreak 319 319 + to do checks from within the debugger, or to do checks with explicit -
libpolys/polys/nc/old.gring.cc
r7d73a53 rca5f5ec 3090 3090 if (nc_CallPlural(r->GetNC()->C, r->GetNC()->D, NULL, NULL, res, bSetupQuotient, true, true, r)) 3091 3091 { 3092 WarnS("Error occur ed while coping/setuping the NC structure!"); // No reaction!???3092 WarnS("Error occurred while coping/setuping the NC structure!"); // No reaction!??? 3093 3093 return true; // error 3094 3094 } -
libpolys/polys/pDebug.cc
r7d73a53 rca5f5ec 51 51 fprintf(stderr, "\n// ***dPolyReportError: "); 52 52 vfprintf(stderr, fmt, ap); 53 fprintf(stderr, "\n occur ed at\n");53 fprintf(stderr, "\n occurred at\n"); 54 54 omPrintCurrentBackTraceMax(stderr, 8); 55 55 if (p != NULL) 56 56 { 57 fprintf(stderr, " occur ed for poly: ");57 fprintf(stderr, " occurred for poly: "); 58 58 p_wrp(p, r); 59 59 omPrintAddrInfo(stderr, p, " "); -
libpolys/reporter/dError.cc
r7d73a53 rca5f5ec 59 59 #if !defined(OM_NDEBUG) 60 60 #ifdef omPrintCurrentBackTraceMax 61 fprintf(stderr, " occur ed at: \n");61 fprintf(stderr, " occurred at: \n"); 62 62 omPrintCurrentBackTraceMax(stderr, 8); 63 63 #endif -
libpolys/reporter/reporter.h
r7d73a53 rca5f5ec 109 109 extern int dReportError(const char* fmt, ...); 110 110 #define dReportBug(s) \ 111 dReportError("Bug reported: %s\n occur ed at %s,%d\n", s, __FILE__, __LINE__)111 dReportError("Bug reported: %s\n occurred at %s,%d\n", s, __FILE__, __LINE__) 112 112 113 113 // this is just a dummy procedure which is called after the error
Note: See TracChangeset
for help on using the changeset viewer.