Changeset 42aa8b8 in git
 Timestamp:
 Jun 3, 2014, 6:28:02 PM (9 years ago)
 Branches:
 (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
 Children:
 9e74d36ab6179b1687991fad57ad4613a9816f7cd7295ff2c24f0d2b03594917a387c981bd47eedd
 Parents:
 ee121df974c1705dca6d334a16b69f52ee5fc0d4
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

Singular/links/ssiLink.cc
ree121d r42aa8b8 62 62 // 7>8: qring 63 63 64 // 64 bit version:65 #if SIZEOF_LONG == 866 #define MAX_NUM_SIZE 6067 #define POW_2_28 (1L<<60)68 #define LONG long69 #else70 // 32 bit version:71 #define MAX_NUM_SIZE 2872 #define POW_2_28 (1L<<28)73 #define LONG int74 #endif75 76 64 #define SSI_BASE 16 77 65 typedef struct … … 101 89 { 102 90 // if (currRing!=NULL) 103 // Print("need to change the ring, currRing:%s, switch to: ssiRing%d\n",IDID(currRingHdl ,nr);91 // Print("need to change the ring, currRing:%s, switch to: ssiRing%d\n",IDID(currRingHdl),nr); 104 92 // else 105 93 // Print("no ring, switch to ssiRing%d\n",nr); … … 132 120 void ssiWriteBigInt(const ssiInfo *d, const number n) 133 121 { 134 // syntax is as follows: 135 // case 2 Q: 3 4 <int> 136 // or 3 3 <mpz_t nominator> 137 if(SR_HDL(n) & SR_INT) 138 { 139 fprintf(d>f_write,"4 %ld ",SR_TO_INT(n)); 140 //if (d>f_debug!=NULL) fprintf(d>f_debug,"bigint: short \"%ld\" ",SR_TO_INT(n)); 141 } 142 else if (n>s==3) 143 { 144 fputs("3 ",d>f_write); 145 mpz_out_str(d>f_write,10,n>z); 146 fputc(' ',d>f_write); 147 //gmp_fprintf(d>f_write,"3 %Zd ",n>z); 148 //if (d>f_debug!=NULL) gmp_fprintf(d>f_debug,"bigint: gmp \"%Zd\" ",n>z); 149 } 150 else WerrorS("illiegal bigint"); 122 coeffs_BIGINT>cfWriteFd(n,d>f_write,coeffs_BIGINT); 151 123 } 152 124 … … 161 133 // or 3 5 <mpz_t raw nom.> <mpz_t raw denom.> 162 134 // or 3 6 <mpz_t raw nom.> <mpz_t raw denom.> 163 // or 3 7<mpz_t raw nom.>135 // or 3 8 <mpz_t raw nom.> 164 136 if (getCoeffType(cf)==n_transExt) 165 137 { … … 414 386 } 415 387 416 number ssiReadBigInt(const ssiInfo *d)417 {418 int sub_type=1;419 sub_type=s_readint(d>f_read);420 switch(sub_type)421 {422 case 3:423 {// read int or mpz_t or mpz_t, mpz_t424 number n=nlRInit(0);425 s_readmpz(d>f_read,n>z);426 n>s=sub_type;427 return n;428 }429 case 4:430 {431 int dd;432 dd=s_readint(d>f_read);433 return INT_TO_SR(dd);434 }435 default:436 Werror("error in reading bigint: invalid subtype %d",sub_type);437 return NULL;438 }439 }440 441 388 number ssiReadNumber_CF(const ssiInfo *d, const coeffs cf) 442 389 { … … 461 408 else Werror("coeffs not implemented in ssiReadNumber"); 462 409 return NULL; 410 } 411 412 number ssiReadBigInt(const ssiInfo *d) 413 { 414 number n=ssiReadNumber_CF(d,coeffs_BIGINT); 415 if ((SR_HDL(n) & SR_INT)==0) 416 { 417 if (n>s!=3) Werror("invalid sub type in bigint:%d",n>s); 418 } 419 return n; 463 420 } 464 421 
libpolys/coeffs/longrat.cc
ree121d r42aa8b8 17 17 18 18 // 64 bit version: 19 #if SIZEOF_LONG == 820 //#if 019 //#if SIZEOF_LONG == 8 20 #if 0 21 21 #define MAX_NUM_SIZE 60 22 22 #define POW_2_28 (1L<<60) 23 #define POW_2_28_32 (1L<<28) 23 24 #define LONG long 24 25 #else 25 26 #define MAX_NUM_SIZE 28 26 27 #define POW_2_28 (1L<<28) 28 #define POW_2_28_32 (1L<<28) 27 29 #define LONG int 28 30 #endif … … 802 804 LONG bb=SR_TO_INT(b); 803 805 LONG c=SR_TO_INT(a) % bb; 804 /*if(c < 0)805 {806 if(bb < 0)807 c = c  bb;808 else809 c = c + bb;810 }*/811 /*if((((SR_TO_INT(a)) / (bb))*bb+c) != SR_TO_INT(a))812 {813 printf("\nERROR longrat:819\n");814 printf("\na = %ld\n",SR_TO_INT(a));815 printf("\nb = %ld\n",bb);816 printf("\nc = %ld\n",c);817 }*/818 806 return INT_TO_SR(c); 819 807 } 820 808 if (SR_HDL(a) & SR_INT) 821 809 { 822 // a is a small and b is a large int: > a 823 // INCORRECT, IT COULD HAPPEN THAT b IS A SMALL NUMBER 824 number aa=ALLOC_RNUMBER(); 825 mpz_init(aa>z); 826 mpz_set_si(aa>z, SR_TO_INT(a)); 810 mpz_t aa; 811 mpz_init(aa); 812 mpz_set_si(aa, SR_TO_INT(a)); 827 813 u=ALLOC_RNUMBER(); 828 814 #if defined(LDEBUG) … … 831 817 u>s = 3; 832 818 mpz_init(u>z); 833 mpz_mod(u>z,aa>z,b>z); 834 if (mpz_isNeg(u>z)) 835 { 836 if (mpz_isNeg(b>z)) 837 mpz_sub(u>z,aa>z,b>z); 838 else 839 mpz_add(u>z,aa>z,b>z); 840 } 841 /*mpz_t dummy; 842 mpz_init(dummy); 843 mpz_fdiv_q(dummy, aa>z, b>z); 844 mpz_mul(dummy, dummy, b>z); 845 mpz_add(dummy, dummy, u>z); 846 if(mpz_cmp(dummy,aa>z) != 0) 847 { 848 printf("\nERROR longrat:911\n"); 849 printf("\na = ");n_Print(aa,r); 850 gmp_printf("\ndummy = %Zd",dummy); 851 mpz_clear(dummy);mpz_init(dummy);mpz_tdiv_q(dummy, a>z, b>z); 852 gmp_printf("\na div b = %Zd\n u = ", dummy); 853 n_Print(u,r); 854 } 855 mpz_clear(dummy);*/ 856 mpz_clear(aa>z); 857 #if defined(LDEBUG) 858 aa>debug=654324; 859 #endif 860 FREE_RNUMBER(aa); 819 mpz_mod(u>z,aa,b>z); 820 mpz_clear(aa); 861 821 u=nlShort3(u); 862 822 nlTest(u,r); … … 876 836 u>s = 3; 877 837 mpz_mod(u>z,a>z,b>z); 878 if (mpz_isNeg(u>z))879 {880 if (mpz_isNeg(b>z))881 mpz_sub(u>z,u>z,b>z);882 else883 mpz_add(u>z,u>z,b>z);884 }885 838 if (bb!=NULL) 886 839 { … … 891 844 FREE_RNUMBER(bb); 892 845 } 893 /*mpz_t dummy;894 mpz_init(dummy);895 mpz_fdiv_q(dummy, a>z, b>z);896 mpz_mul(dummy, dummy, b>z);897 mpz_add(dummy, dummy, u>z);898 if(mpz_cmp(dummy,a>z) != 0)899 {900 printf("\nERROR longrat:911\n");901 printf("\na = ");n_Print(a,r);902 gmp_printf("\ndummy = %Zd",dummy);903 mpz_clear(dummy);mpz_init(dummy);mpz_tdiv_q(dummy, a>z, b>z);904 gmp_printf("\na div b = %Zd\n u = ", dummy);905 n_Print(u,r);906 }907 mpz_clear(dummy);*/908 846 u=nlShort3(u); 909 847 nlTest(u,r); … … 1108 1046 nlTest(a, r); 1109 1047 #endif 1110 //if (SR_HDL(a) & SR_INT) return (a==INT_TO_SR(1L));1111 //return FALSE;1112 1048 return (a==INT_TO_SR(1L)); 1113 1049 } … … 2924 2860 #else 2925 2861 long nn=SR_TO_INT(n); 2926 if ((nn<POW_2_28)&&(nn>= POW_2_28)) 2927 fprintf(f,"4 %ld ",nn); 2862 if ((nn<POW_2_28_32)&&(nn>= POW_2_28_32)) 2863 { 2864 int nnn=(int)nn; 2865 fprintf(f,"4 %d ",nnn); 2866 } 2928 2867 else 2929 2868 {
Note: See TracChangeset
for help on using the changeset viewer.