Compare commits

..

3 Commits

Author SHA1 Message Date
David Mak 5c5620692f core: Add np_{round,floor,ceil}
These functions are NumPy variants of round/floor/ceil, which returns
floats instead of ints.
2023-11-23 13:45:07 +08:00
David Mak 0af1e37e99 core: Prefix all NumPy/SciPy functions with np_/sp_spec 2023-11-23 13:35:23 +08:00
David Mak 854e33ed48 meta: Update cargo dependencies 2023-11-23 13:31:24 +08:00
4 changed files with 346 additions and 244 deletions

36
Cargo.lock generated
View File

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

View File

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

View File

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

View File

@ -36,48 +36,52 @@ def test_round64():
for x in [-1.5, -0.5, 0.5, 1.5]: for x in [-1.5, -0.5, 0.5, 1.5]:
output_int64(round64(x)) output_int64(round64(x))
def test_isnan(): 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():
for x in [dbl_nan(), 0.0, dbl_inf()]: 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()]: 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() 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()]: 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() 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()]: 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()]: 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()]: 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() e = dbl_e()
for x in [1.0, e, dbl_inf(), -dbl_inf(), dbl_nan()]: 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()]: 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()]: 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()]: 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(): def test_floor():
for x in [-1.5, -0.5, 0.5, 1.5]: for x in [-1.5, -0.5, 0.5, 1.5]:
@ -87,6 +91,10 @@ def test_floor64():
for x in [-1.5, -0.5, 0.5, 1.5]: for x in [-1.5, -0.5, 0.5, 1.5]:
output_int64(floor64(x)) 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(): def test_ceil():
for x in [-1.5, -0.5, 0.5, 1.5]: for x in [-1.5, -0.5, 0.5, 1.5]:
output_int32(ceil(x)) output_int32(ceil(x))
@ -95,165 +103,172 @@ def test_ceil64():
for x in [-1.5, -0.5, 0.5, 1.5]: for x in [-1.5, -0.5, 0.5, 1.5]:
output_int64(ceil64(x)) output_int64(ceil64(x))
def test_sqrt(): def test_np_ceil():
for x in [1.0, 2.0, 4.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(sqrt(x))
def test_rint():
for x in [-1.5, -0.5, 0.5, 1.5, dbl_inf(), -dbl_inf(), dbl_nan()]: for x in [-1.5, -0.5, 0.5, 1.5, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(rint(x)) output_float64(np_ceil(x))
def test_tan(): def test_np_sqrt():
for x in [1.0, 2.0, 4.0, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(np_sqrt(x))
def test_np_rint():
for x in [-1.5, -0.5, 0.5, 1.5, dbl_inf(), -dbl_inf(), dbl_nan()]:
output_float64(np_rint(x))
def test_np_tan():
pi = dbl_pi() 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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()]: 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]: 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 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()]: 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 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()]: 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 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()]: 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 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()]: 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 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]: 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 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()]: 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 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()]: 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: def run() -> int32:
test_round() test_round()
test_round64() test_round64()
test_isnan() test_np_round()
test_isinf() test_np_isnan()
test_sin() test_np_isinf()
test_cos() test_np_sin()
test_exp() test_np_cos()
test_exp2() test_np_exp()
test_log() test_np_exp2()
test_log10() test_np_log()
test_log2() test_np_log10()
test_fabs() test_np_log2()
test_np_fabs()
test_floor() test_floor()
test_floor64() test_floor64()
test_np_floor()
test_ceil() test_ceil()
test_ceil64() test_ceil64()
test_sqrt() test_np_ceil()
test_rint() test_np_sqrt()
test_tan() test_np_rint()
test_arcsin() test_np_tan()
test_arccos() test_np_arcsin()
test_arctan() test_np_arccos()
test_sinh() test_np_arctan()
test_cosh() test_np_sinh()
test_tanh() test_np_cosh()
test_arcsinh() test_np_tanh()
test_arccosh() test_np_arcsinh()
test_arctanh() test_np_arccosh()
test_expm1() test_np_arctanh()
test_cbrt() test_np_expm1()
test_erf() test_np_cbrt()
test_erfc() test_sp_spec_erf()
test_gamma() test_sp_spec_erfc()
test_gammaln() test_sp_spec_gamma()
test_j0() test_sp_spec_gammaln()
test_j1() test_sp_spec_j0()
test_arctan2() test_sp_spec_j1()
test_copysign() test_np_arctan2()
test_fmax() test_np_copysign()
test_fmin() test_np_fmax()
test_ldexp() test_np_fmin()
test_hypot() test_np_ldexp()
test_nextafter() test_np_hypot()
test_np_nextafter()
return 0 return 0