public class RadicalInverse
extends java.lang.Object
We recall that for a k-digit integer i whose digital b-ary expansion is
Note that ψb(i) cannot always be represented exactly as a floating-point number on the computer (e.g., if b is not a power of two). For an exact representation, one can use the integer
It is common practice to permute locally the values of the van der Corput sequence. One way of doing this is to apply a permutation to the digits of i before computing ψb(i). That is, for a permutation π of the digits {0,..., b - 1},
The permutation π can be deterministic or random. One (deterministic)
possibility implemented here is the Faure permutation σb of
{0,..., b - 1} defined as follows.
For b = 2, take
σ = I, the identical permutation. For even
b = 2c > 2, take
| σ[i] | = | 2τ[i] i = 0, 1,…, c - 1 | |
| σ[i + c] | = | 2τ[i] + 1 i = 0, 1,…, c - 1 |
| σ[c] | = | c | |
| σ[i] | = | τ[i], if 0 <= τ[i] < c | |
| σ[i] | = | τ[i] + 1, if c <= τ[i] < 2c |
| σ[i] | = | τ[i - 1], if 0 <= τ[i - 1] < c | |
| σ[i] | = | τ[i - 1] + 1, if c <= τ[i - 1] < 2c |
| Constructor and Description |
|---|
RadicalInverse(int b,
double x0)
Initializes the base of this object to b
and its first value of x to x0.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
getFaurePermutation(int b,
int[] pi)
Computes the Faure permutation σb of the set
{0,…, b - 1} and puts it in array pi.
|
static int[] |
getPrimes(int n)
Provides an elementary method for obtaining the first n prime
numbers larger than 1.
|
static int |
integerRadicalInverse(int b,
int i)
Computes the integer radical inverse of i in base b,
equal to
bkψb(i) if i has k b-ary digits.
|
double |
nextRadicalInverse()
A fast method that incrementally computes the radical inverse xi+1
in base b from xi = ψb(i),
using addition with rigthward carry as described in
Wang and Hickernell.
|
static double |
nextRadicalInverse(double invb,
double x)
A fast method that incrementally computes the radical inverse xi+1
in base b from xi = x = ψb(i),
using addition with rigthward carry.
|
static int |
nextRadicalInverseDigits(int b,
int k,
int[] idigits)
Given the k digits of the integer radical inverse of i in bdigits,
in base b, this method replaces them by the digits of the integer
radical inverse of i + 1 and returns their number.
|
static double |
permutedRadicalInverse(int b,
int[] pi,
int i)
Computes the radical inverse of i in base b, where the digits
are permuted using the permutation π.
|
static double |
radicalInverse(int b,
long i)
Computes the radical inverse of i in base b.
|
static void |
reverseDigits(int k,
int[] bdigits,
int[] idigits)
Given the k b-ary digits of i in bdigits, returns the
k digits of the integer radical inverse of i in idigits.
|
public RadicalInverse(int b,
double x0)
b - Basex0 - Initial value of xpublic static int[] getPrimes(int n)
n - number of prime numbers to returnpublic static double radicalInverse(int b,
long i)
b - base used for the operationi - the value for which the radical inverse will be computedpublic static double nextRadicalInverse(double invb,
double x)
radicalInverse every once in a while (i.e. in every few
thousand calls).invb - 1/b where b is the basex - the inverse xipublic double nextRadicalInverse()
radicalInverse once in every 1000 calls.public static void reverseDigits(int k,
int[] bdigits,
int[] idigits)
k - number of digits in arraysbdigits - digits in original orderidigits - digits in reverse orderpublic static int integerRadicalInverse(int b,
int i)
b - base used for the operationi - the value for which the integer radical inverse will be computedpublic static int nextRadicalInverseDigits(int b,
int k,
int[] idigits)
b - basek - initial number of digits in arraysidigits - digits of integer radical inversepublic static void getFaurePermutation(int b,
int[] pi)
b - the basepi - an array of size at least b,
to be filled with the permutationpublic static double permutedRadicalInverse(int b,
int[] pi,
int i)
b - base b used for the operationpi - an array of length at least b containing the permutation
used during the computationi - the value for which the radical inverse will be computedTo submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.