Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8260329: Update references to TAOCP to latest edition
Browse files Browse the repository at this point in the history
Reviewed-by: alanb, bpb
  • Loading branch information
jddarcy committed Jan 25, 2021
1 parent 5b0b24b commit 73c78c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/math/MutableBigInteger.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1166,7 +1166,7 @@ MutableBigInteger divideKnuth(MutableBigInteger b, MutableBigInteger quotient) {
* Calculates the quotient of this div b and places the quotient in the
* provided MutableBigInteger objects and the remainder object is returned.
*
* Uses Algorithm D in Knuth section 4.3.1.
* Uses Algorithm D from Knuth TAOCP Vol. 2, 3rd edition, section 4.3.1.
* Many optimizations to that algorithm have been adapted from the Colin
* Plumb C library.
* It special cases one word divisors for speed. The content of b is not
Expand Down Expand Up @@ -1980,7 +1980,7 @@ MutableBigInteger hybridGCD(MutableBigInteger b) {
* Assumes that this and v are not zero.
*/
private MutableBigInteger binaryGCD(MutableBigInteger v) {
// Algorithm B from Knuth section 4.5.2
// Algorithm B from Knuth TAOCP Vol. 2, 3rd edition, section 4.5.2
MutableBigInteger u = this;
MutableBigInteger r = new MutableBigInteger();

Expand Down
17 changes: 9 additions & 8 deletions src/java.base/share/classes/java/util/Random.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -39,8 +39,9 @@
/**
* An instance of this class is used to generate a stream of
* pseudorandom numbers. The class uses a 48-bit seed, which is
* modified using a linear congruential formula. (See Donald Knuth,
* <i>The Art of Computer Programming, Volume 2</i>, Section 3.2.1.)
* modified using a linear congruential formula. (See Donald E. Knuth,
* <cite>The Art of Computer Programming, Volume 2, Third
* edition: Seminumerical Algorithms</cite>, Section 3.2.1.)
* <p>
* If two instances of {@code Random} are created with the same
* seed, and the same sequence of method calls is made for each, they
Expand Down Expand Up @@ -187,8 +188,8 @@ public synchronized void setSeed(long seed) {
*
* This is a linear congruential pseudorandom number generator, as
* defined by D. H. Lehmer and described by Donald E. Knuth in
* <i>The Art of Computer Programming,</i> Volume 2:
* <i>Seminumerical Algorithms</i>, section 3.2.1.
* <cite>The Art of Computer Programming, Volume 2, Third edition:
* Seminumerical Algorithms</cite>, section 3.2.1.
*
* @param bits random bits
* @return the next pseudorandom value from this random number
Expand Down Expand Up @@ -569,8 +570,8 @@ public double nextDouble() {
* }
* }}</pre>
* This uses the <i>polar method</i> of G. E. P. Box, M. E. Muller, and
* G. Marsaglia, as described by Donald E. Knuth in <i>The Art of
* Computer Programming</i>, Volume 2: <i>Seminumerical Algorithms</i>,
* G. Marsaglia, as described by Donald E. Knuth in <cite>The Art of
* Computer Programming, Volume 2, third edition: Seminumerical Algorithms</cite>,
* section 3.4.1, subsection C, algorithm P. Note that it generates two
* independent values at the cost of only one call to {@code StrictMath.log}
* and one call to {@code StrictMath.sqrt}.
Expand All @@ -581,7 +582,7 @@ public double nextDouble() {
* generator's sequence
*/
public synchronized double nextGaussian() {
// See Knuth, ACP, Section 3.4.1 Algorithm C.
// See Knuth, TAOCP, Vol. 2, 3rd edition, Section 3.4.1 Algorithm C.
if (haveNextNextGaussian) {
haveNextNextGaussian = false;
return nextNextGaussian;
Expand Down

0 comments on commit 73c78c8

Please sign in to comment.