Compare commits

..

No commits in common. "5c5620692f0695b05357e0f1beb8d33afb0d6c16" and "f020d61cbb3b103182337c9cf57daef35dfa0c4a" have entirely different histories.

4 changed files with 242 additions and 344 deletions

36
Cargo.lock generated
View File

@ -148,9 +148,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.4.8"
version = "4.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64"
checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b"
dependencies = [
"clap_builder",
"clap_derive",
@ -158,9 +158,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.4.8"
version = "4.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc"
checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663"
dependencies = [
"anstream",
"anstyle",
@ -333,9 +333,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.7"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8"
checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e"
dependencies = [
"libc",
"windows-sys 0.48.0",
@ -1026,9 +1026,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.25"
version = "0.38.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e"
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
dependencies = [
"bitflags 2.4.1",
"errno",
@ -1063,18 +1063,18 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
[[package]]
name = "serde"
version = "1.0.193"
version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.193"
version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
dependencies = [
"proc-macro2",
"quote",
@ -1118,9 +1118,9 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "smallvec"
version = "1.11.2"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
[[package]]
name = "string-interner"
@ -1544,18 +1544,18 @@ dependencies = [
[[package]]
name = "zerocopy"
version = "0.7.26"
version = "0.7.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0"
checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.26"
version = "0.7.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f"
checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b"
dependencies = [
"proc-macro2",
"quote",

View File

@ -881,33 +881,6 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
Ok(Some(val_toint.into()))
}),
),
create_fn_by_codegen(
primitives,
&var_map,
"np_round",
float,
&[(float, "n")],
Box::new(|ctx, _, _, args, generator| {
let llvm_f64 = ctx.ctx.f64_type();
let arg = args[0].1.clone()
.to_basic_value_enum(ctx, generator, ctx.primitives.float)?;
let intrinsic_fn = ctx.module.get_function("llvm.roundeven.f64").unwrap_or_else(|| {
let fn_type = llvm_f64.fn_type(&[llvm_f64.into()], false);
ctx.module.add_function("llvm.roundeven.f64", fn_type, None)
});
let val = ctx
.builder
.build_call(intrinsic_fn, &[arg.into()], "")
.try_as_basic_value()
.left()
.unwrap();
Ok(Some(val.into()))
}),
),
Arc::new(RwLock::new(TopLevelDef::Function {
name: "range".into(),
simple_name: "range".into(),
@ -1150,33 +1123,6 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
Ok(Some(val_toint.into()))
}),
),
create_fn_by_codegen(
primitives,
&var_map,
"np_floor",
float,
&[(float, "n")],
Box::new(|ctx, _, _, args, generator| {
let llvm_f64 = ctx.ctx.f64_type();
let arg = args[0].1.clone()
.to_basic_value_enum(ctx, generator, ctx.primitives.float)?;
let intrinsic_fn = ctx.module.get_function("llvm.floor.f64").unwrap_or_else(|| {
let fn_type = llvm_f64.fn_type(&[llvm_f64.into()], false);
ctx.module.add_function("llvm.floor.f64", fn_type, None)
});
let val = ctx
.builder
.build_call(intrinsic_fn, &[arg.into()], "")
.try_as_basic_value()
.left()
.unwrap();
Ok(Some(val.into()))
}),
),
create_fn_by_codegen(
primitives,
&var_map,
@ -1237,33 +1183,6 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
Ok(Some(val_toint.into()))
}),
),
create_fn_by_codegen(
primitives,
&var_map,
"np_ceil",
float,
&[(float, "n")],
Box::new(|ctx, _, _, args, generator| {
let llvm_f64 = ctx.ctx.f64_type();
let arg = args[0].1.clone()
.to_basic_value_enum(ctx, generator, ctx.primitives.float)?;
let intrinsic_fn = ctx.module.get_function("llvm.ceil.f64").unwrap_or_else(|| {
let fn_type = llvm_f64.fn_type(&[llvm_f64.into()], false);
ctx.module.add_function("llvm.ceil.f64", fn_type, None)
});
let val = ctx
.builder
.build_call(intrinsic_fn, &[arg.into()], "")
.try_as_basic_value()
.left()
.unwrap();
Ok(Some(val.into()))
}),
),
Arc::new(RwLock::new({
let list_var = primitives.1.get_fresh_var(Some("L".into()), None);
let list = primitives.1.add_ty(TypeEnum::TList { ty: list_var.0 });
@ -1512,7 +1431,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"np_isnan",
"isnan",
boolean,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1532,7 +1451,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"np_isinf",
"isinf",
boolean,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1552,7 +1471,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_sin",
"sin",
float,
&[(float, "x")],
"llvm.sin.f64",
@ -1560,7 +1479,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_cos",
"cos",
float,
&[(float, "x")],
"llvm.cos.f64",
@ -1568,7 +1487,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_exp",
"exp",
float,
&[(float, "x")],
"llvm.exp.f64",
@ -1576,7 +1495,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_exp2",
"exp2",
float,
&[(float, "x")],
"llvm.exp2.f64",
@ -1584,7 +1503,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_log",
"log",
float,
&[(float, "x")],
"llvm.log.f64",
@ -1592,7 +1511,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_log10",
"log10",
float,
&[(float, "x")],
"llvm.log10.f64",
@ -1600,7 +1519,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_log2",
"log2",
float,
&[(float, "x")],
"llvm.log2.f64",
@ -1608,7 +1527,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_fabs",
"fabs",
float,
&[(float, "x")],
"llvm.fabs.f64",
@ -1616,7 +1535,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_sqrt",
"sqrt",
float,
&[(float, "x")],
"llvm.sqrt.f64",
@ -1624,7 +1543,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_rint",
"rint",
float,
&[(float, "x")],
"llvm.roundeven.f64",
@ -1632,7 +1551,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_tan",
"tan",
float,
&[(float, "x")],
"tan",
@ -1641,7 +1560,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_arcsin",
"arcsin",
float,
&[(float, "x")],
"asin",
@ -1650,7 +1569,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_arccos",
"arccos",
float,
&[(float, "x")],
"acos",
@ -1659,7 +1578,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_arctan",
"arctan",
float,
&[(float, "x")],
"atan",
@ -1668,7 +1587,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_sinh",
"sinh",
float,
&[(float, "x")],
"sinh",
@ -1677,7 +1596,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_cosh",
"cosh",
float,
&[(float, "x")],
"cosh",
@ -1686,7 +1605,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_tanh",
"tanh",
float,
&[(float, "x")],
"tanh",
@ -1695,7 +1614,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_arcsinh",
"arcsinh",
float,
&[(float, "x")],
"asinh",
@ -1704,7 +1623,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_arccosh",
"arccosh",
float,
&[(float, "x")],
"acosh",
@ -1713,7 +1632,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_arctanh",
"arctanh",
float,
&[(float, "x")],
"atanh",
@ -1722,7 +1641,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_expm1",
"expm1",
float,
&[(float, "x")],
"expm1",
@ -1731,7 +1650,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_cbrt",
"cbrt",
float,
&[(float, "x")],
"cbrt",
@ -1740,7 +1659,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"sp_spec_erf",
"erf",
float,
&[(float, "z")],
"erf",
@ -1749,7 +1668,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"sp_spec_erfc",
"erfc",
float,
&[(float, "x")],
"erfc",
@ -1758,7 +1677,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"sp_spec_gamma",
"gamma",
float,
&[(float, "z")],
Box::new(|ctx, _, fun, args, generator| {
@ -1776,7 +1695,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"sp_spec_gammaln",
"gammaln",
float,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1794,7 +1713,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_codegen(
primitives,
&var_map,
"sp_spec_j0",
"j0",
float,
&[(float, "x")],
Box::new(|ctx, _, fun, args, generator| {
@ -1812,7 +1731,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"sp_spec_j1",
"j1",
float,
&[(float, "x")],
"j1",
@ -1822,7 +1741,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_arctan2",
"arctan2",
float,
&[(float, "x1"), (float, "x2")],
"atan2",
@ -1831,7 +1750,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_copysign",
"copysign",
float,
&[(float, "x1"), (float, "x2")],
"llvm.copysign.f64",
@ -1839,7 +1758,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_fmax",
"fmax",
float,
&[(float, "x1"), (float, "x2")],
"llvm.maxnum.f64",
@ -1847,7 +1766,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_intrinsic(
primitives,
&var_map,
"np_fmin",
"fmin",
float,
&[(float, "x1"), (float, "x2")],
"llvm.minnum.f64",
@ -1855,7 +1774,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_ldexp",
"ldexp",
float,
&[(float, "x1"), (int32, "x2")],
"ldexp",
@ -1864,7 +1783,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_hypot",
"hypot",
float,
&[(float, "x1"), (float, "x2")],
"hypot",
@ -1873,7 +1792,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
create_fn_by_extern(
primitives,
&var_map,
"np_nextafter",
"nextafter",
float,
&[(float, "x1"), (float, "x2")],
"nextafter",
@ -1916,57 +1835,54 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
"float",
"round",
"round64",
"np_round",
"range",
"str",
"bool",
"floor",
"floor64",
"np_floor",
"ceil",
"ceil64",
"np_ceil",
"len",
"min",
"max",
"abs",
"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",
"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",
"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')
@ -108,55 +108,52 @@ def patch(module):
# Builtin Math functions
module.round = round_away_zero
module.round64 = round_away_zero
module.np_round = np.round
module.floor = math.floor
module.floor64 = math.floor
module.np_floor = np.floor
module.ceil = math.ceil
module.ceil64 = math.ceil
module.np_ceil = np.ceil
# NumPy Math functions
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
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
# SciPy Math Functions
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
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
def file_import(filename, prefix="file_import_"):

View File

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