Skip to content

Commit a9b68f9

Browse files
committed
Ver 0.39.4
- Optimize `integrate`
2 parents 8e22171 + 6ff4307 commit a9b68f9

File tree

13 files changed

+1541
-695
lines changed

13 files changed

+1541
-695
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "peroxide"
3-
version = "0.39.3"
3+
version = "0.39.4"
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"
@@ -29,8 +29,8 @@ criterion = { version = "0.5.1", features = ["html_reports"] }
2929

3030
[dependencies]
3131
csv = { version = "1.3", optional = true, default-features = false }
32-
rand = { version = "0.8", features = ["small_rng"] }
33-
rand_distr = "0.4"
32+
rand = { version = "0.9", features = ["small_rng"] }
33+
rand_distr = "0.5"
3434
order-stat = "0.1"
3535
puruspe = "0.4"
3636
matrixmultiply = { version = "0.3", features = ["threading"] }

RELEASES.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Release 0.39.4 (2025-04-11)
2+
3+
## Optimize `integrate`
4+
5+
- Replace the output signature of `gauss_legendre_table` and `kronrod_table` to `&'static [f64]` to avoid unnecessary allocations.
6+
- Hard code symmetry of weights and nodes into source code to avoid unnecessary allocations.
7+
- New helper function - `compute_gauss_kronrod_sum_stored`
8+
- Reduce the number of function calls (G+K -> K)
9+
- Change update method of subinterval tolerance (divide by 2 -> divide by sqrt(2))
10+
- These changes improve the performance of `integrate` by 1.2x - 50x (to integrate highly oscillatory functions)
11+
12+
## Update dependencies
13+
14+
- Update `rand` to `0.9`
15+
- Update `rand_distr` to `0.5`
16+
117
# Release 0.39.3 (2025-03-13)
218

319
- Update `puruspe` to `0.4.0`

src/fuga/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ pub use crate::util::plot::*;
205205

206206
pub use anyhow;
207207
pub use paste;
208+
pub use rand::prelude::*;
208209

209210
// =============================================================================
210211
// Enums

src/macros/matlab_macro.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate rand;
2-
pub use self::rand::prelude::*;
3-
41
/// MATLAB like zeros - zero matrix
52
///
63
/// # Examples
@@ -45,18 +42,18 @@ macro_rules! zeros {
4542
#[macro_export]
4643
macro_rules! rand {
4744
() => {{
48-
let mut rng = thread_rng();
49-
rng.gen_range(0f64..=1f64)
45+
let mut rng = rand::rng();
46+
rng.random_range(0f64..=1f64)
5047
}};
5148

5249
( $m:expr, $n:expr ) => {{
5350
let r = $m;
5451
let c = $n;
55-
let mut rng = thread_rng();
52+
let mut rng = rand::rng();
5653
let mut m = matrix(vec![0f64; r * c], r, c, Row);
5754
for i in 0..r {
5855
for j in 0..c {
59-
m[(i, j)] = rng.gen_range(0f64..=1f64);
56+
m[(i, j)] = rng.random_range(0f64..=1f64);
6057
}
6158
}
6259
m

src/macros/r_macro.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
//! * `pt`
1717
//! * `lm`
1818
19-
extern crate rand;
20-
pub use self::rand::prelude::*;
21-
2219
/// R like concatenate (Type: Vec\<f64\>)
2320
///
2421
/// # Examples
@@ -278,10 +275,10 @@ macro_rules! runif {
278275
let n: usize = $x0;
279276
let mut v = vec![0f64; n];
280277

281-
let mut rng = thread_rng();
278+
let mut rng = rand::rng();
282279

283280
for i in 0..n {
284-
v[i] = rng.gen_range($start as f64..=$end as f64);
281+
v[i] = rng.random_range($start as f64..=$end as f64);
285282
}
286283
v
287284
}};

0 commit comments

Comments
 (0)