core: Prefix all NumPy/SciPy functions with np_/sp_spec

This commit is contained in:
David Mak 2023-11-23 13:32:08 +08:00
parent 854e33ed48
commit 0af1e37e99
3 changed files with 224 additions and 224 deletions

View File

@ -1431,7 +1431,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"isnan",
"np_isnan",
boolean,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1451,7 +1451,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"isinf",
"np_isinf",
boolean,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1471,7 +1471,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"sin",
"np_sin",
float,
&[(float, "x")],
"llvm.sin.f64",
@ -1479,7 +1479,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"cos",
"np_cos",
float,
&[(float, "x")],
"llvm.cos.f64",
@ -1487,7 +1487,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"exp",
"np_exp",
float,
&[(float, "x")],
"llvm.exp.f64",
@ -1495,7 +1495,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"exp2",
"np_exp2",
float,
&[(float, "x")],
"llvm.exp2.f64",
@ -1503,7 +1503,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"log",
"np_log",
float,
&[(float, "x")],
"llvm.log.f64",
@ -1511,7 +1511,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"log10",
"np_log10",
float,
&[(float, "x")],
"llvm.log10.f64",
@ -1519,7 +1519,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"log2",
"np_log2",
float,
&[(float, "x")],
"llvm.log2.f64",
@ -1527,7 +1527,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"fabs",
"np_fabs",
float,
&[(float, "x")],
"llvm.fabs.f64",
@ -1535,7 +1535,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"sqrt",
"np_sqrt",
float,
&[(float, "x")],
"llvm.sqrt.f64",
@ -1543,7 +1543,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"rint",
"np_rint",
float,
&[(float, "x")],
"llvm.roundeven.f64",
@ -1551,7 +1551,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"tan",
"np_tan",
float,
&[(float, "x")],
"tan",
@ -1560,7 +1560,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"arcsin",
"np_arcsin",
float,
&[(float, "x")],
"asin",
@ -1569,7 +1569,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"arccos",
"np_arccos",
float,
&[(float, "x")],
"acos",
@ -1578,7 +1578,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"arctan",
"np_arctan",
float,
&[(float, "x")],
"atan",
@ -1587,7 +1587,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"sinh",
"np_sinh",
float,
&[(float, "x")],
"sinh",
@ -1596,7 +1596,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"cosh",
"np_cosh",
float,
&[(float, "x")],
"cosh",
@ -1605,7 +1605,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"tanh",
"np_tanh",
float,
&[(float, "x")],
"tanh",
@ -1614,7 +1614,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"arcsinh",
"np_arcsinh",
float,
&[(float, "x")],
"asinh",
@ -1623,7 +1623,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"arccosh",
"np_arccosh",
float,
&[(float, "x")],
"acosh",
@ -1632,7 +1632,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"arctanh",
"np_arctanh",
float,
&[(float, "x")],
"atanh",
@ -1641,7 +1641,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"expm1",
"np_expm1",
float,
&[(float, "x")],
"expm1",
@ -1650,7 +1650,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"cbrt",
"np_cbrt",
float,
&[(float, "x")],
"cbrt",
@ -1659,7 +1659,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"erf",
"sp_spec_erf",
float,
&[(float, "z")],
"erf",
@ -1668,7 +1668,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"erfc",
"sp_spec_erfc",
float,
&[(float, "x")],
"erfc",
@ -1677,7 +1677,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"gamma",
"sp_spec_gamma",
float,
&[(float, "z")],
Box::new(|ctx, _, fun, args, generator| {
@ -1695,7 +1695,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"gammaln",
"sp_spec_gammaln",
float,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1713,7 +1713,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"j0",
"sp_spec_j0",
float,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1731,7 +1731,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"j1",
"sp_spec_j1",
float,
&[(float, "x")],
"j1",
@ -1741,7 +1741,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"arctan2",
"np_arctan2",
float,
&[(float, "x1"), (float, "x2")],
"atan2",
@ -1750,7 +1750,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"copysign",
"np_copysign",
float,
&[(float, "x1"), (float, "x2")],
"llvm.copysign.f64",
@ -1758,7 +1758,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"fmax",
"np_fmax",
float,
&[(float, "x1"), (float, "x2")],
"llvm.maxnum.f64",
@ -1766,7 +1766,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"fmin",
"np_fmin",
float,
&[(float, "x1"), (float, "x2")],
"llvm.minnum.f64",
@ -1774,7 +1774,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"ldexp",
"np_ldexp",
float,
&[(float, "x1"), (int32, "x2")],
"ldexp",
@ -1783,7 +1783,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"hypot",
"np_hypot",
float,
&[(float, "x1"), (float, "x2")],
"hypot",
@ -1792,7 +1792,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"nextafter",
"np_nextafter",
float,
&[(float, "x1"), (float, "x2")],
"nextafter",
@ -1846,43 +1846,43 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
"min",
"max",
"abs",
"isnan",
"isinf",
"sin",
"cos",
"exp",
"exp2",
"log",
"log10",
"log2",
"fabs",
"sqrt",
"rint",
"tan",
"arcsin",
"arccos",
"arctan",
"sinh",
"cosh",
"tanh",
"arcsinh",
"arccosh",
"arctanh",
"expm1",
"cbrt",
"erf",
"erfc",
"gamma",
"gammaln",
"j0",
"j1",
"arctan2",
"copysign",
"fmax",
"fmin",
"ldexp",
"hypot",
"nextafter",
"np_isnan",
"np_isinf",
"np_sin",
"np_cos",
"np_exp",
"np_exp2",
"np_log",
"np_log10",
"np_log2",
"np_fabs",
"np_sqrt",
"np_rint",
"np_tan",
"np_arcsin",
"np_arccos",
"np_arctan",
"np_sinh",
"np_cosh",
"np_tanh",
"np_arcsinh",
"np_arccosh",
"np_arctanh",
"np_expm1",
"np_cbrt",
"sp_spec_erf",
"sp_spec_erfc",
"sp_spec_gamma",
"sp_spec_gammaln",
"sp_spec_j0",
"sp_spec_j1",
"np_arctan2",
"np_copysign",
"np_fmax",
"np_fmin",
"np_ldexp",
"np_hypot",
"np_nextafter",
"Some",
],
)

