Changeset 31376 in project


Ignore:
Timestamp:
09/11/14 13:22:41 (5 years ago)
Author:
sjamaan
Message:

numbers: Make flonum and fixnum gcd operators more consistently named

Location:
release/4/numbers/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers-c.c

    r31364 r31376  
    499499  BIGNUM_DEALLOCATE(bigy);
    500500  C_return_bignum(k, bigx);
    501 }
    502 
    503 static C_word
    504 C_a_i_flonum_gcd(C_word **p, C_word n, C_word x, C_word y)
    505 {
    506    double xub, yub, r;
    507    
    508    xub = C_flonum_magnitude(x);
    509    yub = C_flonum_magnitude(y);
    510 
    511    if (xub < 0.0) xub = -xub;
    512    if (yub < 0.0) yub = -yub;
    513    
    514    while(yub != 0.0) {
    515      r = fmod(xub, yub);
    516      xub = yub;
    517      yub = r;
    518    }
    519    C_return(C_flonum(p, xub));
    520501}
    521502
     
    15411522}
    15421523
    1543 void C_ccall
    1544 C_fixnum_gcd(C_word c, C_word self, C_word k, C_word x, C_word y)
     1524C_word C_ccall
     1525C_u_i_2_fixnum_gcd(C_word x, C_word y)
    15451526{
    15461527   C_word r;
     
    15571538     y = r;
    15581539   }
    1559    C_kontinue(k, C_fix(x));
     1540   return C_fix(x);
     1541}
     1542
     1543C_word C_ccall
     1544C_a_u_i_2_flonum_gcd(C_word **p, C_word n, C_word x, C_word y)
     1545{
     1546   double xub, yub, r;
     1547   
     1548   xub = C_flonum_magnitude(x);
     1549   yub = C_flonum_magnitude(y);
     1550
     1551   if (xub < 0.0) xub = -xub;
     1552   if (yub < 0.0) yub = -yub;
     1553   
     1554   while(yub != 0.0) {
     1555     r = fmod(xub, yub);
     1556     xub = yub;
     1557     yub = r;
     1558   }
     1559   C_return(C_flonum(p, xub));
    15601560}
    15611561
  • release/4/numbers/trunk/numbers-c.h

    r31364 r31376  
    191191C_word C_ccall C_bignum_normalize(C_word big);
    192192
    193 void C_ccall C_fixnum_gcd(C_word c, C_word self, C_word k, C_word x, C_word y);
     193C_word C_ccall C_u_i_2_fixnum_gcd(C_word x, C_word y);
     194C_word C_ccall C_a_u_i_2_flonum_gcd(C_word **p, C_word n, C_word x, C_word y);
    194195void C_ccall C_u_fixnum_neg(C_word c, C_word self, C_word k, C_word x);
    195196void C_ccall C_u_bignum_negate(C_word c, C_word self, C_word k, C_word x);
  • release/4/numbers/trunk/numbers.scm

    r31364 r31376  
    161161
    162162;; This one should really be part of Chicken, hence the name
    163 (define fxgcd (##core#primitive "C_fixnum_gcd"))
     163(define (fxgcd x y) (##core#inline "C_u_i_2_fixnum_gcd" x y))
    164164(define biggcd (##core#primitive "big_gcd"))
    165 (define (fpgcd x y) (##core#inline_allocate ("C_a_i_flonum_gcd" 4) x y))
     165(define (fpgcd x y) (##core#inline_allocate ("C_a_u_i_2_flonum_gcd" 4) x y))
    166166
    167167(define-inline (%big-cmp x y) (##core#inline "C_u_i_bignum_cmp" x y))
Note: See TracChangeset for help on using the changeset viewer.