chore(math): initialize pallas-math crate (#474)
This commit is contained in:
parent
d12fe799eb
commit
acf18f202b
6 changed files with 53 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ members = [
|
|||
"pallas-utxorpc",
|
||||
"pallas-hardano",
|
||||
"pallas-wallet",
|
||||
"pallas-math",
|
||||
"pallas",
|
||||
"examples/block-download",
|
||||
"examples/block-decode",
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ As already explained, _Pallas_ aims at being an expanding set of components. The
|
|||
| ------------------------------- | -------------------------------------------------- |
|
||||
| [pallas-crypto](/pallas-crypto) | Shared Cryptographic primitives |
|
||||
| [pallas-codec](/pallas-codec) | Shared CBOR encoding / decoding using minicbor lib |
|
||||
| [pallas-math](/pallas-math) | Shared mathematics functions |
|
||||
|
||||
## Etymology
|
||||
|
||||
|
|
|
|||
19
pallas-math/Cargo.toml
Normal file
19
pallas-math/Cargo.toml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "pallas-math"
|
||||
description = "Mathematics functions for Cardano"
|
||||
version = "0.27.0"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/txpipe/pallas"
|
||||
homepage = "https://github.com/txpipe/pallas"
|
||||
documentation = "https://docs.rs/pallas-math"
|
||||
license = "Apache-2.0"
|
||||
readme = "README.md"
|
||||
authors = ["Andrew Westberg <andrewwestberg@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
rug = "1.24.1"
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
rand = "0.8"
|
||||
14
pallas-math/README.md
Normal file
14
pallas-math/README.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Pallas Math
|
||||
|
||||
Crate with all the mathematics functions to support Cardano protocol:
|
||||
|
||||
- [] lncf - Approximate `ln(1+x)` for `x in 0..infinty`.
|
||||
- [] cf - Compute continued fraction using max steps or bounded list of a/b factors.
|
||||
- [] bound - Simple way to find integer powers that bound x.
|
||||
- [] contract - Bisect bounds to find the smallest integer power such that `factor^n<=x<factor^(n+1)`.
|
||||
- [] find_e - find n with `e^n<=x<e^(n+1)`.
|
||||
- [] ln - Compute natural logarithm via continued fraction, first splitting integral part and then using continued fractions approximation for `ln(1+x)`.
|
||||
- [] taylor_exp - Compute `exp(x)` using Taylor expansion.
|
||||
- [] taylor_exp_cmp - Efficient way to compare the result of the Taylor expansion of the exponential function to a threshold value.
|
||||
- ...
|
||||
- ...
|
||||
1
pallas-math/src/lib.rs
Normal file
1
pallas-math/src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod math;
|
||||
17
pallas-math/src/math.rs
Normal file
17
pallas-math/src/math.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*!
|
||||
# Cardano Math functions
|
||||
*/
|
||||
|
||||
pub fn add(a: i32, b: i32) -> i32 {
|
||||
a + b
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_add() {
|
||||
assert_eq!(add(1, 2), 3);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue