xgo/compiler/stdlib/math.go
2019-01-29 20:46:30 -08:00

74 lines
2.5 KiB
Go

package stdlib
import (
"math"
"github.com/d5/tengo/objects"
)
var mathModule = map[string]objects.Object{
"e": &objects.Float{Value: math.E},
"pi": &objects.Float{Value: math.Pi},
"phi": &objects.Float{Value: math.Phi},
"sqrt2": &objects.Float{Value: math.Sqrt2},
"sqrtE": &objects.Float{Value: math.SqrtE},
"sqrtPi": &objects.Float{Value: math.SqrtPi},
"sqrtPhi": &objects.Float{Value: math.SqrtPhi},
"ln2": &objects.Float{Value: math.Ln2},
"log2E": &objects.Float{Value: math.Log2E},
"ln10": &objects.Float{Value: math.Ln10},
"log10E": &objects.Float{Value: math.Log10E},
"abs": FuncAFRF(math.Abs),
"acos": FuncAFRF(math.Acos),
"acosh": FuncAFRF(math.Acosh),
"asin": FuncAFRF(math.Asin),
"asinh": FuncAFRF(math.Asinh),
"atan": FuncAFRF(math.Atan),
"atan2": FuncAFFRF(math.Atan2),
"atanh": FuncAFRF(math.Atanh),
"cbrt": FuncAFRF(math.Cbrt),
"ceil": FuncAFRF(math.Ceil),
"copysign": FuncAFFRF(math.Copysign),
"cos": FuncAFRF(math.Cos),
"cosh": FuncAFRF(math.Cosh),
"dim": FuncAFFRF(math.Dim),
"erf": FuncAFRF(math.Erf),
"erfc": FuncAFRF(math.Erfc),
"exp": FuncAFRF(math.Exp),
"exp2": FuncAFRF(math.Exp2),
"expm1": FuncAFRF(math.Expm1),
"floor": FuncAFRF(math.Floor),
"gamma": FuncAFRF(math.Gamma),
"hypot": FuncAFFRF(math.Hypot),
"ilogb": FuncAFRI(math.Ilogb),
"inf": FuncAIRF(math.Inf),
"is_inf": FuncAFIRB(math.IsInf),
"is_nan": FuncAFRB(math.IsNaN),
"j0": FuncAFRF(math.J0),
"j1": FuncAFRF(math.J1),
"jn": FuncAIFRF(math.Jn),
"ldexp": FuncAFIRF(math.Ldexp),
"log": FuncAFRF(math.Log),
"log10": FuncAFRF(math.Log10),
"log1p": FuncAFRF(math.Log1p),
"log2": FuncAFRF(math.Log2),
"logb": FuncAFRF(math.Logb),
"max": FuncAFFRF(math.Max),
"min": FuncAFFRF(math.Min),
"mod": FuncAFFRF(math.Mod),
"nan": FuncARF(math.NaN),
"nextafter": FuncAFFRF(math.Nextafter),
"pow": FuncAFFRF(math.Pow),
"pow10": FuncAIRF(math.Pow10),
"remainder": FuncAFFRF(math.Remainder),
"signbit": FuncAFRB(math.Signbit),
"sin": FuncAFRF(math.Sin),
"sinh": FuncAFRF(math.Sinh),
"sqrt": FuncAFRF(math.Sqrt),
"tan": FuncAFRF(math.Tan),
"tanh": FuncAFRF(math.Tanh),
"trunc": FuncAFRF(math.Trunc),
"y0": FuncAFRF(math.Y0),
"y1": FuncAFRF(math.Y1),
"yn": FuncAIFRF(math.Yn),
}