math32

package module
v0.0.0-...-c78ed91 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: 0BSD, BSD-3-Clause Imports: 2 Imported by: 11

README

math32 GoDoc

A float32 version of Go's math package. The majority of code in this library is a thin float32 wrapper over the results of the math package that comes in the standard lib.

The original code is lifted from the Go standard library which is governed by a BSD-style licence which can be found here: https://golang.org/LICENSE.

Documentation

Index

Constants

View Source
const (
	E   = math.E
	Pi  = math.Pi
	Phi = math.Phi

	Sqrt2   = math.Sqrt2
	SqrtE   = math.SqrtE
	SqrtPi  = math.SqrtPi
	SqrtPhi = math.SqrtPhi

	Ln2    = math.Ln2
	Log2E  = 1 / Ln2
	Ln10   = math.Ln10
	Log10E = 1 / Ln10
)

Mathematical constants.

View Source
const (
	MaxFloat32             = 3.40282346638528859811704183484516925440e+38  // 2**127 * (2**24 - 1) / 2**23
	SmallestNonzeroFloat32 = 1.401298464324817070923729583289916131280e-45 // 1 / 2**(127 - 1 + 23)
)

Floating-point limit values. Max is the largest finite value representable by the type. SmallestNonzero is the smallest positive, non-zero value representable by the type.

Variables

View Source
var CosGo = cos

CosGo is the pure Go Cos function.

View Source
var SinGo = sin

SinGo is the pure Go Sin function.

View Source
var TanGo = tan

TanGo is the pure Go Tan function.

Functions

func Abs

func Abs(x float32) float32

Abs returns the absolute value of x.

Special cases are:

Abs(±Inf) = +Inf
Abs(NaN) = NaN

func Acos

func Acos(x float32) float32

func Acosh

func Acosh(x float32) float32

func Asin

func Asin(x float32) float32

func Asinh

func Asinh(x float32) float32

func Atan

func Atan(x float32) float32

func Atan2

func Atan2(x, y float32) float32

func Atanh

func Atanh(x float32) float32

func Cbrt

func Cbrt(x float32) float32

func Ceil

func Ceil(x float32) float32

Ceil returns the least integer value greater than or equal to x.

Special cases are:

Ceil(±0) = ±0
Ceil(±Inf) = ±Inf
Ceil(NaN) = NaN

func Close

func Close(a, b float32) bool

Close approximates equality between a and b with 1e-6 precision.

func ComplexExp

func ComplexExp(x complex64) complex64

func Copysign

func Copysign(x, y float32) float32

Copysign returns a value with the magnitude of x and the sign of y.

func Cos

func Cos(x float32) float32

Cos returns the cosine of the radian argument x.

Special cases are:

Cos(±Inf) = NaN
Cos(NaN) = NaN

func Cosh

func Cosh(x float32) float32

func Dim

func Dim(x, y float32) float32

Dim returns the maximum of x-y or 0.

Special cases are:

Dim(+Inf, +Inf) = NaN
Dim(-Inf, -Inf) = NaN
Dim(x, NaN) = Dim(NaN, x) = NaN

func Erf

func Erf(x float32) float32

func Erfc

func Erfc(x float32) float32

func Exp

func Exp(x float32) float32

func Exp2

func Exp2(x float32) float32

Exp2 returns 2**x, the base-2 exponential of x.

Special cases are the same as Exp.

func Expm1

func Expm1(x float32) float32

Expm1 returns e**x - 1, the base-e exponential of x minus 1. It is more accurate than Exp(x) - 1 when x is near zero.

Special cases are:

Expm1(+Inf) = +Inf
Expm1(-Inf) = -1
Expm1(NaN) = NaN

Very large values overflow to -1 or +Inf.

func Float32bits

func Float32bits(f float32) uint32

Float32bits returns the IEEE 754 binary representation of f.

func Float32frombits

func Float32frombits(b uint32) float32

Float32frombits returns the floating point number corresponding to the IEEE 754 binary representation b.

func Float64bits

func Float64bits(f float64) uint64

Float64bits returns the IEEE 754 binary representation of f.

func Float64frombits

func Float64frombits(b uint64) float64

Float64frombits returns the floating point number corresponding the IEEE 754 binary representation b.

func Floor

func Floor(x float32) float32

Floor returns the greatest integer value less than or equal to x.

Special cases are:

Floor(±0) = ±0
Floor(±Inf) = ±Inf
Floor(NaN) = NaN

func Frexp

func Frexp(f float32) (frac float32, exp int)

Frexp breaks f into a normalized fraction and an integral power of two. It returns frac and exp satisfying f == frac × 2**exp, with the absolute value of frac in the interval [½, 1).

Special cases are:

Frexp(±0) = ±0, 0
Frexp(±Inf) = ±Inf, 0
Frexp(NaN) = NaN, 0

func Gamma

func Gamma(x float32) float32

func Hypot

func Hypot(p, q float32) float32

Hypot returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow.

Special cases are:

Hypot(±Inf, q) = +Inf
Hypot(p, ±Inf) = +Inf
Hypot(NaN, q) = NaN
Hypot(p, NaN) = NaN

func Ilogb

func Ilogb(x float32) int

func Inf

func Inf(sign int) float32

Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.

func IsInf

func IsInf(f float32, sign int) bool

IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.

func IsNaN

func IsNaN(f float32) (is bool)

IsNaN reports whether f is an IEEE 754 “not-a-number” value.

func J0

func J0(x float32) float32

func J1

func J1(x float32) float32

func Jn

func Jn(n int, x float32) float32

