refmath

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atan2

func Atan2(y, x float64) float64

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 Cos

func Cos(x float64) float64

Cos returns the cosine of x, in radians.

func Cosh

func Cosh(x float64) float64

Cosh returns the hyperbolic cosine of x.

func FMA

func FMA(x, y, z float64) float64

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

func Log2(x float64) float64

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

func Pow(x, y float64) float64

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

func PowI(x float64, n int64, round func(float64) float64) float64

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.

func Sin

func Sin(x float64) float64

Sin returns the sine of x, in radians.

func Sinh

func Sinh(x float64) float64

Sinh returns the hyperbolic sine of x, from Expm1 as FreeBSD's e_sinh.c computes it. The series of math.Sinh for small x is a few units in the last place off.

func Tan

func Tan(x float64) float64

Tan returns the tangent of x, in radians.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL