Documentation
¶
Overview ¶
Package refmath has the float64 mathematical functions that the Tile IR interpreter and CPU implementations of Tile IR operations compute with as the reference for what a device computes.
This package is outside the compatibility promise of github.com/tmc/lib/nvidia. Its API may change or be removed in patch releases.
Package refmath has the float64 mathematical functions that the Tile IR interpreter and CPU implementations of Tile IR operations compute with as the reference for what a device computes.
Each is the function of package math, replaced where that one is far from the true value: the trigonometric functions of large arguments, Tan of small ones, Log2 near 1, Sinh, Cosh just below overflow, Pow of a large exponent, and Atan2 where the quotient underflows. Compared with a device, package math was the one in error in those places. The results are within a few units in the last place of the true value, not correctly rounded.
PowI and FMA are not functions of package math: they compute what the Tile IR operations fpowi and fma compute.
The import path of this package is provisional: the package may move.
Index ¶
- func Atan2(y, x float64) float64
- func Cos(x float64) float64
- func Cosh(x float64) float64
- func FMA(x, y, z float64) float64
- func Log2(x float64) float64
- func Pow(x, y float64) float64
- func PowI(x float64, n int64, round func(float64) float64) float64
- func Sin(x float64) float64
- func Sinh(x float64) float64
- func Tan(x float64) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Atan2 ¶
Atan2 returns the arc tangent of y/x in the quadrant of the point (x, y). Its sign is that of y, which math.Atan2 loses where y/x underflows to zero and x is negative.
func FMA ¶
FMA returns x*y+z rounded to odd: the exact sum if it is a float64, and otherwise its neighbor whose last bit is set. Rounding that to a narrower format gives what rounding the exact sum would. The product x*y must be exact in float64, as it is for float32 operands.
func Log2 ¶
Log2 returns the base-2 logarithm of x. It is exact for a power of two. math.Log2 adds the exponent of x to the logarithm of its fraction, which near 1 cancels.
func Pow ¶
Pow returns x raised to the power y, with the special cases of math.Pow, which is hundreds of units in the last place off in two places. It squares x once for every bit of the integer part of y, doubling the error each time; and it rounds the logarithm of x before multiplying it by the fraction of y, an error the exponential then magnifies by that product. Pow computes the integer power exactly and takes the logarithm of the fraction of x alone.
func PowI ¶
PowI returns x raised to the integer power n as the Tile IR operation fpowi computes it in a format that round rounds to: by squaring and multiplying, each product rounded, as compiler-rt's __powidf2 does. A negative power is the reciprocal of the positive one: where that one overflows the result is zero, not the subnormal number that x to the n may be.
Types ¶
This section is empty.