Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
c79b222d
Commit
c79b222d
authored
20 years ago
by
rtoy
Browse files
Options
Downloads
Patches
Plain Diff
o Move definition of MAKE-SMALL-BIGNUM earlier so it can be inlined in
the places where it is used. o Remove old bignum-gcd.
parent
6a5a1c87
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/bignum.lisp
+11
-39
11 additions, 39 deletions
code/bignum.lisp
with
11 additions
and
39 deletions
code/bignum.lisp
+
11
−
39
View file @
c79b222d
...
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/bignum.lisp,v 1.
39
2004/08/
22 15:21:55
rtoy Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/bignum.lisp,v 1.
40
2004/08/
31 00:19:41
rtoy Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -1154,33 +1154,16 @@ down to individual words.")
;;;; GCD.
#+
nil
(
defun
bignum-gcd
(
a
b
)
(
declare
(
type
bignum-type
a
b
))
(
let*
((
a
(
if
(
%bignum-0-or-plusp
a
(
%bignum-length
a
))
a
(
negate-bignum
a
nil
)))
(
b
(
if
(
%bignum-0-or-plusp
b
(
%bignum-length
b
))
b
(
negate-bignum
b
nil
))))
(
declare
(
type
bignum-type
a
b
))
(
when
(
<
a
b
)
(
rotatef
a
b
))
;; While the length difference of A and B is sufficiently large,
;; reduce using MOD (slowish, but it should equalize the sizes of
;; A and B pretty quickly). After that, use the binary GCD
;; algorithm to handle the rest. This gives a very large speedup
;; in cl-bench.
(
loop
until
(
and
(
=
(
%bignum-length
b
)
1
)
(
zerop
(
%bignum-ref
b
0
)))
do
(
when
(
<=
(
%bignum-length
a
)
(
1+
(
%bignum-length
b
)))
(
return-from
bignum-gcd
(
bignum-binary-gcd
a
b
)))
(
let
((
rem
(
mod
a
b
)))
(
if
(
fixnump
rem
)
(
setf
a
(
make-small-bignum
rem
))
(
setf
a
rem
))
(
rotatef
a
b
)))
a
))
;;; MAKE-SMALL-BIGNUM -- Public.
;;;
;;; Allocate a single word bignum that holds fixnum. This is useful when
;;; we are trying to mix fixnum and bignum operands.
;;;
(
declaim
(
inline
make-small-bignum
))
(
defun
make-small-bignum
(
fixnum
)
(
let
((
res
(
%allocate-bignum
1
)))
(
setf
(
%bignum-ref
res
0
)
(
%fixnum-to-digit
fixnum
))
res
))
(
eval-when
(
:compile-toplevel
:load-toplevel
:execute
)
;; The asserts in the GCD implementation are way too expensive to
...
...
@@ -3598,17 +3581,6 @@ friends is working.
;;;; General utilities.
;;; MAKE-SMALL-BIGNUM -- Public.
;;;
;;; Allocate a single word bignum that holds fixnum. This is useful when
;;; we are trying to mix fixnum and bignum operands.
;;;
(
declaim
(
inline
make-small-bignum
))
(
defun
make-small-bignum
(
fixnum
)
(
let
((
res
(
%allocate-bignum
1
)))
(
setf
(
%bignum-ref
res
0
)
(
%fixnum-to-digit
fixnum
))
res
))
;;; %NORMALIZE-BIGNUM-BUFFER -- Internal.
;;;
;;; Internal in-place operations use this to fixup remaining digits in the
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment