Ignore:
Timestamp:
Oct 9, 2009, 8:40:00 PM (10 years ago)
Author:
gz
Message:

Faster bignum multiplication (r12839, r12847, r12850)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-0/l0-bignum64.lisp

    r12048 r12973  
    804804                    (len-b (%bignum-length b))
    805805                    (len-res (+ len-a len-b))
    806                     (res (%allocate-bignum len-res)) )
     806                    (res (%allocate-bignum len-res)))
    807807               (declare (bignum-index len-a len-b len-res))
    808808               (dotimes (i len-a)
    809809                 (declare (type bignum-index i))
    810810                 (%multiply-and-add-loop a b res i len-b))
     811               res))
     812           (multiply-unsigned-bignums64 (a b)
     813             (let* ((len-a (ceiling (%bignum-length a) 2))
     814                    (len-b (ceiling (%bignum-length b) 2))
     815                    (len-res (+ len-a len-b))
     816                    (res (%allocate-bignum (+ len-res len-res))))
     817               (declare (bignum-index len-a len-b len-res))
     818               (dotimes (i len-a)
     819                 (declare (type bignum-index i))
     820                 (%multiply-and-add-loop64 a b res i len-b))
    811821               res)))
    812       (let* ((res (with-negated-bignum-buffers a b multiply-unsigned-bignums)))
     822      (let* ((res (with-negated-bignum-buffers a b
     823                                               multiply-unsigned-bignums64)))
    813824        (if signs-differ (negate-bignum-in-place res))
    814825        (%normalize-bignum-macro res)))))
    815826
    816 
     827(defun multiply-bignum-and-fixnum (bignum fixnum)
     828  (declare (type bignum-type bignum) (fixnum fixnum))
     829  (if (eql fixnum 1)
     830    bignum
     831    (with-small-bignum-buffers ((big-fix fixnum))
     832      (multiply-bignums bignum big-fix))))
     833
     834#+slower
    817835(defun multiply-bignum-and-fixnum (bignum fixnum)
    818836  (declare (type bignum-type bignum) (fixnum fixnum))
Note: See TracChangeset for help on using the changeset viewer.