View File

@ -6,9 +6,9 @@ import importlib.machinery
import math
import numpy as np
import pathlib
import scipy
from numpy import int32, int64, uint32, uint64
from scipy import special
from typing import TypeVar, Generic
T = TypeVar('T')
@ -114,46 +114,46 @@ def patch(module):
module.ceil64 = math.ceil
# NumPy Math functions
module.isnan = np.isnan
module.isinf = np.isinf
module.sin = np.sin
module.cos = np.cos
module.exp = np.exp
module.exp2 = np.exp2
module.log = np.log
module.log10 = np.log10
module.log2 = np.log2
module.fabs = np.fabs
module.trunc = np.trunc
module.sqrt = np.sqrt
module.rint = np.rint
module.tan = np.tan
module.arcsin = np.arcsin
module.arccos = np.arccos
module.arctan = np.arctan
module.sinh = np.sinh
module.cosh = np.cosh
module.tanh = np.tanh
module.arcsinh = np.arcsinh
module.arccosh = np.arccosh
module.arctanh = np.arctanh
module.expm1 = np.expm1
module.cbrt = np.cbrt
module.arctan2 = np.arctan2
module.copysign = np.copysign
module.fmax = np.fmax
module.fmin = np.fmin
module.ldexp = np.ldexp
module.hypot = np.hypot
module.nextafter = np.nextafter
module.np_isnan = np.isnan
module.np_isinf = np.isinf
module.np_sin = np.sin
module.np_cos = np.cos
module.np_exp = np.exp
module.np_exp2 = np.exp2
module.np_log = np.log
module.np_log10 = np.log10
module.np_log2 = np.log2
module.np_fabs = np.fabs
module.np_trunc = np.trunc
module.np_sqrt = np.sqrt
module.np_rint = np.rint
module.np_tan = np.tan
module.np_arcsin = np.arcsin
module.np_arccos = np.arccos
module.np_arctan = np.arctan
module.np_sinh = np.sinh
module.np_cosh = np.cosh
module.np_tanh = np.tanh
module.np_arcsinh = np.arcsinh
module.np_arccosh = np.arccosh
module.np_arctanh = np.arctanh
module.np_expm1 = np.expm1
module.np_cbrt = np.cbrt
module.np_arctan2 = np.arctan2
module.np_copysign = np.copysign
module.np_fmax = np.fmax
module.np_fmin = np.fmin
module.np_ldexp = np.ldexp
module.np_hypot = np.hypot
module.np_nextafter = np.nextafter
# SciPy Math Functions
module.erf = scipy.special.erf
module.erfc = scipy.special.erfc
module.gamma = scipy.special.gamma
module.gammaln = scipy.special.gammaln
module.j0 = scipy.special.j0
module.j1 = scipy.special.j1
module.sp_spec_erf = special.erf
module.sp_spec_erfc = special.erfc
module.sp_spec_gamma = special.gamma
module.sp_spec_gammaln = special.gammaln
module.sp_spec_j0 = special.j0
module.sp_spec_j1 = special.j1
def file_import(filename, prefix="file_import_"):

