Skip to content

Commit 8d99a0f

Browse files
add regression test
1 parent 40686e2 commit 8d99a0f

File tree

1 file changed

+17
-0
lines changed
  • poly/src/evaluations/multivariate/multilinear

1 file changed

+17
-0
lines changed

poly/src/evaluations/multivariate/multilinear/sparse.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,23 @@ mod tests {
450450
}
451451
}
452452

453+
#[test]
454+
fn sparse_to_evaluations_matches_to_dense() {
455+
let mut rng = test_rng();
456+
const NV: usize = 8; // 2^8 = 256, small and fast
457+
458+
for _ in 0..25 {
459+
// Make a sparse poly with ~sqrt(2^NV) non-zeros at random indices.
460+
let sparse = SparseMultilinearExtension::<Fr>::rand(NV, &mut rng);
461+
let dense_via_sparse = sparse.to_dense_multilinear_extension().evaluations;
462+
let dense_via_to_evals = sparse.to_evaluations();
463+
assert_eq!(
464+
dense_via_to_evals, dense_via_sparse,
465+
"to_evaluations must reproduce the dense vector exactly"
466+
);
467+
}
468+
}
469+
453470
#[test]
454471
fn evaluate_edge_cases() {
455472
// test constant polynomial

0 commit comments

Comments
 (0)