Skip to content

Commit ba10ac9

Browse files
authored
Merge pull request #6 from SingleRust/feature-dev-randomized-centering
Version upgrade to 1.0.0
2 parents cc1b3f4 + a9d5b16 commit ba10ac9

6 files changed

Lines changed: 661 additions & 213 deletions

File tree

Cargo.lock

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

Cargo.toml

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

1111
[dependencies]
1212
anyhow = "1.0.97"
13-
argmin = { version = "0.10.0", features = ["rayon"] }
13+
#argmin = { version = "0.10.0", features = ["rayon"] }
1414
nalgebra-sparse = "0.10.0"
1515
num-traits = "0.2.19"
1616
rand = "0.9.0"

src/lanczos/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ where
168168
Ok(SvdRec {
169169
// Dimensionality (number of Ut,Vt rows & length of S)
170170
d: r.d,
171-
ut: Array2::from_shape_vec((r.d, r.Ut.cols), r.Ut.value)?,
171+
u: Array2::from_shape_vec((r.d, r.Ut.cols), r.Ut.value)?,
172172
s: Array::from_shape_vec(r.d, r.S)?,
173173
vt: Array2::from_shape_vec((r.d, r.Vt.cols), r.Vt.value)?,
174174
diagnostics: Diagnostics {
@@ -1402,7 +1402,7 @@ fn lanso<T: SvdFloat>(
14021402
impl<T: SvdFloat + 'static> SvdRec<T> {
14031403
pub fn recompose(&self) -> Array2<T> {
14041404
let sdiag = Array2::from_diag(&self.s);
1405-
self.ut.t().dot(&sdiag).dot(&self.vt)
1405+
self.u.dot(&sdiag).dot(&self.vt)
14061406
}
14071407
}
14081408

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,18 @@ mod simple_comparison_tests {
166166
#[test]
167167
fn test_random_svd_computation() {
168168

169-
// Create a matrix with high sparsity (99%)
170169
let test_matrix = create_sparse_matrix(1000, 250, 0.01); // 1% non-zeros
171170

172-
// Convert to CSR for processing
173171
let csr = CsrMatrix::from(&test_matrix);
174172

175-
// Run randomized SVD with reasonable defaults for a sparse matrix
176173
let result = randomized::randomized_svd(
177174
&csr,
178-
50, // target rank
179-
10, // oversampling parameter
180-
3, // power iterations
181-
randomized::PowerIterationNormalizer::QR, // use QR normalization
182-
Some(42), // random seed
175+
50,
176+
10,
177+
3,
178+
randomized::PowerIterationNormalizer::QR,
179+
false,
180+
Some(42),
183181
);
184182

185183
// Verify the computation succeeds on a highly sparse matrix
@@ -206,8 +204,8 @@ mod simple_comparison_tests {
206204
}
207205

208206
// Verify basics of U and V dimensions
209-
assert_eq!(svd_result.ut.nrows(), 50, "U transpose should have 50 rows");
210-
assert_eq!(svd_result.ut.ncols(), 1000, "U transpose should have 1000 columns");
207+
assert_eq!(svd_result.u.nrows(), 50, "U transpose should have 50 rows");
208+
assert_eq!(svd_result.u.ncols(), 1000, "U transpose should have 1000 columns");
211209
assert_eq!(svd_result.vt.nrows(), 50, "V transpose should have 50 rows");
212210
assert_eq!(svd_result.vt.ncols(), 250, "V transpose should have 250 columns");
213211

@@ -232,6 +230,7 @@ mod simple_comparison_tests {
232230
10, // oversampling parameter
233231
7, // power iterations
234232
randomized::PowerIterationNormalizer::QR, // use QR normalization
233+
false,
235234
Some(42), // random seed
236235
)
237236
});
@@ -263,6 +262,7 @@ mod simple_comparison_tests {
263262
10, // oversampling parameter
264263
2, // power iterations
265264
randomized::PowerIterationNormalizer::QR, // use QR normalization
265+
false,
266266
Some(42), // random seed
267267
)
268268
});

0 commit comments

Comments
 (0)