Changeset bf8a3f in git
- Timestamp:
- May 28, 2014, 11:01:58 AM (9 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 121ad4a2fe86746537b889b9ac969034ed1c0dd1
- Parents:
- d3c0a07150aa1213c3c3b5b69c6e7fcfacd56d73
- git-author:
- Adi Popescu <adi_popescum@yahoo.de>2014-05-28 11:01:58+02:00
- git-committer:
- Adi Popescu <adi_popescum@yahoo.de>2014-05-28 18:02:06+02:00
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/paraplanecurves.lib
rd3c0a0 rbf8a3f 1973 1973 1974 1974 /////////////////////////////////////////////////////////////////////////////// 1975 staticproc polyModP(poly q, bigint p)1975 proc polyModP(poly q, bigint p) 1976 1976 "USAGE: polyModP(q, p); q poly, p bigint 1977 1977 RETURN: takes each coefficient of q modulo p and returns the resulting poly … … 2064 2064 " 2065 2065 { 2066 r;2067 p;2068 gcd(r,p);2069 2066 list L = extgcd(r, p); 2070 2067 if (L[1] != 1) { ERROR("GCD of", r, "and", p, "should be 1."); } -
libpolys/coeffs/longrat.cc
rd3c0a0 rbf8a3f 265 265 if ( SR_HDL(n) & SR_INT ) 266 266 { 267 term = SR_TO_INT(n); 267 int nn=SR_TO_INT(n); 268 if ((long)nn==SR_TO_INT(n)) 269 term = nn; 270 else 271 { 272 mpz_t dummy; 273 mpz_init_set_si(dummy, SR_TO_INT(n)); 274 term = make_cf(dummy); 275 } 268 276 } 269 277 else … … 534 542 nlTest(i, r); 535 543 nlNormalize(i,r); 536 if (SR_HDL(i) & SR_INT) return SR_TO_INT(i); 544 if (SR_HDL(i) & SR_INT) 545 { 546 int dummy = SR_TO_INT(i); 547 if((long)dummy == SR_TO_INT(i)) 548 return SR_TO_INT(i); 549 else 550 return 0; 551 } 537 552 if (i->s==3) 538 553 { … … 563 578 nlTest(i, r); 564 579 nlNormalize(i,r); 565 if (SR_HDL(i) & SR_INT) return (i);580 if (SR_HDL(i) & SR_INT) return (i); 566 581 if (i->s==3) 567 582 { … … 786 801 { 787 802 LONG bb=SR_TO_INT(b); 788 LONG c=SR_TO_INT(a)%bb; 803 LONG c=SR_TO_INT(a) % bb; 804 if(c < 0) 805 { 806 if(bb < 0) 807 c = c - bb; 808 else 809 c = c + bb; 810 } 811 //printf("\nnlIntMod SR_TO_INT\n"); 812 //n_Print(a,r); 813 //printf("\na = %ld\n",SR_TO_INT(a)); 814 //n_Print(b, r); 815 //printf("\nb = %ld\n",bb); 816 //printf("\nc = %ld\n",c); 789 817 return INT_TO_SR(c); 790 818 } 791 819 if (SR_HDL(a) & SR_INT) 792 820 { 793 /* a is a small and b is a large int: -> a */ 794 return a; 821 // a is a small and b is a large int: -> a 822 // INCORRECT, IT COULD HAPPEN THAT B IS A SMALL NUMBER 823 number aa; 824 //mpz_ptr aa=NULL; 825 //aa=(mpz_ptr)omAlloc(sizeof(mpz_t)); 826 aa=ALLOC_RNUMBER(); 827 mpz_init(aa->z); 828 mpz_set_si(aa->z, SR_TO_INT(a)); 829 //mpz_init_set_si(aa,SR_TO_INT(a)); 830 u=ALLOC_RNUMBER(); 831 #if defined(LDEBUG) 832 u->debug=123456; 833 #endif 834 u->s = 3; 835 mpz_init(u->z); 836 mpz_mod(u->z,aa->z,b->z); 837 if (mpz_isNeg(u->z)) 838 { 839 if (mpz_isNeg(b->z)) 840 mpz_sub(u->z,aa->z,b->z); 841 else 842 mpz_add(u->z,aa->z,b->z); 843 } 844 /*if( !n_GreaterZero(a,r) ) 845 { 846 if( !n_GreaterZero(b,r) ) 847 a = r->cfSub(a,b,r); 848 else 849 a = r->cfAdd(a,b,r); 850 }*/ 851 //printf("\nnlIntMod a\n"); 852 //printf("\na = ");n_Print(a,r);printf("\n"); 853 //gmp_printf("\nb = %Zd",b);n_Print(b,r);printf("\n"); 854 //printf("\nc = ");n_Print(a,r);printf("\n"); 855 //gmp_printf("\nc = %Zd",u->z); 856 u=nlShort3(u); 857 nlTest(u,r); 858 return u; 795 859 } 796 860 number bb=NULL; … … 807 871 u->s = 3; 808 872 mpz_mod(u->z,a->z,b->z); 873 //printf("\nnlIntMod mpz_t\n"); 874 //gmp_printf("\na = %Zd\n",a); 875 //n_Print(b, r); 876 //gmp_printf("\nb = %Zd\n",b); 877 //gmp_printf("\nc = %Zd\n",u); 809 878 if (bb!=NULL) 810 879 { … … 2092 2161 assume( getCoeffType(dst) == ID ); 2093 2162 assume( getCoeffType(src) == ID ); 2094 2095 2163 if ((SR_HDL(a) & SR_INT)||(a==NULL)) 2096 2164 { … … 2693 2761 2694 2762 nlInpGcd(cand, n, cf); 2695 2696 2763 assume( nlGreaterZero(cand,cf) ); 2697 2764 -
libpolys/coeffs/mpr_complex.cc
rd3c0a0 rbf8a3f 458 458 if (SR_HDL(num) & SR_INT) 459 459 { 460 r= SR_TO_INT(num); 460 int nn = SR_TO_INT(num); 461 if((long)nn == SR_TO_INT(num)) 462 r = SR_TO_INT(num); 463 else 464 r = gmp_float(SR_TO_INT(num)); 461 465 } 462 466 else
Note: See TracChangeset
for help on using the changeset viewer.