View File

@ -36,48 +36,48 @@ def test_round64():
for x in [-1.5, -0.5, 0.5, 1.5]:
output_int64(round64(x))
def test_isnan():
def test_np_isnan():
for x in [dbl_nan(), 0.0, dbl_inf()]:
output_bool(isnan(x))
output_bool(np_isnan(x))
def test_isinf():
def test_np_isinf():
for x in [dbl_inf(), -dbl_inf(), 0.0, dbl_nan()]:
output_bool(isinf(x))
output_bool(np_isinf(x))
def test_sin():
def test_np_sin():
pi = dbl_pi()
for x in [-pi, -pi / 2.0, -pi / 4.0, 0.0, pi / 4.0, pi / 2.0, pi, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(sin(x))
output_float64(np_sin(x))
def test_cos():
def test_np_cos():
pi = dbl_pi()
for x in [-pi, -pi / 2.0, -pi / 4.0, 0.0, pi / 4.0, pi / 2.0, pi, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(cos(x))
output_float64(np_cos(x))
def test_exp():
def test_np_exp():
for x in [0.0, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(exp(x))
output_float64(np_exp(x))
def test_exp2():
def test_np_exp2():
for x in [0.0, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(exp2(x))
output_float64(np_exp2(x))
def test_log():
def test_np_log():
e = dbl_e()
for x in [1.0, e, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(log(x))
output_float64(np_log(x))
def test_log10():
def test_np_log10():
for x in [1.0, 10.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(log10(x))
output_float64(np_log10(x))
def test_log2():
def test_np_log2():
for x in [1.0, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(log2(x))
output_float64(np_log2(x))
def test_fabs():
def test_np_fabs():
for x in [-1.0, 0.0, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(fabs(x))
output_float64(np_fabs(x))
def test_floor():
for x in [-1.5, -0.5, 0.5, 1.5]:
@ -95,165 +95,165 @@ def test_ceil64():
for x in [-1.5, -0.5, 0.5, 1.5]:
output_int64(ceil64(x))
def test_sqrt():
def test_np_sqrt():
for x in [1.0, 2.0, 4.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(sqrt(x))
output_float64(np_sqrt(x))
def test_rint():
def test_np_rint():
for x in [-1.5, -0.5, 0.5, 1.5, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(rint(x))
output_float64(np_rint(x))
def test_tan():
def test_np_tan():
pi = dbl_pi()
for x in [-pi, -pi / 2.0, -pi / 4.0, 0.0, pi / 4.0, pi / 2.0, pi, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(tan(x))
output_float64(np_tan(x))
def test_arcsin():
def test_np_arcsin():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(arcsin(x))
output_float64(np_arcsin(x))
def test_arccos():
def test_np_arccos():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(arccos(x))
output_float64(np_arccos(x))
def test_arctan():
def test_np_arctan():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(arctan(x))
output_float64(np_arctan(x))
def test_sinh():
def test_np_sinh():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(sinh(x))
output_float64(np_sinh(x))
def test_cosh():
def test_np_cosh():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(cosh(x))
output_float64(np_cosh(x))
def test_tanh():
def test_np_tanh():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(tanh(x))
output_float64(np_tanh(x))
def test_arcsinh():
def test_np_arcsinh():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(arcsinh(x))
output_float64(np_arcsinh(x))
def test_arccosh():
def test_np_arccosh():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(arccosh(x))
output_float64(np_arccosh(x))
def test_arctanh():
def test_np_arctanh():
for x in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(arctanh(x))
output_float64(np_arctanh(x))
def test_expm1():
def test_np_expm1():
for x in [0.0, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(expm1(x))
output_float64(np_expm1(x))
def test_cbrt():
def test_np_cbrt():
for x in [1.0, 8.0, 27.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(expm1(x))
output_float64(np_expm1(x))
def test_erf():
def test_sp_spec_erf():
for x in [-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(erf(x))
output_float64(sp_spec_erf(x))
def test_erfc():
def test_sp_spec_erfc():
for x in [-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(erfc(x))
output_float64(sp_spec_erfc(x))
def test_gamma():
def test_sp_spec_gamma():
for x in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(gamma(x))
output_float64(sp_spec_gamma(x))
def test_gammaln():
def test_sp_spec_gammaln():
for x in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(gammaln(x))
output_float64(sp_spec_gammaln(x))
def test_j0():
def test_sp_spec_j0():
for x in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(j0(x))
output_float64(sp_spec_j0(x))
def test_j1():
def test_sp_spec_j1():
for x in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0]:
output_float64(j1(x))
output_float64(sp_spec_j1(x))
def test_arctan2():
def test_np_arctan2():
for x1 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
for x2 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(arctan2(x1, x2))
output_float64(np_arctan2(x1, x2))
def test_copysign():
def test_np_copysign():
for x1 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
for x2 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(copysign(x1, x2))
output_float64(np_copysign(x1, x2))
def test_fmax():
def test_np_fmax():
for x1 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
for x2 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(fmax(x1, x2))
output_float64(np_fmax(x1, x2))
def test_fmin():
def test_np_fmin():
for x1 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
for x2 in [-1.0, -0.5, 0.0, 0.5, 1.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(fmin(x1, x2))
output_float64(np_fmin(x1, x2))
def test_ldexp():
def test_np_ldexp():
for x1 in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
for x2 in [-2, -1, 0, 1, 2]:
output_float64(ldexp(x1, x2))
output_float64(np_ldexp(x1, x2))
def test_hypot():
def test_np_hypot():
for x1 in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
for x2 in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(hypot(x1, x2))
output_float64(np_hypot(x1, x2))
def test_nextafter():
def test_np_nextafter():
for x1 in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
for x2 in [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(nextafter(x1, x2))
output_float64(np_nextafter(x1, x2))
def run() -> int32:
test_round()
test_round64()
test_isnan()
test_isinf()
test_sin()
test_cos()
test_exp()
test_exp2()
test_log()
test_log10()
test_log2()
test_fabs()
test_np_isnan()
test_np_isinf()
test_np_sin()
test_np_cos()
test_np_exp()
test_np_exp2()
test_np_log()
test_np_log10()
test_np_log2()
test_np_fabs()
test_floor()
test_floor64()
test_ceil()
test_ceil64()
test_sqrt()
test_rint()
test_tan()
test_arcsin()
test_arccos()
test_arctan()
test_sinh()
test_cosh()
test_tanh()
test_arcsinh()
test_arccosh()
test_arctanh()
test_expm1()
test_cbrt()
test_erf()
test_erfc()
test_gamma()
test_gammaln()
test_j0()
test_j1()
test_arctan2()
test_copysign()
test_fmax()
test_fmin()
test_ldexp()
test_hypot()
test_nextafter()
test_np_sqrt()
test_np_rint()
test_np_tan()
test_np_arcsin()
test_np_arccos()
test_np_arctan()
test_np_sinh()
test_np_cosh()
test_np_tanh()
test_np_arcsinh()
test_np_arccosh()
test_np_arctanh()
test_np_expm1()
test_np_cbrt()
test_sp_spec_erf()
test_sp_spec_erfc()
test_sp_spec_gamma()
test_sp_spec_gammaln()
test_sp_spec_j0()
test_sp_spec_j1()
test_np_arctan2()
test_np_copysign()
test_np_fmax()
test_np_fmin()
test_np_ldexp()
test_np_hypot()
test_np_nextafter()
return 0