Crates.io | ftl-numkernel |
lib.rs | ftl-numkernel |
version | 0.1.0 |
created_at | 2024-11-13 12:54:28.900968+00 |
updated_at | 2024-11-13 12:54:28.900968+00 |
description | A library designed to provide numerical operations and error handling for both real and complex numbers, also supporting arbitrary precision types |
homepage | |
repository | |
max_upload_size | |
id | 1446499 |
size | 245,412 |
ftl-numkernel
is a comprehensive library designed to provide advanced numerical operations and error handling for both real and complex numbers. It leverages Rust's strong type system and error handling capabilities to ensure robust and reliable computations. The library includes traits and implementations for various mathematical functions, with support for both native floating-point types and arbitrary precision types provided by the rug
library.
Error Handling:
Traits for Numerical Operations:
Support for Real and Complex Numbers:
Arbitrary Precision Support:
rug
library.rug
library is activated with the optional flag --features=rug
.Comprehensive Documentation:
Extensibility:
duplicate
crate is used to reduce code redundancy and ensure consistent implementations across different types.This library currently requires the nightly branch of the Rust compiler, as it depends on the unstable feature error_generic_member_access
, which is not yet available in stable or beta releases.
Note: This requirement is accurate at the time of writing (November 2024), but it may change if the feature error_generic_member_access
becomes stable in the future. Once the feature is stabilized, this library should work on the stable Rust compiler as well.
To use this library with the nightly compiler, please run:
rustup install nightly
rustup override set nightly
This will set your environment to use the nightly compiler, enabling compatibility with the current version of the library.
use ftl_numkernel::functions::Sqrt;
let x = 4.;
let sqrt_x = x.sqrt();
assert_eq!(sqrt_x, 2.0);
let y = -4.;
let sqrt_y = y.try_sqrt();
assert!(sqrt_y.is_err());
In this example, x.sqrt()
computes the square root of x
without checks (in Release mode), while y.try_sqrt()
will perform checks (in Debug and Release mode) on the values of y
before the computation of the square root (ensuring that the input value is finite, normal and non-negative) and after the computation of the square root (i.e., just before the result is returned and stored in sqrt_y
), in order to ensure that the returned value is finite and normal. Since y
is negative, the rust Err
type will wrap an error in sqrt_y
.
Copyright 2024, C.N.R. - Consiglio Nazionale delle Ricerche
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
If you enable the rug
feature (with the optional flag --features=rug
), this project will use the Rug
library, which is licensed under the LGPL-3.0. Activating this feature may introduce LGPL-3.0 requirements to your project.
Specifically, if you distribute a product that links with Rug
, you may need to comply with the LGPL-3.0 license terms, which require the ability to replace or relink the Rug
component by the end-user.
To avoid LGPL-3.0 obligations, you can use this library without enabling the rug
feature, thereby excluding Rug
as a dependency.