Skip to content

Commit d6665b7

Browse files
committed
Ver 0.37.3
- Add Nan/infinite guard to `gauss_kronrod_quadrature` (early exit) (#59) - Add complex feature & complex module (#35) - Implement Cubic B-Spline basis function
2 parents dea021a + d9b3545 commit d6665b7

File tree

12 files changed

+258
-114
lines changed

12 files changed

+258
-114
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "peroxide"
3-
version = "0.37.2"
3+
version = "0.37.3"
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"
@@ -38,6 +38,7 @@ lapack = { version = "0.19", optional = true }
3838
serde = { version = "1.0", features = ["derive"], optional = true }
3939
json = { version = "0.12", optional = true }
4040
arrow2 = { version = "0.18", features = ["io_parquet", "io_parquet_compression"], optional = true }
41+
num-complex = { version = "0.4", optional = true }
4142

4243
[package.metadata.docs.rs]
4344
rustdoc-args = [ "--html-in-header", "katex-header.html", "--cfg", "docsrs"]
@@ -48,3 +49,4 @@ O3 = ["blas", "lapack"]
4849
plot = ["pyo3"]
4950
nc = ["netcdf"]
5051
parquet = ["arrow2"]
52+
complex = ["num-complex", "matrixmultiply/cgemm"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ Peroxide can do many things.
173173
- Cubic Hermite Spline
174174
- Estimate slope via Akima
175175
- Estimate slope via Quadratic interpolation
176+
- B-Spline (incomplete)
177+
- Uniform Cubic B-Spline basis function
176178
- Non-linear regression
177179
- Gradient Descent
178180
- Levenberg Marquardt

RELEASES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Release 0.37.3 (2024-05-01)
2+
3+
- Add Nan/infinite guard to `gauss_kronrod_quadrature` (early exit) ([#59](https://github.com/Axect/Peroxide/pull/59)) (Thanks to [@GComitini](https://github.com/GComitini))
4+
- Add complex feature & complex module ([#35](https://github.com/Axect/Peroxide/issues/35))
5+
- Implement Cubic B-Spline basis functions
6+
- `UnitCubicBasis`
7+
- `CubicBSplineBases`
8+
19
# Release 0.37.2 (2024-04-16)
210

311
- Do not include legend box if there is no legend ([#58](https://github.com/Axect/Peroxide/pull/58)) (Thanks to [@GComitini](https://github.com/GComitini))

example_data/cubic_b_spline.png

164 KB
Loading

example_data/rkf45_test.png

0 Bytes
Loading

example_data/test_plot.png

0 Bytes
Loading

src/complex/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use num_complex::Complex;
2+
3+
pub type C64 = Complex<f64>;
4+
5+
pub mod vector;

src/structure/complex.rs renamed to src/complex/vector.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ use crate::traits::fp::FPVector;
33
use crate::traits::math::{Vector, Normed, Norm, InnerProduct};
44
use crate::traits::sugar::VecOps;
55

6-
pub type C64 = Complex<f64>;
7-
86
impl Vector for Complex<f64> {
97
type Scalar = Self;
108

11-
fn add_vec<'a, 'b>(&'a self, rhs: &'b Self) -> Self {
9+
fn add_vec(&self, rhs: &Self) -> Self {
1210
self + rhs
1311
}
1412

15-
fn sub_vec<'a, 'b>(&'a self, rhs: &'b Self) -> Self {
13+
fn sub_vec(&self, rhs: &Self) -> Self {
1614
self - rhs
1715
}
1816

@@ -70,15 +68,15 @@ impl FPVector for Vec<Complex<f64>> {
7068
fn filter<F>(&self, f: F) -> Self
7169
where
7270
F: Fn(Self::Scalar) -> bool {
73-
self.into_iter().filter(|&x| f(*x)).map(|&t| t).collect()
71+
self.iter().filter(|&x| f(*x)).cloned().collect()
7472
}
7573

7674
fn take(&self, n: usize) -> Self {
77-
self.iter().take(n).map(|&x| x).collect()
75+
self.iter().take(n).cloned().collect()
7876
}
7977

8078
fn skip(&self, n: usize) -> Self {
81-
self.iter().skip(n).map(|&x| x).collect()
79+
self.iter().skip(n).cloned().collect()
8280
}
8381

8482
fn sum(&self) -> Self::Scalar {
@@ -93,11 +91,11 @@ impl FPVector for Vec<Complex<f64>> {
9391
impl Vector for Vec<Complex<f64>> {
9492
type Scalar = Complex<f64>;
9593

96-
fn add_vec<'a, 'b>(&'a self, rhs: &'b Self) -> Self {
94+
fn add_vec(&self, rhs: &Self) -> Self {
9795
self.zip_with(|x, y| x + y, rhs)
9896
}
9997

100-
fn sub_vec<'a, 'b>(&'a self, rhs: &'b Self) -> Self {
98+
fn sub_vec(&self, rhs: &Self) -> Self {
10199
self.zip_with(|x, y| x - y, rhs)
102100
}
103101

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,6 @@ pub mod statistics;
205205
pub mod structure;
206206
pub mod traits;
207207
pub mod util;
208+
209+
#[cfg(feature = "complex")]
210+
pub mod complex;

src/numerical/integral.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ where
240240
tol
241241
};
242242
if (G - K).abs() < tol_curr || a == b || max_iter == 0 {
243+
if ! G.is_finite() {
244+
return G;
245+
}
243246
I += G;
244247
} else {
245248
S.push((a, c, tol / 2f64, max_iter - 1));

0 commit comments

Comments
 (0)