From d7828050d462c27b71f1368f09f9bc547bf0bf5f Mon Sep 17 00:00:00 2001 From: axect Date: Sun, 28 Jan 2024 17:31:32 +0900 Subject: [PATCH 1/2] IMPL: derive Serialize & Deserialize for matrix --- src/structure/matrix.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/structure/matrix.rs b/src/structure/matrix.rs index 091df7fe..baf7bbdd 100644 --- a/src/structure/matrix.rs +++ b/src/structure/matrix.rs @@ -607,13 +607,13 @@ #[cfg(feature="csv")] extern crate csv; +#[cfg(feature="csv")] +use self::csv::{ReaderBuilder, StringRecord, WriterBuilder}; + #[cfg(feature = "O3")] extern crate blas; #[cfg(feature = "O3")] extern crate lapack; - -#[cfg(feature="csv")] -use self::csv::{ReaderBuilder, StringRecord, WriterBuilder}; use ::matrixmultiply; #[cfg(feature = "O3")] use blas::{daxpy, dgemm, dgemv}; @@ -622,6 +622,9 @@ use lapack::{dgecon, dgeqrf, dgetrf, dgetri, dgetrs, dorgqr, dgesvd, dpotrf}; #[cfg(feature = "O3")] use std::f64::NAN; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + pub use self::Shape::{Col, Row}; use crate::numerical::eigen::{eigen, EigenMethod}; use crate::traits::{ @@ -661,8 +664,10 @@ pub type Perms = Vec<(usize, usize)>; /// println!("{}", a); // Similar to [[1,2],[3,4]] /// println!("{}", b); // Similar to [[1,3],[2,4]] /// ``` -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Default, Debug, PartialEq, Clone, Copy)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum Shape { + #[default] Col, Row, } @@ -678,12 +683,6 @@ impl fmt::Display for Shape { } } -impl Default for Shape { - fn default() -> Self { - Shape::Col - } -} - /// R-like matrix structure /// /// # Examples @@ -700,6 +699,7 @@ impl Default for Shape { /// }; // [[1,2],[3,4]] /// ``` #[derive(Debug, Clone, Default)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Matrix { pub data: Vec, pub row: usize, From 66e18c864cff911ee4ba3ddaf0c49ac7e6f3f2b1 Mon Sep 17 00:00:00 2001 From: axect Date: Sun, 28 Jan 2024 17:34:15 +0900 Subject: [PATCH 2/2] RLSE: Ver 0.34.4 - Derive `Serialize` and `Deserialize` for `Matrix` --- Cargo.toml | 2 +- RELEASES.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 705aec75..e097734e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "peroxide" -version = "0.34.3" +version = "0.34.4" authors = ["axect "] edition = "2018" description = "Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with farmiliar syntax" diff --git a/RELEASES.md b/RELEASES.md index 1dfddfa1..69aa4977 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,8 @@ +# Release 0.34.4 (2024-01-28) + +* Derive `Serialize` and `Deserialize` for `Matrix` +* Remove explicit implementation for `Default` for `Shape` + # Release 0.34.3 (2023-11-25) * Update `peroxide-num` to `v0.1.4`