siderust-js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +166 -0
- package/.gitmodules +9 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +661 -0
- package/README.md +138 -0
- package/package.json +12 -0
- package/qtty-js/.github/workflows/ci.yml +151 -0
- package/qtty-js/.gitmodules +3 -0
- package/qtty-js/CHANGELOG.md +31 -0
- package/qtty-js/LICENSE +661 -0
- package/qtty-js/README.md +132 -0
- package/qtty-js/package.json +20 -0
- package/qtty-js/qtty/.github/workflows/ci.yml +155 -0
- package/qtty-js/qtty/CHANGELOG.md +120 -0
- package/qtty-js/qtty/Cargo.lock +1462 -0
- package/qtty-js/qtty/Cargo.toml +12 -0
- package/qtty-js/qtty/LICENSE +661 -0
- package/qtty-js/qtty/README.md +9 -0
- package/qtty-js/qtty/qtty/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty/README.md +8 -0
- package/qtty-js/qtty/qtty/examples/angles.rs +14 -0
- package/qtty-js/qtty/qtty/examples/astronomy.rs +17 -0
- package/qtty-js/qtty/qtty/examples/dimensional_arithmetic.rs +83 -0
- package/qtty-js/qtty/qtty/examples/python_integration.rs +61 -0
- package/qtty-js/qtty/qtty/examples/quickstart.rs +15 -0
- package/qtty-js/qtty/qtty/examples/ratios.rs +12 -0
- package/qtty-js/qtty/qtty/examples/serde_with_unit.rs +234 -0
- package/qtty-js/qtty/qtty/examples/serialization.rs +141 -0
- package/qtty-js/qtty/qtty/examples/serialization_advanced.rs +155 -0
- package/qtty-js/qtty/qtty/src/f32.rs +108 -0
- package/qtty-js/qtty/qtty/src/f64.rs +30 -0
- package/qtty-js/qtty/qtty/src/i128.rs +111 -0
- package/qtty-js/qtty/qtty/src/i16.rs +111 -0
- package/qtty-js/qtty/qtty/src/i32.rs +111 -0
- package/qtty-js/qtty/qtty/src/i64.rs +111 -0
- package/qtty-js/qtty/qtty/src/i8.rs +111 -0
- package/qtty-js/qtty/qtty/src/lib.rs +238 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/src/lib.rs +5 -0
- package/qtty-js/qtty/qtty/tests/integration_tests.rs +529 -0
- package/qtty-js/qtty/qtty/tests/qtty_vec_feature_matrix.rs +58 -0
- package/qtty-js/qtty/qtty-core/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty-core/README.md +8 -0
- package/qtty-js/qtty/qtty-core/examples/diesel_integration.rs +145 -0
- package/qtty-js/qtty/qtty-core/examples/quantity_db_serde.rs +215 -0
- package/qtty-js/qtty/qtty-core/src/dimension.rs +249 -0
- package/qtty-js/qtty/qtty-core/src/feature_diesel.rs +318 -0
- package/qtty-js/qtty/qtty-core/src/feature_pyo3.rs +27 -0
- package/qtty-js/qtty/qtty-core/src/feature_serde.rs +203 -0
- package/qtty-js/qtty/qtty-core/src/feature_tiberius.rs +28 -0
- package/qtty-js/qtty/qtty-core/src/lib.rs +744 -0
- package/qtty-js/qtty/qtty-core/src/macros.rs +93 -0
- package/qtty-js/qtty/qtty-core/src/quantity.rs +810 -0
- package/qtty-js/qtty/qtty-core/src/scalar.rs +1742 -0
- package/qtty-js/qtty/qtty-core/src/unit.rs +332 -0
- package/qtty-js/qtty/qtty-core/src/units/angular.rs +1228 -0
- package/qtty-js/qtty/qtty-core/src/units/area.rs +243 -0
- package/qtty-js/qtty/qtty-core/src/units/frequency.rs +179 -0
- package/qtty-js/qtty/qtty-core/src/units/length.rs +1270 -0
- package/qtty-js/qtty/qtty-core/src/units/mass.rs +488 -0
- package/qtty-js/qtty/qtty-core/src/units/mod.rs +26 -0
- package/qtty-js/qtty/qtty-core/src/units/power.rs +324 -0
- package/qtty-js/qtty/qtty-core/src/units/time.rs +667 -0
- package/qtty-js/qtty/qtty-core/src/units/unitless.rs +212 -0
- package/qtty-js/qtty/qtty-core/src/units/velocity.rs +210 -0
- package/qtty-js/qtty/qtty-core/src/units/volume.rs +269 -0
- package/qtty-js/qtty/qtty-core/tests/core.rs +628 -0
- package/qtty-js/qtty/qtty-core/tests/diesel.rs +461 -0
- package/qtty-js/qtty/qtty-core/tests/integers.rs +632 -0
- package/qtty-js/qtty/qtty-core/tests/no_cross_unit_ops.rs +35 -0
- package/qtty-js/qtty/qtty-core/tests/pyo3.rs +334 -0
- package/qtty-js/qtty/qtty-core/tests/quantity_f32.rs +276 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_decimal.rs +258 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f32.rs +286 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f64_real.rs +287 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_rational.rs +260 -0
- package/qtty-js/qtty/qtty-core/tests/serde.rs +256 -0
- package/qtty-js/qtty/qtty-core/tests/tiberius.rs +208 -0
- package/qtty-js/qtty/qtty-derive/Cargo.toml +23 -0
- package/qtty-js/qtty/qtty-derive/README.md +8 -0
- package/qtty-js/qtty/qtty-derive/src/lib.rs +340 -0
- package/qtty-js/qtty/qtty-ffi/ARCHITECTURE.md +3 -0
- package/qtty-js/qtty/qtty-ffi/Cargo.toml +31 -0
- package/qtty-js/qtty/qtty-ffi/README.md +9 -0
- package/qtty-js/qtty/qtty-ffi/build.rs +326 -0
- package/qtty-js/qtty/qtty-ffi/cbindgen.toml +105 -0
- package/qtty-js/qtty/qtty-ffi/include/qtty_ffi.h +1126 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi.rs +1251 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi_serde.rs +294 -0
- package/qtty-js/qtty/qtty-ffi/src/helpers.rs +310 -0
- package/qtty-js/qtty/qtty-ffi/src/lib.rs +229 -0
- package/qtty-js/qtty/qtty-ffi/src/macros.rs +121 -0
- package/qtty-js/qtty/qtty-ffi/src/registry.rs +274 -0
- package/qtty-js/qtty/qtty-ffi/src/types.rs +620 -0
- package/qtty-js/qtty/qtty-ffi/tests/integration_tests.rs +842 -0
- package/qtty-js/qtty/qtty-ffi/units.csv +156 -0
- package/qtty-js/qtty/qtty-ffi/units.csv.md +3 -0
- package/qtty-js/qtty-node/.prettierignore +6 -0
- package/qtty-js/qtty-node/.prettierrc.json +6 -0
- package/qtty-js/qtty-node/README.md +250 -0
- package/qtty-js/qtty-node/c8.config.json +11 -0
- package/qtty-js/qtty-node/eslint.config.js +31 -0
- package/qtty-js/qtty-node/examples/arithmetic.mjs +64 -0
- package/qtty-js/qtty-node/examples/astronomy.mjs +90 -0
- package/qtty-js/qtty-node/examples/quickstart.mjs +36 -0
- package/qtty-js/qtty-node/examples/serialization.mjs +125 -0
- package/qtty-js/qtty-node/examples/unit_factories.mjs +74 -0
- package/qtty-js/qtty-node/index.d.ts +219 -0
- package/qtty-js/qtty-node/index.js +323 -0
- package/qtty-js/qtty-node/lib/DerivedQuantity.js +122 -0
- package/qtty-js/qtty-node/lib/Quantity.js +151 -0
- package/qtty-js/qtty-node/lib/backend.js +25 -0
- package/qtty-js/qtty-node/native.cjs +306 -0
- package/qtty-js/qtty-node/package-lock.json +3223 -0
- package/qtty-js/qtty-node/package.json +70 -0
- package/qtty-js/qtty-node/units.d.ts +299 -0
- package/qtty-js/qtty-node/units.js +210 -0
- package/qtty-js/qtty-web/Cargo.lock +767 -0
- package/qtty-js/qtty-web/Cargo.toml +21 -0
- package/qtty-js/qtty-web/index.d.ts +140 -0
- package/qtty-js/qtty-web/index.js +20 -0
- package/qtty-js/qtty-web/lib/DerivedQuantity.js +58 -0
- package/qtty-js/qtty-web/lib/Quantity.js +75 -0
- package/qtty-js/qtty-web/lib/backend.js +80 -0
- package/qtty-js/qtty-web/package.json +45 -0
- package/qtty-js/qtty-web/src/lib.rs +111 -0
- package/qtty-js/scripts/ci.sh +73 -0
- package/scripts/ci.sh +123 -0
- package/siderust-core/Cargo.lock +787 -0
- package/siderust-core/Cargo.toml +18 -0
- package/siderust-core/DEDUPLICATION.md +124 -0
- package/siderust-core/src/body.rs +120 -0
- package/siderust-core/src/events.rs +184 -0
- package/siderust-core/src/lib.rs +20 -0
- package/siderust-core/src/observer.rs +55 -0
- package/siderust-core/src/position.rs +213 -0
- package/siderust-node/.prettierignore +7 -0
- package/siderust-node/.prettierrc.json +6 -0
- package/siderust-node/Cargo.lock +906 -0
- package/siderust-node/Cargo.toml +29 -0
- package/siderust-node/README.md +109 -0
- package/siderust-node/__test__/index.test.mjs +248 -0
- package/siderust-node/build.rs +5 -0
- package/siderust-node/c8.config.json +3 -0
- package/siderust-node/eslint.config.js +31 -0
- package/siderust-node/examples/01_basic_coordinates.mjs +24 -0
- package/siderust-node/examples/02_coordinate_transformations.mjs +25 -0
- package/siderust-node/examples/03_all_frames_conversions.mjs +26 -0
- package/siderust-node/examples/04_all_center_conversions.mjs +24 -0
- package/siderust-node/examples/05_target_tracking.mjs +22 -0
- package/siderust-node/examples/06_night_events.mjs +18 -0
- package/siderust-node/examples/07_moon_properties.mjs +21 -0
- package/siderust-node/examples/08_solar_system.mjs +19 -0
- package/siderust-node/examples/09_star_observability.mjs +22 -0
- package/siderust-node/examples/10_time_periods.mjs +9 -0
- package/siderust-node/examples/11_serialization.mjs +31 -0
- package/siderust-node/examples/12_runtime_ephemeris.mjs +27 -0
- package/siderust-node/examples/13_coordinate_operations.mjs +20 -0
- package/siderust-node/index.d.ts +623 -0
- package/siderust-node/index.js +79 -0
- package/siderust-node/lib/Observer.js +112 -0
- package/siderust-node/lib/Star.js +118 -0
- package/siderust-node/lib/backend.js +63 -0
- package/siderust-node/lib/wrappers.js +566 -0
- package/siderust-node/main.js +20 -0
- package/siderust-node/native.cjs +360 -0
- package/siderust-node/package-lock.json +3261 -0
- package/siderust-node/package.json +71 -0
- package/siderust-node/src/body.rs +74 -0
- package/siderust-node/src/coordinates.rs +372 -0
- package/siderust-node/src/ephemeris.rs +462 -0
- package/siderust-node/src/events.rs +577 -0
- package/siderust-node/src/lib.rs +43 -0
- package/siderust-node/src/observer.rs +132 -0
- package/siderust-node/src/phase.rs +218 -0
- package/siderust-node/src/position.rs +292 -0
- package/siderust-node/src/star.rs +200 -0
- package/siderust-web/Cargo.lock +855 -0
- package/siderust-web/Cargo.toml +34 -0
- package/siderust-web/README.md +100 -0
- package/siderust-web/__test__/index.test.mjs +118 -0
- package/siderust-web/examples/github-pages/README.md +31 -0
- package/siderust-web/examples/github-pages/index.html +135 -0
- package/siderust-web/index.d.ts +311 -0
- package/siderust-web/index.js +66 -0
- package/siderust-web/lib/Observer.js +103 -0
- package/siderust-web/lib/Star.js +116 -0
- package/siderust-web/lib/backend.js +400 -0
- package/siderust-web/lib/wrappers.js +512 -0
- package/siderust-web/package.json +55 -0
- package/siderust-web/src/body.rs +69 -0
- package/siderust-web/src/coordinates.rs +302 -0
- package/siderust-web/src/ephemeris.rs +456 -0
- package/siderust-web/src/events.rs +520 -0
- package/siderust-web/src/lib.rs +51 -0
- package/siderust-web/src/observer.rs +117 -0
- package/siderust-web/src/phase.rs +190 -0
- package/siderust-web/src/position.rs +291 -0
- package/siderust-web/src/star.rs +178 -0
- package/tempoch-js/.github/workflows/ci.yml +142 -0
- package/tempoch-js/.gitmodules +3 -0
- package/tempoch-js/CHANGELOG.md +25 -0
- package/tempoch-js/LICENSE +661 -0
- package/tempoch-js/README.md +126 -0
- package/tempoch-js/package.json +20 -0
- package/tempoch-js/scripts/ci.sh +73 -0
- package/tempoch-js/tempoch/.github/workflows/ci.yml +113 -0
- package/tempoch-js/tempoch/CHANGELOG.md +82 -0
- package/tempoch-js/tempoch/Cargo.lock +947 -0
- package/tempoch-js/tempoch/Cargo.toml +3 -0
- package/tempoch-js/tempoch/LICENSE +661 -0
- package/tempoch-js/tempoch/README.md +76 -0
- package/tempoch-js/tempoch/tempoch/Cargo.toml +27 -0
- package/tempoch-js/tempoch/tempoch/examples/periods.rs +45 -0
- package/tempoch-js/tempoch/tempoch/examples/quickstart.rs +13 -0
- package/tempoch-js/tempoch/tempoch/src/lib.rs +49 -0
- package/tempoch-js/tempoch/tempoch/tests/integration.rs +57 -0
- package/tempoch-js/tempoch/tempoch-core/Cargo.toml +24 -0
- package/tempoch-js/tempoch/tempoch-core/src/delta_t.rs +345 -0
- package/tempoch-js/tempoch/tempoch-core/src/instant.rs +811 -0
- package/tempoch-js/tempoch/tempoch-core/src/julian_date_ext.rs +142 -0
- package/tempoch-js/tempoch/tempoch-core/src/lib.rs +81 -0
- package/tempoch-js/tempoch/tempoch-core/src/period.rs +1168 -0
- package/tempoch-js/tempoch/tempoch-core/src/scales.rs +779 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.lock +889 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.toml +26 -0
- package/tempoch-js/tempoch/tempoch-ffi/build.rs +24 -0
- package/tempoch-js/tempoch/tempoch-ffi/cbindgen.toml +30 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/error.rs +19 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/lib.rs +82 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/period.rs +101 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/time.rs +711 -0
- package/tempoch-js/tempoch/tempoch-ffi/tests/ffi.rs +265 -0
- package/tempoch-js/tempoch-node/.prettierignore +6 -0
- package/tempoch-js/tempoch-node/.prettierrc.json +6 -0
- package/tempoch-js/tempoch-node/Cargo.lock +496 -0
- package/tempoch-js/tempoch-node/Cargo.toml +29 -0
- package/tempoch-js/tempoch-node/README.md +265 -0
- package/tempoch-js/tempoch-node/__test__/index.test.mjs +598 -0
- package/tempoch-js/tempoch-node/build.rs +5 -0
- package/tempoch-js/tempoch-node/c8.config.json +3 -0
- package/tempoch-js/tempoch-node/eslint.config.js +31 -0
- package/tempoch-js/tempoch-node/examples/periods.mjs +79 -0
- package/tempoch-js/tempoch-node/examples/quickstart.mjs +71 -0
- package/tempoch-js/tempoch-node/examples/timescales.mjs +92 -0
- package/tempoch-js/tempoch-node/index.d.ts +280 -0
- package/tempoch-js/tempoch-node/index.js +32 -0
- package/tempoch-js/tempoch-node/lib/JulianDate.js +176 -0
- package/tempoch-js/tempoch-node/lib/ModifiedJulianDate.js +156 -0
- package/tempoch-js/tempoch-node/lib/Period.js +133 -0
- package/tempoch-js/tempoch-node/lib/backend.js +38 -0
- package/tempoch-js/tempoch-node/lib/qttyCompat.js +92 -0
- package/tempoch-js/tempoch-node/native.cjs +317 -0
- package/tempoch-js/tempoch-node/package-lock.json +3223 -0
- package/tempoch-js/tempoch-node/package.json +56 -0
- package/tempoch-js/tempoch-node/src/lib.rs +573 -0
- package/tempoch-js/tempoch-web/Cargo.toml +23 -0
- package/tempoch-js/tempoch-web/index.d.ts +95 -0
- package/tempoch-js/tempoch-web/index.js +27 -0
- package/tempoch-js/tempoch-web/lib/JulianDate.js +170 -0
- package/tempoch-js/tempoch-web/lib/ModifiedJulianDate.js +145 -0
- package/tempoch-js/tempoch-web/lib/Period.js +121 -0
- package/tempoch-js/tempoch-web/lib/backend.js +118 -0
- package/tempoch-js/tempoch-web/package.json +46 -0
- package/tempoch-js/tempoch-web/src/lib.rs +184 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#![cfg(feature = "scalar-decimal")]
|
|
2
|
+
|
|
3
|
+
use qtty_core::length::Meter;
|
|
4
|
+
use qtty_core::scalar::{Exact, Real, Scalar};
|
|
5
|
+
use qtty_core::Quantity;
|
|
6
|
+
use rust_decimal::Decimal;
|
|
7
|
+
|
|
8
|
+
#[test]
|
|
9
|
+
fn test_decimal_scalar_basic() {
|
|
10
|
+
assert_eq!(Decimal::ZERO, Decimal::from(0));
|
|
11
|
+
assert_eq!(Decimal::ONE, Decimal::from(1));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
fn test_decimal_abs() {
|
|
16
|
+
let val = Decimal::from(-5);
|
|
17
|
+
assert_eq!(Scalar::abs(val), Decimal::from(5));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[test]
|
|
21
|
+
fn test_decimal_min_max() {
|
|
22
|
+
let a = Decimal::from(3);
|
|
23
|
+
let b = Decimal::from(7);
|
|
24
|
+
assert_eq!(Scalar::min(a, b), Decimal::from(3));
|
|
25
|
+
assert_eq!(Scalar::max(a, b), Decimal::from(7));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[test]
|
|
29
|
+
fn test_decimal_rem_euclid() {
|
|
30
|
+
let val = Decimal::from(17);
|
|
31
|
+
let modulus = Decimal::from(5);
|
|
32
|
+
assert_eq!(Scalar::rem_euclid(val, modulus), Decimal::from(2));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[test]
|
|
36
|
+
fn test_decimal_real_constants() {
|
|
37
|
+
let pi = Decimal::PI;
|
|
38
|
+
assert!(pi.to_f64() > 3.14);
|
|
39
|
+
assert!(pi.to_f64() < 3.15);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#[test]
|
|
43
|
+
fn test_decimal_from_to_f64() {
|
|
44
|
+
let val = Decimal::from_f64(42.5);
|
|
45
|
+
assert!((val.to_f64() - 42.5).abs() < 0.01);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[test]
|
|
49
|
+
fn test_decimal_is_nan_infinite() {
|
|
50
|
+
let val = Decimal::from(100);
|
|
51
|
+
assert!(!val.is_nan());
|
|
52
|
+
assert!(!val.is_infinite());
|
|
53
|
+
assert!(val.is_finite());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#[test]
|
|
57
|
+
fn test_decimal_exact_conversion() {
|
|
58
|
+
let val = Decimal::from(1000);
|
|
59
|
+
let f64_val = Exact::to_f64_approx(val);
|
|
60
|
+
assert_eq!(f64_val, 1000.0);
|
|
61
|
+
let back: Decimal = Exact::from_f64_approx(f64_val);
|
|
62
|
+
assert_eq!(back, Decimal::from(1000));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#[test]
|
|
66
|
+
fn test_decimal_quantity() {
|
|
67
|
+
let m = Quantity::<Meter, Decimal>::new(Decimal::from(100));
|
|
68
|
+
assert_eq!(m.value(), Decimal::from(100));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#[test]
|
|
72
|
+
fn test_decimal_quantity_arithmetic() {
|
|
73
|
+
let a = Quantity::<Meter, Decimal>::new(Decimal::from(10));
|
|
74
|
+
let b = Quantity::<Meter, Decimal>::new(Decimal::from(5));
|
|
75
|
+
let sum = a + b;
|
|
76
|
+
assert_eq!(sum.value(), Decimal::from(15));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
80
|
+
// Decimal Real methods (coverage for scalar.rs decimal_impl)
|
|
81
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
#[test]
|
|
84
|
+
fn test_decimal_signum_positive() {
|
|
85
|
+
let val = Decimal::from(42);
|
|
86
|
+
assert_eq!(Real::signum(val), Decimal::ONE);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#[test]
|
|
90
|
+
fn test_decimal_signum_negative() {
|
|
91
|
+
let val = Decimal::from(-42);
|
|
92
|
+
assert_eq!(Real::signum(val), Decimal::NEGATIVE_ONE);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#[test]
|
|
96
|
+
fn test_decimal_signum_zero() {
|
|
97
|
+
assert_eq!(Real::signum(Decimal::ZERO), Decimal::ZERO);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#[test]
|
|
101
|
+
fn test_decimal_mul_add() {
|
|
102
|
+
let result = Real::mul_add(Decimal::from(2), Decimal::from(3), Decimal::from(4));
|
|
103
|
+
assert_eq!(result, Decimal::from(10));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#[test]
|
|
107
|
+
fn test_decimal_floor() {
|
|
108
|
+
let val = Decimal::try_from(3.7).unwrap();
|
|
109
|
+
assert_eq!(Real::floor(val), Decimal::from(3));
|
|
110
|
+
let val = Decimal::try_from(-3.7).unwrap();
|
|
111
|
+
assert_eq!(Real::floor(val), Decimal::from(-4));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#[test]
|
|
115
|
+
fn test_decimal_ceil() {
|
|
116
|
+
let val = Decimal::try_from(3.2).unwrap();
|
|
117
|
+
assert_eq!(Real::ceil(val), Decimal::from(4));
|
|
118
|
+
let val = Decimal::try_from(-3.2).unwrap();
|
|
119
|
+
assert_eq!(Real::ceil(val), Decimal::from(-3));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#[test]
|
|
123
|
+
fn test_decimal_round() {
|
|
124
|
+
let val = Decimal::try_from(3.5).unwrap();
|
|
125
|
+
assert_eq!(Real::round(val), Decimal::from(4));
|
|
126
|
+
let val = Decimal::try_from(3.4).unwrap();
|
|
127
|
+
assert_eq!(Real::round(val), Decimal::from(3));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
#[test]
|
|
131
|
+
fn test_decimal_trunc() {
|
|
132
|
+
let val = Decimal::try_from(3.9).unwrap();
|
|
133
|
+
assert_eq!(Real::trunc(val), Decimal::from(3));
|
|
134
|
+
let val = Decimal::try_from(-3.9).unwrap();
|
|
135
|
+
assert_eq!(Real::trunc(val), Decimal::from(-3));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
#[test]
|
|
139
|
+
fn test_decimal_fract() {
|
|
140
|
+
let val = Decimal::try_from(3.75).unwrap();
|
|
141
|
+
let frac = Real::fract(val);
|
|
142
|
+
assert!((Exact::to_f64_approx(frac) - 0.75).abs() < 0.01);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#[test]
|
|
146
|
+
fn test_decimal_powf() {
|
|
147
|
+
let result = Real::powf(Decimal::from(2), Decimal::from(10));
|
|
148
|
+
assert!((Exact::to_f64_approx(result) - 1024.0).abs() < 1.0);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#[test]
|
|
152
|
+
fn test_decimal_powi() {
|
|
153
|
+
let result = Real::powi(Decimal::from(3), 4);
|
|
154
|
+
assert_eq!(result, Decimal::from(81));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#[test]
|
|
158
|
+
fn test_decimal_sqrt() {
|
|
159
|
+
let result = Real::sqrt(Decimal::from(16));
|
|
160
|
+
assert_eq!(result, Decimal::from(4));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#[test]
|
|
164
|
+
fn test_decimal_cbrt() {
|
|
165
|
+
let result = Real::cbrt(Decimal::from(27));
|
|
166
|
+
assert!((Exact::to_f64_approx(result) - 3.0).abs() < 0.01);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#[test]
|
|
170
|
+
fn test_decimal_ln() {
|
|
171
|
+
let result = Real::ln(Decimal::ONE);
|
|
172
|
+
assert!((Exact::to_f64_approx(result)).abs() < 0.01);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#[test]
|
|
176
|
+
fn test_decimal_log10() {
|
|
177
|
+
let result = Real::log10(Decimal::from(100));
|
|
178
|
+
assert!((Exact::to_f64_approx(result) - 2.0).abs() < 0.01);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#[test]
|
|
182
|
+
fn test_decimal_log2() {
|
|
183
|
+
let result = Real::log2(Decimal::from(8));
|
|
184
|
+
assert!((Exact::to_f64_approx(result) - 3.0).abs() < 0.01);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#[test]
|
|
188
|
+
fn test_decimal_log_base() {
|
|
189
|
+
let result = Real::log(Decimal::from(1000), Decimal::from(10));
|
|
190
|
+
assert!((Exact::to_f64_approx(result) - 3.0).abs() < 0.01);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
#[test]
|
|
194
|
+
fn test_decimal_exp() {
|
|
195
|
+
let result = Real::exp(Decimal::ZERO);
|
|
196
|
+
assert!((Exact::to_f64_approx(result) - 1.0).abs() < 0.01);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#[test]
|
|
200
|
+
fn test_decimal_exp2() {
|
|
201
|
+
let result = Real::exp2(Decimal::from(10));
|
|
202
|
+
assert!((Exact::to_f64_approx(result) - 1024.0).abs() < 1.0);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
#[test]
|
|
206
|
+
fn test_decimal_hypot() {
|
|
207
|
+
let result = Real::hypot(Decimal::from(3), Decimal::from(4));
|
|
208
|
+
assert!((Exact::to_f64_approx(result) - 5.0).abs() < 0.01);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#[test]
|
|
212
|
+
fn test_decimal_rem_euclid_negative() {
|
|
213
|
+
// Test negative remainder path
|
|
214
|
+
let val = Decimal::from(-10);
|
|
215
|
+
let modulus = Decimal::from(3);
|
|
216
|
+
let result = Scalar::rem_euclid(val, modulus);
|
|
217
|
+
assert!((Exact::to_f64_approx(result) - 2.0).abs() < 0.01);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
221
|
+
// Commutative multiplication: Decimal * Quantity
|
|
222
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
223
|
+
|
|
224
|
+
#[test]
|
|
225
|
+
fn test_decimal_commutative_mul() {
|
|
226
|
+
let q = Quantity::<Meter, Decimal>::new(Decimal::from(5));
|
|
227
|
+
let result = Decimal::from(3) * q;
|
|
228
|
+
assert_eq!(result.value(), Decimal::from(15));
|
|
229
|
+
let result2 = q * Decimal::from(3);
|
|
230
|
+
assert_eq!(result2.value(), Decimal::from(15));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
234
|
+
// Decimal Quantity: to_lossy, Display, to, cast
|
|
235
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
236
|
+
|
|
237
|
+
#[test]
|
|
238
|
+
fn test_decimal_quantity_to() {
|
|
239
|
+
use qtty_core::length::Kilometer;
|
|
240
|
+
let km = Quantity::<Kilometer, Decimal>::new(Decimal::from(1));
|
|
241
|
+
let m: Quantity<Meter, Decimal> = km.to();
|
|
242
|
+
assert_eq!(m.value(), Decimal::from(1000));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
#[test]
|
|
246
|
+
fn test_decimal_quantity_display() {
|
|
247
|
+
let m = Quantity::<Meter, Decimal>::new(Decimal::from(42));
|
|
248
|
+
assert_eq!(format!("{}", m), "42 m");
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#[test]
|
|
252
|
+
fn test_decimal_to_lossy() {
|
|
253
|
+
use qtty_core::length::Kilometer;
|
|
254
|
+
let m = Quantity::<Meter, Decimal>::new(Decimal::from(1500));
|
|
255
|
+
let km: Quantity<Kilometer, Decimal> = m.to_lossy();
|
|
256
|
+
// 1500/1000 = 1.5, to_f64_approx and back should give close to 1.5
|
|
257
|
+
assert!((Exact::to_f64_approx(km.value()) - 1.5).abs() < 0.01);
|
|
258
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
//! Tests for f32 Scalar + Real + Transcendental trait methods (coverage for scalar.rs).
|
|
2
|
+
|
|
3
|
+
use qtty_core::scalar::{Real, Scalar, Transcendental};
|
|
4
|
+
|
|
5
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
// Scalar methods for f32
|
|
7
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
#[test]
|
|
10
|
+
fn f32_scalar_zero_one() {
|
|
11
|
+
assert_eq!(f32::ZERO, 0.0_f32);
|
|
12
|
+
assert_eq!(f32::ONE, 1.0_f32);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#[test]
|
|
16
|
+
fn f32_abs() {
|
|
17
|
+
assert_eq!(Scalar::abs(-5.0_f32), 5.0);
|
|
18
|
+
assert_eq!(Scalar::abs(5.0_f32), 5.0);
|
|
19
|
+
assert_eq!(Scalar::abs(0.0_f32), 0.0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#[test]
|
|
23
|
+
fn f32_min() {
|
|
24
|
+
assert_eq!(Scalar::min(3.0_f32, 7.0), 3.0);
|
|
25
|
+
assert_eq!(Scalar::min(7.0_f32, 3.0), 3.0);
|
|
26
|
+
assert_eq!(Scalar::min(-1.0_f32, 1.0), -1.0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#[test]
|
|
30
|
+
fn f32_max() {
|
|
31
|
+
assert_eq!(Scalar::max(3.0_f32, 7.0), 7.0);
|
|
32
|
+
assert_eq!(Scalar::max(7.0_f32, 3.0), 7.0);
|
|
33
|
+
assert_eq!(Scalar::max(-1.0_f32, 1.0), 1.0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#[test]
|
|
37
|
+
fn f32_rem_euclid() {
|
|
38
|
+
let r = Scalar::rem_euclid(10.0_f32, 3.0);
|
|
39
|
+
assert!((r - 1.0).abs() < 1e-6);
|
|
40
|
+
let r = Scalar::rem_euclid(-10.0_f32, 3.0);
|
|
41
|
+
assert!((r - 2.0).abs() < 1e-6);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45
|
+
// Real constants and conversions
|
|
46
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
#[test]
|
|
49
|
+
fn f32_real_constants() {
|
|
50
|
+
assert!((f32::PI - core::f32::consts::PI).abs() < 1e-6);
|
|
51
|
+
assert!((f32::TAU - core::f32::consts::TAU).abs() < 1e-5);
|
|
52
|
+
assert!((f32::E - core::f32::consts::E).abs() < 1e-6);
|
|
53
|
+
assert!(f32::INFINITY.is_infinite());
|
|
54
|
+
assert!(f32::NEG_INFINITY.is_infinite());
|
|
55
|
+
assert!(f32::NAN.is_nan());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#[test]
|
|
59
|
+
fn f32_from_to_f64() {
|
|
60
|
+
let val = f32::from_f64(42.5);
|
|
61
|
+
assert!((val - 42.5_f32).abs() < 1e-6);
|
|
62
|
+
assert!((val.to_f64() - 42.5).abs() < 1e-6);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
66
|
+
// Real methods
|
|
67
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
#[test]
|
|
70
|
+
fn f32_signum() {
|
|
71
|
+
assert_eq!(Real::signum(5.0_f32), 1.0);
|
|
72
|
+
assert_eq!(Real::signum(-5.0_f32), -1.0);
|
|
73
|
+
assert!(Real::signum(f32::NAN).is_nan());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[test]
|
|
77
|
+
fn f32_is_nan() {
|
|
78
|
+
assert!(Real::is_nan(f32::NAN));
|
|
79
|
+
assert!(!Real::is_nan(0.0_f32));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#[test]
|
|
83
|
+
fn f32_is_infinite() {
|
|
84
|
+
assert!(Real::is_infinite(f32::INFINITY));
|
|
85
|
+
assert!(Real::is_infinite(f32::NEG_INFINITY));
|
|
86
|
+
assert!(!Real::is_infinite(42.0_f32));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#[test]
|
|
90
|
+
fn f32_is_finite() {
|
|
91
|
+
assert!(Real::is_finite(42.0_f32));
|
|
92
|
+
assert!(!Real::is_finite(f32::INFINITY));
|
|
93
|
+
assert!(!Real::is_finite(f32::NAN));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#[test]
|
|
97
|
+
fn f32_mul_add() {
|
|
98
|
+
let r = Real::mul_add(2.0_f32, 3.0, 4.0);
|
|
99
|
+
assert!((r - 10.0).abs() < 1e-6);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#[test]
|
|
103
|
+
fn f32_floor() {
|
|
104
|
+
assert_eq!(Real::floor(3.7_f32), 3.0);
|
|
105
|
+
assert_eq!(Real::floor(-3.7_f32), -4.0);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#[test]
|
|
109
|
+
fn f32_ceil() {
|
|
110
|
+
assert_eq!(Real::ceil(3.2_f32), 4.0);
|
|
111
|
+
assert_eq!(Real::ceil(-3.2_f32), -3.0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#[test]
|
|
115
|
+
fn f32_round() {
|
|
116
|
+
assert_eq!(Real::round(3.5_f32), 4.0);
|
|
117
|
+
assert_eq!(Real::round(3.4_f32), 3.0);
|
|
118
|
+
assert_eq!(Real::round(-3.5_f32), -4.0);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#[test]
|
|
122
|
+
fn f32_trunc() {
|
|
123
|
+
assert_eq!(Real::trunc(3.9_f32), 3.0);
|
|
124
|
+
assert_eq!(Real::trunc(-3.9_f32), -3.0);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#[test]
|
|
128
|
+
fn f32_fract() {
|
|
129
|
+
let f = Real::fract(3.75_f32);
|
|
130
|
+
assert!((f - 0.75).abs() < 1e-6);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#[test]
|
|
134
|
+
fn f32_powf() {
|
|
135
|
+
let r = Real::powf(2.0_f32, 10.0);
|
|
136
|
+
assert!((r - 1024.0).abs() < 1e-2);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#[test]
|
|
140
|
+
fn f32_powi() {
|
|
141
|
+
let r = Real::powi(2.0_f32, 10);
|
|
142
|
+
assert!((r - 1024.0).abs() < 1e-2);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#[test]
|
|
146
|
+
fn f32_sqrt() {
|
|
147
|
+
assert!((Real::sqrt(16.0_f32) - 4.0).abs() < 1e-6);
|
|
148
|
+
assert!((Real::sqrt(2.0_f32) - core::f32::consts::SQRT_2).abs() < 1e-6);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#[test]
|
|
152
|
+
fn f32_cbrt() {
|
|
153
|
+
assert!((Real::cbrt(27.0_f32) - 3.0).abs() < 1e-5);
|
|
154
|
+
assert!((Real::cbrt(-8.0_f32) + 2.0).abs() < 1e-5);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#[test]
|
|
158
|
+
fn f32_ln() {
|
|
159
|
+
assert!((Real::ln(1.0_f32)).abs() < 1e-6);
|
|
160
|
+
assert!((Real::ln(core::f32::consts::E) - 1.0).abs() < 1e-6);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#[test]
|
|
164
|
+
fn f32_log10() {
|
|
165
|
+
assert!((Real::log10(100.0_f32) - 2.0).abs() < 1e-5);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#[test]
|
|
169
|
+
fn f32_log2() {
|
|
170
|
+
assert!((Real::log2(8.0_f32) - 3.0).abs() < 1e-5);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
#[test]
|
|
174
|
+
fn f32_log() {
|
|
175
|
+
assert!((Real::log(1000.0_f32, 10.0) - 3.0).abs() < 1e-3);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#[test]
|
|
179
|
+
fn f32_exp() {
|
|
180
|
+
assert!((Real::exp(0.0_f32) - 1.0).abs() < 1e-6);
|
|
181
|
+
assert!((Real::exp(1.0_f32) - core::f32::consts::E).abs() < 1e-5);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#[test]
|
|
185
|
+
fn f32_exp2() {
|
|
186
|
+
assert!((Real::exp2(0.0_f32) - 1.0).abs() < 1e-6);
|
|
187
|
+
assert!((Real::exp2(10.0_f32) - 1024.0).abs() < 1e-2);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#[test]
|
|
191
|
+
fn f32_hypot() {
|
|
192
|
+
assert!((Real::hypot(3.0_f32, 4.0) - 5.0).abs() < 1e-6);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
196
|
+
// Transcendental methods — f32
|
|
197
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
#[test]
|
|
200
|
+
fn f32_sin() {
|
|
201
|
+
let pi = core::f32::consts::PI;
|
|
202
|
+
assert!((Transcendental::sin(0.0_f32)).abs() < 1e-6);
|
|
203
|
+
assert!((Transcendental::sin(pi / 2.0) - 1.0).abs() < 1e-6);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#[test]
|
|
207
|
+
fn f32_cos() {
|
|
208
|
+
let pi = core::f32::consts::PI;
|
|
209
|
+
assert!((Transcendental::cos(0.0_f32) - 1.0).abs() < 1e-6);
|
|
210
|
+
assert!((Transcendental::cos(pi) + 1.0).abs() < 1e-6);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
#[test]
|
|
214
|
+
fn f32_tan() {
|
|
215
|
+
let pi = core::f32::consts::PI;
|
|
216
|
+
assert!((Transcendental::tan(0.0_f32)).abs() < 1e-6);
|
|
217
|
+
assert!((Transcendental::tan(pi / 4.0) - 1.0).abs() < 1e-5);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
#[test]
|
|
221
|
+
fn f32_sin_cos() {
|
|
222
|
+
let pi = core::f32::consts::PI;
|
|
223
|
+
let (s, c) = Transcendental::sin_cos(pi / 6.0_f32);
|
|
224
|
+
assert!((s - 0.5).abs() < 1e-6);
|
|
225
|
+
assert!((c - (3.0_f32).sqrt() / 2.0).abs() < 1e-6);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
#[test]
|
|
229
|
+
fn f32_asin() {
|
|
230
|
+
assert!((Transcendental::asin(0.5_f32) - core::f32::consts::FRAC_PI_6).abs() < 1e-6);
|
|
231
|
+
assert!((Transcendental::asin(1.0_f32) - core::f32::consts::FRAC_PI_2).abs() < 1e-6);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
#[test]
|
|
235
|
+
fn f32_acos() {
|
|
236
|
+
assert!((Transcendental::acos(0.5_f32) - core::f32::consts::FRAC_PI_3).abs() < 1e-6);
|
|
237
|
+
assert!((Transcendental::acos(1.0_f32)).abs() < 1e-6);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#[test]
|
|
241
|
+
fn f32_atan() {
|
|
242
|
+
assert!((Transcendental::atan(1.0_f32) - core::f32::consts::FRAC_PI_4).abs() < 1e-6);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
#[test]
|
|
246
|
+
fn f32_atan2() {
|
|
247
|
+
let pi = core::f32::consts::PI;
|
|
248
|
+
assert!((Transcendental::atan2(1.0_f32, 1.0) - pi / 4.0).abs() < 1e-6);
|
|
249
|
+
assert!((Transcendental::atan2(0.0_f32, -1.0) - pi).abs() < 1e-6);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
#[test]
|
|
253
|
+
fn f32_sinh() {
|
|
254
|
+
assert!((Transcendental::sinh(0.0_f32)).abs() < 1e-6);
|
|
255
|
+
assert!((Transcendental::sinh(1.0_f32) - 1.0_f32.sinh()).abs() < 1e-6);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
#[test]
|
|
259
|
+
fn f32_cosh() {
|
|
260
|
+
assert!((Transcendental::cosh(0.0_f32) - 1.0).abs() < 1e-6);
|
|
261
|
+
assert!((Transcendental::cosh(1.0_f32) - 1.0_f32.cosh()).abs() < 1e-6);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#[test]
|
|
265
|
+
fn f32_tanh() {
|
|
266
|
+
assert!((Transcendental::tanh(0.0_f32)).abs() < 1e-6);
|
|
267
|
+
assert!((Transcendental::tanh(1.0_f32) - 1.0_f32.tanh()).abs() < 1e-6);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
#[test]
|
|
271
|
+
fn f32_asinh() {
|
|
272
|
+
assert!((Transcendental::asinh(0.0_f32)).abs() < 1e-6);
|
|
273
|
+
assert!((Transcendental::asinh(1.0_f32) - 1.0_f32.asinh()).abs() < 1e-6);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
#[test]
|
|
277
|
+
fn f32_acosh() {
|
|
278
|
+
assert!((Transcendental::acosh(1.0_f32)).abs() < 1e-6);
|
|
279
|
+
assert!((Transcendental::acosh(2.0_f32) - 2.0_f32.acosh()).abs() < 1e-6);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
#[test]
|
|
283
|
+
fn f32_atanh() {
|
|
284
|
+
assert!((Transcendental::atanh(0.0_f32)).abs() < 1e-6);
|
|
285
|
+
assert!((Transcendental::atanh(0.5_f32) - 0.5_f32.atanh()).abs() < 1e-6);
|
|
286
|
+
}
|