Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial README for pallas-math #474

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"pallas-utxorpc",
"pallas-hardano",
"pallas-wallet",
"pallas-math",
"pallas",
"examples/block-download",
"examples/block-decode",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 19 additions & 0 deletions pallas-math/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions pallas-math/README.md
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions pallas-math/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod math;
17 changes: 17 additions & 0 deletions pallas-math/src/math.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}