Skip to content

Commit e20e55f

Browse files
committed
Ver 0.39.5
- Add new feature `rkyv`
2 parents a9b68f9 + 9c7f7ee commit e20e55f

File tree

8 files changed

+28
-2
lines changed

8 files changed

+28
-2
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "peroxide"
3-
version = "0.39.4"
3+
version = "0.39.5"
44
authors = ["axect <[email protected]>"]
55
edition = "2018"
66
description = "Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with farmiliar syntax"
@@ -47,6 +47,7 @@ pyo3 = { version = "0.22", optional = true, features = [
4747
blas = { version = "0.22", optional = true }
4848
lapack = { version = "0.19", optional = true }
4949
serde = { version = "1.0", features = ["derive"], optional = true }
50+
rkyv = { version = "0.8", optional = true }
5051
json = { version = "0.12", optional = true }
5152
arrow2 = { version = "0.18", features = [
5253
"io_parquet",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Peroxide provides various features.
4646
- `csv` - To handle csv file format with Matrix or DataFrame
4747
- `parquet` - To handle parquet file format with DataFrame
4848
- `serde` - serialization with [Serde](https://serde.rs/).
49+
- `rkyv` - serialization with [rkyv](https://rkyv.org).
4950

5051
If you want to do high performance computation and more linear algebra, then choose `O3` feature.
5152
If you don't want to depend C/C++ or Fortran libraries, then choose `default` feature.

RELEASES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Release 0.39.5 (2025-04-21)
2+
3+
- New feature `rkyv`
4+
- Implement `rkyv::{Archive, Serialize, Deserialize}` for `Matrix`, `Polynomial`, `Spline`, `ODE`
5+
16
# Release 0.39.4 (2025-04-11)
27

38
## Optimize `integrate`

src/numerical/ode.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ impl<BU: ButcherTableau> ODEIntegrator for BU {
366366
/// In MATLAB, it is called `ode3`.
367367
#[derive(Debug, Clone, Copy, Default)]
368368
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
369+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
369370
pub struct RALS3;
370371

371372
impl ButcherTableau for RALS3 {
@@ -381,6 +382,7 @@ impl ButcherTableau for RALS3 {
381382
/// It calculates four intermediate values (k1, k2, k3, k4) to estimate the next step solution.
382383
#[derive(Debug, Clone, Copy, Default)]
383384
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
385+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
384386
pub struct RK4;
385387

386388
impl ButcherTableau for RK4 {
@@ -395,6 +397,7 @@ impl ButcherTableau for RK4 {
395397
/// This fourth order method is known as minimum truncation error RK4.
396398
#[derive(Debug, Clone, Copy, Default)]
397399
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
400+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
398401
pub struct RALS4;
399402

400403
impl ButcherTableau for RALS4 {
@@ -414,6 +417,7 @@ impl ButcherTableau for RALS4 {
414417
/// This integrator uses the 5th order Runge-Kutta method to numerically integrate the ODE system.
415418
#[derive(Debug, Clone, Copy, Default)]
416419
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
420+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
417421
pub struct RK5;
418422

419423
impl ButcherTableau for RK5 {
@@ -473,6 +477,7 @@ impl ButcherTableau for RK5 {
473477
/// - `max_step_iter`: The maximum number of iterations per step.
474478
#[derive(Debug, Clone, Copy)]
475479
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
480+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
476481
pub struct BS23 {
477482
pub tol: f64,
478483
pub safety_factor: f64,
@@ -554,6 +559,7 @@ impl ButcherTableau for BS23 {
554559
/// - `max_step_iter`: The maximum number of iterations per step.
555560
#[derive(Debug, Clone, Copy)]
556561
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
562+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
557563
pub struct RKF45 {
558564
pub tol: f64,
559565
pub safety_factor: f64,
@@ -656,6 +662,7 @@ impl ButcherTableau for RKF45 {
656662
/// - `max_step_iter`: The maximum number of iterations per step.
657663
#[derive(Debug, Clone, Copy)]
658664
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
665+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
659666
pub struct DP45 {
660667
pub tol: f64,
661668
pub safety_factor: f64,
@@ -777,6 +784,7 @@ impl ButcherTableau for DP45 {
777784
/// - Ch. Tsitouras, Comput. Math. Appl. 62 (2011) 770-780.
778785
#[derive(Debug, Clone, Copy)]
779786
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
787+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
780788
pub struct TSIT45 {
781789
pub tol: f64,
782790
pub safety_factor: f64,
@@ -896,6 +904,7 @@ impl ButcherTableau for TSIT45 {
896904
/// Currently, there are two options: fixed-point iteration and Broyden's method.
897905
#[derive(Debug, Clone, Copy)]
898906
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
907+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
899908
pub enum ImplicitSolver {
900909
FixedPoint,
901910
Broyden,
@@ -915,6 +924,7 @@ pub enum ImplicitSolver {
915924
/// - `max_step_iter`: The maximum number of iterations for the implicit solver per step.
916925
#[derive(Debug, Clone, Copy)]
917926
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
927+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
918928
pub struct GL4 {
919929
pub solver: ImplicitSolver,
920930
pub tol: f64,

src/numerical/spline.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ pub fn cubic_hermite_spline(
441441
/// ```
442442
#[derive(Debug, Clone, Default)]
443443
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
444+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize))]
444445
pub struct CubicSpline {
445446
polynomials: Vec<(Range<f64>, Polynomial)>,
446447
}
@@ -691,6 +692,7 @@ impl Calculus for CubicSpline {
691692
// =============================================================================
692693
#[derive(Debug, Clone, Default)]
693694
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
695+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize))]
694696
pub struct CubicHermiteSpline {
695697
polynomials: Vec<(Range<f64>, Polynomial)>,
696698
}
@@ -917,6 +919,7 @@ fn quadratic_slopes(x: &[f64], y: &[f64]) -> Result<Vec<f64>> {
917919
/// [Wikipedia](https://en.wikipedia.org/wiki/Irwin%E2%80%93Hall_distribution#Special_cases)
918920
#[derive(Debug, Copy, Clone)]
919921
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
922+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize))]
920923
pub struct UnitCubicBasis {
921924
pub x_min: f64,
922925
pub x_max: f64,
@@ -992,6 +995,7 @@ impl UnitCubicBasis {
992995
/// ```
993996
#[derive(Debug, Clone)]
994997
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
998+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize))]
995999
pub struct CubicBSplineBases {
9961000
pub ranges: Vec<Range<f64>>,
9971001
pub bases: Vec<UnitCubicBasis>,
@@ -1089,6 +1093,7 @@ impl CubicBSplineBases {
10891093
/// ```
10901094
#[derive(Debug, Clone, Default)]
10911095
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
1096+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize))]
10921097
pub struct BSpline {
10931098
pub degree: usize,
10941099
pub knots: Vec<f64>,

src/statistics/stat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ pub fn cor(v1: &Vec<f64>, v2: &Vec<f64>) -> f64 {
555555
///
556556
/// fn main() {
557557
/// let a: Matrix = c!(1,2,3,4,5).into();
558-
/// let b: Matrix = &a + &Normal(0,1).sample(5).into();
558+
/// let noise: Matrix = Normal(0,1).sample(5).into();
559+
/// let b: Matrix = &a + &noise;
559560
/// lm(&a, &b).print();
560561
///
561562
/// // c[0]

src/structure/matrix.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ pub type Perms = Vec<(usize, usize)>;
657657
/// ```
658658
#[derive(Default, Debug, PartialEq, Clone, Copy)]
659659
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
660+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
660661
pub enum Shape {
661662
#[default]
662663
Col,
@@ -690,6 +691,7 @@ impl fmt::Display for Shape {
690691
/// ```
691692
#[derive(Debug, Clone, Default)]
692693
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
694+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
693695
pub struct Matrix {
694696
pub data: Vec<f64>,
695697
pub row: usize,

src/structure/polynomial.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::ops::{Add, Div, Mul, Neg, Sub};
1818
/// Polynomial Structure
1919
#[derive(Debug, Clone, Default)]
2020
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
21+
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize))]
2122
pub struct Polynomial {
2223
pub coef: Vec<f64>,
2324
}

0 commit comments

Comments
 (0)