mathg

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 2 Imported by: 0

README

mathg

A wrapper of Golang's math package to support generic numbers.

Note: Functions in this package just call the math function with the number casted to float64; this package is not well tested and may or may not function as you expect.

Usage

go get

go get github.com/stefafafan/mathg

You can use many of the math functions with float32, int64, etc.


import "github.com/stefafafan/mathg"

func main() {
    // int abs
    mathg.Abs(123)

    // float abs
    mathg.Abs(123.456)

    // ...
}

Author

stefafafan (GitHub, Twitter)

Documentation

Overview

Package mathg defines generic wrapper functions supplied by the standard math package.

The following functions are not defined since either they are intended to be used for specific types. Float32bits, Float32frombits, Float64bits, Float64frombits, Inf, IsInf, NaN, Nextafter, Nextafter32, Pow10

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T Number](x T) T

Abs is a wrapper of math.Abs.

func Acos

func Acos[T Number](x T) float64

Acos is a wrapper of math.Acos.

func Acosh

func Acosh[T Number](x T) float64

Acosh is a wrapper of math.Acosh.

func Asin

func Asin[T Number](x T) float64

Asin is a wrapper of math.Asin.

func Asinh

func Asinh[T Number](x T) float64

Asinh is a wrapper of math.Asinh.

func Atan

func Atan[T Number](x T) float64

Atan is a wrapper of math.Atan.

func Atan2

func Atan2[T Number](y, x T) float64

Atan2 is a wrapper of math.Atan2.

func Atanh

func Atanh[T Number](x T) float64

Atanh is a wrapper of math.Atanh.

func Cbrt

func Cbrt[T Number](x T) float64

Cbrt is a wrapper of math.Cbrt.

func Ceil

func Ceil[T Number](x T) T

Ceil is a wrapper of math.Ceil.

func Copysign

func Copysign[T Number](f, sign T) T

Copysign is a wrapper of math.Copysign.

func Cos

func Cos[T Number](x T) float64

Cos is a wrapper of math.Cos.

func Cosh

func Cosh[T Number](x T) float64

Cosh is a wrapper of math.Cosh.

func Dim

func Dim[T Number](x, y T) T

Dim is a wrapper of math.Dim.

func Erf

func Erf[T Number](x T) float64

Erf is a wrapper of math.Erf.

func Erfc

func Erfc[T Number](x T) float64

Erfc is a wrapper of math.Erfc.

func Erfcinv

func Erfcinv[T Number](x T) float64

Erfcinv is a wrapper of math.Erfcinv.

func Erfinv

func Erfinv[T Number](x T) float64

Erfinv is a wrapper of math.Erfinv.

func Exp

func Exp[T Number](x T) float64

Exp is a wrapper of math.Exp.

func Exp2

func Exp2[T Number](x T) float64

Exp2 is a wrapper of math.Exp2.

func Expm1

func Expm1[T Number](x T) float64

Expm1 is a wrapper of math.Expm1.

func FMA

func FMA[T Number](x, y, z T) T

FMA is a wrapper of math.FMA.

func Floor

func Floor[T Number](x T) T

Floor is a wrapper of math.Floor.

func Frexp

func Frexp[T Number](x T) (frac float64, exp int)

Frexp is a wrapper of math.Frexp.

func Gamma

func Gamma[T Number](x T) float64

Gamma is a wrapper of math.Gamma.

func Hypot

func Hypot[T Number](p, q T) float64

Hypot is a wrapper of math.Hypot.

func Ilogb

func Ilogb[T Number](x T) int

Ilogb is a wrapper of math.Ilogb.

func IsNaN

func IsNaN[T Number](x T) (is bool)

IsNaN is a wrapper of math.IsNaN.

func J0

func J0[T Number](x T) float64

J0 is a wrapper of math.J0.

func J1

func J1[T Number](x T) float64

J1 is a wrapper of math.J1.

func Jn

func Jn[T Number](n int, x T) float64

Jn is a wrapper of math.Jn.

func Ldexp

func Ldexp[T Number](frac T, exp int) float64

Ldexp is a wrapper of math.Ldexp.

func Lgamma

func Lgamma[T Number](x T) (lgamma float64, sign int)

Lgamma is a wrapper of math.Lgamma.

func Log

func Log[T Number](x T) float64

Log is a wrapper of math.Log.

func Log10

func Log10[T Number](x T) float64

Log10 is a wrapper of math.Log10.

func Log1p

func Log1p[T Number](x T) float64

Log1p is a wrapper of math.Log1p.

func Log2

func Log2[T Number](x T) float64

Log2 is a wrapper of math.Log2.

func Logb

func Logb[T Number](x T) float64

Logb is a wrapper of math.Logb.

func Max

func Max[T Number](x, y T) T

Max is a wrapper of math.Max.

func Min

func Min[T Number](x, y T) T

Min is a wrapper of math.Min.

func Mod

func Mod[T Number](x, y T) float64

Mod is a wrapper of math.Mod.

func Modf

func Modf[T Number](x T) (int float64, frac float64)

Modf is a wrapper of math.Modf.

func Pow

func Pow[T Number](x, y T) float64

Pow is a wrapper of math.Pow.

func Remainder

func Remainder[T Number](x, y T) float64

Remainder is a wrapper of math.Remainder.

func Round

func Round[T Number](x T) T

Round is a wrapper of math.Round.

func RoundToEven

func RoundToEven[T Number](x T) T

RoundToEven is a wrapper of math.RoundToEven.

func Signbit

func Signbit[T Number](x T) bool

Signbit is a wrapper of math.Signbit.

func Sin

func Sin[T Number](x T) float64

Sin is a wrapper of math.Sin.

func Sincos

func Sincos[T Number](x T) (sin, cos float64)

Sincos is a wrapper of math.Sincos.

func Sinh

func Sinh[T Number](x T) float64

Sinh is a wrapper of math.Sinh.

func Sqrt

func Sqrt[T Number](x T) float64

Sqrt is a wrapper of math.Sqrt.

func Tan

func Tan[T Number](x T) float64

Tan is a wrapper of math.Tan.

func Tanh

func Tanh[T Number](x T) float64

Tanh is a wrapper of math.Tanh.

func Trunc

func Trunc[T Number](x T) T

Trunc is a wrapper of math.Trunc.

func Y0

func Y0[T Number](x T) float64

Y0 is a wrapper of math.Y0.

func Y1

func Y1[T Number](x T) float64

Y1 is a wrapper of math.Y1.

func Yn

func Yn[T Number](n int, x T) float64

Yn is a wrapper of math.Yn.

Types

type Number

type Number interface {
	constraints.Float | constraints.Integer
}

A Number type represents a Float or Integer.

Jump to

Keyboard shortcuts

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