Skip to content

Commit

Permalink
Ver 0.34.2
Browse files Browse the repository at this point in the history
* Peroxide-num
  • Loading branch information
Axect committed Nov 20, 2023
2 parents 377dc96 + c862b62 commit 32472ca
Show file tree
Hide file tree
Showing 19 changed files with 716 additions and 223 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "peroxide"
version = "0.34.1"
version = "0.34.2"
authors = ["axect <[email protected]>"]
edition = "2018"
description = "Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with farmiliar syntax"
Expand All @@ -27,14 +27,15 @@ order-stat = "0.1"
puruspe = "0.2"
matrixmultiply = { version = "0.3", features = ["threading"] }
peroxide-ad = "0.3"
peroxide-num = "0.1"
#num-complex = "0.3"
netcdf = { version = "0.7", optional = true, default_features = false }
pyo3 = { version = "0.19", optional = true }
blas = { version = "0.22", optional = true }
lapack = { version = "0.19", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
json = { version = "0.12", optional = true }
arrow2 = { version = "0.17", features = ["io_parquet", "io_parquet_compression"], optional = true }
arrow2 = { version = "0.18", features = ["io_parquet", "io_parquet_compression"], optional = true }

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "katex-header.html", "--cfg", "docsrs"]
Expand Down
15 changes: 15 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Release 0.34.2 (2023-11-20)

## New sub-crate : `peroxide-num`

* Add new sub-crate : `peroxide-num`
* Change all dependencies of `ExpLogOps, PowOps, TrigOps` to `peroxide-num`

## Fix errata

* R example in `structure/matrix` (#56) (Thanks to [@rdavis120](https://github.com/rdavis120))

## Fix old syntax

* Fix old syntax - e.g. explicit `into_iter`, `Vec::with_capacity` & `set_len`

# Release 0.34.1 (2023-08-03)

## Modify Statistics of `WeightedUniform`
Expand Down
1 change: 0 additions & 1 deletion examples/ad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ fn main() {
(b - 1f64).print();
(b * 2f64).print();
(b / 2f64).print();
assert_eq!(1f64 + b, b + 1f64);
assert_eq!(-(1f64 - b), b - 1f64);
assert_eq!(2f64 * b, b * 2f64);
assert_eq!(1f64 / (2f64 / b), b / 2f64);
Expand Down
1 change: 1 addition & 0 deletions peroxide-num/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
16 changes: 16 additions & 0 deletions peroxide-num/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "peroxide-num"
version = "0.1.3"
edition = "2021"
authors = ["Axect <[email protected]>"]
description = "Numerical traits for Peroxide"
repository = "https://github.com/Axect/Peroxide"
license = "MIT OR Apache-2.0"
categories = ["science"]
readme = "README.md"
keywords = ["numerical", "mathematics"]
exclude = ["examples/"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
72 changes: 72 additions & 0 deletions peroxide-num/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Peroxide-num

`Peroxide-num` is a Rust crate dedicated to providing comprehensive numeric structures and operations, extending generic programming capabilities with a focus on mathematical computations.

## Overview

This crate defines a set of traits for numeric operations, including basic arithmetic, power functions, trigonometric functions, exponential, and logarithmic functions. It is designed to be used with numeric types that implement these traits, allowing for a wide range of mathematical operations.

## Traits

- `PowOps`: Operations related to powers and roots.
- `TrigOps`: Trigonometric functions.
- `ExpLogOps`: Exponential and logarithmic functions.
- `Float`: Define own floating point type (`f32` and `f64` are implemented as default).
- `Numeric`: A comprehensive trait that encompasses all of the above along with standard arithmetic operations.

## Example 1: Defining a Simple Numeric Type

Below is an example of how you can define your own simple numeric type that implements the `Numeric` trait.

```rust
#[derive(Debug, Clone, Copy, PartialOrd)]
struct SimpleNumber(f64);

impl PowOps for SimpleNumber {
type Float = Self;

fn powi(&self, n: i32) -> Self {
SimpleNumber(self.0.powi(n))
}

fn powf(&self, f: Self::Float) -> Self {
SimpleNumber(self.0.powf(f.0))
}

fn pow(&self, f: Self) -> Self {
SimpleNumber(self.0.powf(f.0))
}

fn sqrt(&self) -> Self {
SimpleNumber(self.0.sqrt())
}
}

// Implement other required operations for SimpleNumber...
// - Add, Sub, Mul, Div, Neg
// - PowOps (implemented above)
// - TrigOps
// - ExpLogOps

impl Numeric<f64> for SimpleNumber {}
```

This `SimpleNumber` struct wraps a `f64` and implements the `Numeric` trait, making it capable of all the operations defined in the `Peroxide-num` crate.

## Example 2: `Vec3D` (3D Vector)

[examples/vec3d.rs](examples/vec3d.rs)

## Usage

To use this type in your own computations:

```rust
let num = SimpleNumber(2.0);
let result = num.sin(); // Compute the sine of 2.0
println!("{:?}", result); // Should display the sine of 2.0
```

The `Peroxide-num` crate is designed to be flexible and extensible, allowing for easy integration with the larger `Peroxide` ecosystem for scientific computing in Rust.

For more information and advanced usage, please refer to the documentation and examples provided with the crate.
18 changes: 18 additions & 0 deletions peroxide-num/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ver 0.1.3 (2023-11-09)

- Add `Group` and `Ring`
- `Group`: require `Add<Self, Output=Self>` and has `zero()`
- `Ring`: require `Group + Mul<Self, Output=Self>` and has `one()`
- `f32` and `f64` are `Ring`

# Ver 0.1.2 (2023-11-09)

- Remove unnecessary constraints for `Numeric<T>`
- `T: Add<Self, Output=Self> + Sub<Self, Output=Self> + Mul<Self, Output=Self> + Div<Self, Output=Self>`
- More specify `Neg` for `Numeric` & `Float`: `Neg` -> `Neg<Output=Self>`

# Ver 0.1.1 (2023-11-09)

- Add constraints for `Numeric<T>`
- `T: Add<Self, Output=Self> + Sub<Self, Output=Self> + Mul<Self, Output=Self> + Div<Self, Output=Self>`
- Add example : `Vec3D`
Loading

0 comments on commit 32472ca

Please sign in to comment.