func Ldexp

func Ldexp(frac float32, exp int) float32

Ldexp is the inverse of Frexp. It returns frac × 2**exp.

Special cases are:

Ldexp(±0, exp) = ±0
Ldexp(±Inf, exp) = ±Inf
Ldexp(NaN, exp) = NaN

func Lgamma

func Lgamma(x float32) (lgamma float32, sign int)

func Log

func Log(x float32) float32

Log returns the natural logarithm of x.

Special cases are:

Log(+Inf) = +Inf
Log(0) = -Inf
Log(x < 0) = NaN
Log(NaN) = NaN

func Log10

func Log10(x float32) float32

func Log1p

func Log1p(x float32) float32

func Log2

func Log2(x float32) float32

func Logb

func Logb(x float32) float32

func Max

func Max(x, y float32) float32

Max returns the larger of x or y.

Special cases are:

Max(x, +Inf) = Max(+Inf, x) = +Inf
Max(x, NaN) = Max(NaN, x) = NaN
Max(+0, ±0) = Max(±0, +0) = +0
Max(-0, -0) = -0

func Min

func Min(x, y float32) float32

Min returns the smaller of x or y.

Special cases are:

Min(x, -Inf) = Min(-Inf, x) = -Inf
Min(x, NaN) = Min(NaN, x) = NaN
Min(-0, ±0) = Min(±0, -0) = -0

func Mod

func Mod(x, y float32) float32

Mod returns the floating-point remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x.

Special cases are:

Mod(±Inf, y) = NaN
Mod(NaN, y) = NaN
Mod(x, 0) = NaN
Mod(x, ±Inf) = x
Mod(x, NaN) = NaN

func Modf

func Modf(f float32) (int float32, frac float32)

Modf returns integer and fractional floating-point numbers that sum to f. Both values have the same sign as f.

Special cases are:

Modf(±Inf) = ±Inf, NaN
Modf(NaN) = NaN, NaN

func NaN

func NaN() float32

NaN returns an IEEE 754 “not-a-number” value.

func Nextafter

func Nextafter(x, y float32) (r float32)

Nextafter returns the next representable float32 value after x towards y.

Special cases are:

Nextafter32(x, x)   = x
Nextafter32(NaN, y) = NaN
Nextafter32(x, NaN) = NaN

func Pow

func Pow(x, y float32) float32

Pow returns x**y, the base-x exponential of y.

Special cases are (in order):

Pow(x, ±0) = 1 for any x
Pow(1, y) = 1 for any y
Pow(x, 1) = x for any x
Pow(NaN, y) = NaN
Pow(x, NaN) = NaN
Pow(±0, y) = ±Inf for y an odd integer < 0
Pow(±0, -Inf) = +Inf
Pow(±0, +Inf) = +0
Pow(±0, y) = +Inf for finite y < 0 and not an odd integer
Pow(±0, y) = ±0 for y an odd integer > 0
Pow(±0, y) = +0 for finite y > 0 and not an odd integer
Pow(-1, ±Inf) = 1
Pow(x, +Inf) = +Inf for |x| > 1
Pow(x, -Inf) = +0 for |x| > 1
Pow(x, +Inf) = +0 for |x| < 1
Pow(x, -Inf) = +Inf for |x| < 1
Pow(+Inf, y) = +Inf for y > 0
Pow(+Inf, y) = +0 for y < 0
Pow(-Inf, y) = Pow(-0, -y)
Pow(x, y) = NaN for finite x < 0 and finite non-integer y

func Pow10

func Pow10(e int) float32

func Remainder

func Remainder(x, y float32) float32

Remainder returns the IEEE 754 floating-point remainder of x/y.

Special cases are:

Remainder(±Inf, y) = NaN
Remainder(NaN, y) = NaN
Remainder(x, 0) = NaN
Remainder(x, ±Inf) = x
Remainder(x, NaN) = NaN

func Signbit

func Signbit(x float32) bool

Signbit returns true if x is negative or negative zero.

func Sin

func Sin(x float32) float32

Sin returns the sine of the radian argument x.

Special cases are:

Sin(±0) = ±0
Sin(±Inf) = NaN
Sin(NaN) = NaN

func Sinc

func Sinc(x float32) float32

Sinc is the sine cardinal function.Sinc

Sinc(x) = |     1      if x = 0
          | sin(x)/x   otherwise

func Sincos

func Sincos(x float32) (sin, cos float32)

Sincos returns Sin(x), Cos(x).

Special cases are:

Sincos(±0) = ±0, 1
Sincos(±Inf) = NaN, NaN
Sincos(NaN) = NaN, NaN

func Sinh

func Sinh(x float32) float32

func Sqrt

func Sqrt(x float32) float32

Sqrt returns the square root of x. For more information see: https://golang.org/pkg/math/#Sqrt

func Tan

func Tan(x float32) float32

Tan returns the tangent of the radian argument x.

Special cases are:

Tan(±0) = ±0
Tan(±Inf) = NaN
Tan(NaN) = NaN

func Tanh

func Tanh(x float32) float32

func Tolerance

func Tolerance(a, b, epsilon float32) bool

Tolerance approximates equality between a and b within (absolute) epsilon.

func Trunc

func Trunc(x float32) float32

Trunc returns the integer value of x.

Special cases are:

Trunc(±0) = ±0
Trunc(±Inf) = ±Inf
Trunc(NaN) = NaN

func Y0

func Y0(x float32) float32

func Y1

func Y1(x float32) float32

func Yn

func Yn(n int, x float32) float32

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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