On this page:
10.1 Parallelization
max-math-threads
10.2 Discrete Fourier Transform Conventions
dft-convention
dft-inverse-convention
10.3 Floating-Point Compliance Testing
test-floating-point
print-fp-test-progress?
8.12

10 Stuff That Doesn’t Belong Anywhere Else🔗ℹ

 (require math/utils) package: math-lib

10.1 Parallelization🔗ℹ

The maximum number of threads a parallelized math function will use. The default value is (max 1 (processor-count)).

10.2 Discrete Fourier Transform Conventions🔗ℹ

parameter

(dft-convention)  (List Real Real)

(dft-convention lst)  void?
  lst : (List Real Real)
A parameter controlling the convention used for scaling discrete Fourier transforms, such as those performed by array-fft. The default value is '(1 -1), which represents the convention used in signal processing.

In general, if lst is (list a b) and n is the length of a transformed array axis or vector, then
  • Each sum is scaled by (expt n (/ (- a 1) 2)).

  • Each exponential in the sum has its argument scaled by b.

Conveniently, a Fourier transform with convention (list (- a) (- b)) is the inverse of a Fourier transform with convention (list a b).

See Mathematica’s documentation on Fourier, from which this excellent idea was stolen.

procedure

(dft-inverse-convention)  (List Real Real)

Returns the convention used for inverse Fourier transforms, given the current convention.

10.3 Floating-Point Compliance Testing🔗ℹ

procedure

(test-floating-point n)  (Listof (List Any Any))

  n : Natural
Runs a comprehensive test of the system’s IEEE 754 (floating-point) compliance, and reports unexpected inaccuracies and errors.

In each test, a function is applied to some carefully chosen values, as well as n additional random values. Its corresponding bigfloat function is applied to the same values, and the answers are compared. Each test returns a list of failures, which are appended and returned.

Each failure in a failure list is formatted

(list (list name args ...) reason)

where name is the name of a function, such as 'fl+, args ... are the arguments it was applied to, and reason is the reason for the failure.

If reason is a flonum, the failure was due to inaccuracy. For example,

(list (list 'fl+ 4.5 2.3) 0.76)

means the result of (fl+ 4.5 2.3) was off by 0.76 ulps.

The threshold for reporting unexpected inaccuracy depends on the function tested. All the arithmetic and irrational functions exported by racket/flonum, for example, must have no more than 0.5 ulps error in order to be compliant.

Two other possible failure reasons are
(list 'different-zero 0.0 -0.0)
(list 'different-zero -0.0 0.0)
The first zero is the answer returned by the function, and the second zero is the expected answer.

Other possible failure reasons have the form

(list 'not-fl2? x y)

meaning that the result (values x y) is not a valid flonum expansion. Such reasons are only given for failures of functions whose names begin with fl2 or contain /error. These functions are currently undocumented, but are used to implement many math/flonum, math/special-functions, and math/distributions functions.

Tests of functions that operate on and return flonum expansions are the strictest tests, requiring hardware arithmetic to be perfectly IEEE 754 compliant. They reliably fail on seemingly innocuous noncompliant behavior, such as computing intermediate results with 80-bit precision.

parameter

(print-fp-test-progress?)  Boolean

(print-fp-test-progress? print?)  void?
  print? : Boolean
When (print-fp-test-progress?) is #t, floating-point tests print and flush a representation of their progress as they run. The default value is #t.