Skip to content

Commit 9ccc368

Browse files
author
Ian
committed
updated single-svdlib, updated dependencies, added local transfer between ndarray and nalgebra
1 parent bc5f967 commit 9ccc368

File tree

4 files changed

+149
-49
lines changed

4 files changed

+149
-49
lines changed

Cargo.lock

Lines changed: 121 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@ description = "A Rust port of LAS2 from SVDLIBC"
44
keywords = ["svd"]
55
categories = ["algorithms", "data-structures", "mathematics", "science"]
66
name = "single-svdlib"
7-
version = "1.0.6"
7+
version = "1.0.8"
88
edition = "2021"
99
license-file = "SVDLIBC-LICENSE.txt"
1010

1111
[features]
1212
# simd = ["dep:simba", "single-utilities/simd"]
1313

1414
[dependencies]
15-
anyhow = "1.0.97"
16-
nalgebra-sparse = "0.10.0"
15+
anyhow = "1.0"
16+
nalgebra-sparse = "0.11.0"
1717
num-traits = "0.2.19"
1818
rand = "0.9.0"
1919
rand_distr = "0.5.1"
2020
rayon = "1.10.0"
2121
thiserror = "2.0.9"
22-
nshare = {version = "0.10.0", features = ["nalgebra", "ndarray"] }
23-
ndarray = "0.16.1"
24-
single-utilities = "0.8.0"
25-
nalgebra = {version = "0.33.2", features = ["rayon"] }
26-
simba = {version = "0.9.0", optional = true}
22+
ndarray = "0.16"
23+
single-utilities = "0.8.7"
24+
nalgebra = {version = "0.34", features = ["rayon"] }

src/randomized/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::error::SvdLibError;
2-
use crate::{Diagnostics, SMat, SvdFloat, SvdRec};
2+
use crate::{Diagnostics, IntoNdarray2, SMat, SvdFloat, SvdRec};
33
use nalgebra_sparse::na::{ComplexField, DMatrix, DVector, RealField};
44
use ndarray::Array1;
5-
use nshare::IntoNdarray2;
65
use rand::prelude::{Distribution, StdRng};
76
use rand::SeedableRng;
87
use rand_distr::Normal;

src/utils.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use rayon::iter::ParallelIterator;
22
use nalgebra_sparse::na::{DMatrix, DVector};
3-
use ndarray::{Array1, Array2};
3+
use ndarray::{Array1, Array2, ShapeBuilder};
44
use num_traits::{Float, Zero};
55
use rayon::prelude::{IntoParallelIterator, IndexedParallelIterator};
66
use single_utilities::traits::FloatOpsTS;
77
use std::fmt::Debug;
8+
use nalgebra::{Dim, Dyn, Scalar};
89

910
pub fn determine_chunk_size(nrows: usize) -> usize {
1011
let num_threads = rayon::current_num_threads();
@@ -110,3 +111,22 @@ impl SvdFloat for f64 {
110111
(b - a).abs() < f64::EPSILON
111112
}
112113
}
114+
115+
pub trait IntoNdarray2 {
116+
type Out;
117+
118+
fn into_ndarray2(self) -> Self::Out;
119+
}
120+
121+
impl<N: Scalar> IntoNdarray2 for nalgebra::Matrix<N, Dyn, Dyn, nalgebra::VecStorage<N, Dyn, Dyn>>
122+
where
123+
nalgebra::DefaultAllocator:
124+
nalgebra::allocator::Allocator<Dyn, Dyn, Buffer<N> = nalgebra::VecStorage<N, Dyn, Dyn>>,
125+
{
126+
type Out = ndarray::Array2<N>;
127+
128+
fn into_ndarray2(self) -> Self::Out {
129+
ndarray::Array2::from_shape_vec(self.shape().strides(self.strides()), self.data.into())
130+
.unwrap()
131+
}
132+
}

0 commit comments

Comments
 (0)