From e3fd0e739328d796117140d84cbf6f73bd7e3f8d Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 1 Apr 2022 15:26:36 -0600 Subject: [PATCH] remove the checked suffix to keep backward compatibility --- nalgebra-sparse/src/ops/serial/cs.rs | 2 +- nalgebra-sparse/src/ops/serial/csc.rs | 18 +++++++++--------- nalgebra-sparse/src/ops/serial/csr.rs | 20 +++++++++----------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/nalgebra-sparse/src/ops/serial/cs.rs b/nalgebra-sparse/src/ops/serial/cs.rs index f3a14924..f65b5071 100644 --- a/nalgebra-sparse/src/ops/serial/cs.rs +++ b/nalgebra-sparse/src/ops/serial/cs.rs @@ -63,7 +63,7 @@ where Ok(()) } -pub fn spmm_cs_prealloc_checked( +pub fn spmm_cs_prealloc( beta: T, c: &mut CsMatrix, alpha: T, diff --git a/nalgebra-sparse/src/ops/serial/csc.rs b/nalgebra-sparse/src/ops/serial/csc.rs index 42d27079..6a691ef9 100644 --- a/nalgebra-sparse/src/ops/serial/csc.rs +++ b/nalgebra-sparse/src/ops/serial/csc.rs @@ -1,6 +1,6 @@ use crate::csc::CscMatrix; use crate::ops::serial::cs::{ - spadd_cs_prealloc, spmm_cs_dense, spmm_cs_prealloc_checked, spmm_cs_prealloc_unchecked, + spadd_cs_prealloc, spmm_cs_dense, spmm_cs_prealloc, spmm_cs_prealloc_unchecked, }; use crate::ops::serial::{OperationError, OperationErrorKind}; use crate::ops::Op; @@ -73,7 +73,7 @@ where /// # Panics /// /// Panics if the dimensions of the matrices involved are not compatible with the expression. -pub fn spmm_csc_prealloc_checked( +pub fn spmm_csc_prealloc( beta: T, c: &mut CscMatrix, alpha: T, @@ -90,9 +90,9 @@ where match (&a, &b) { (NoOp(ref a), NoOp(ref b)) => { // Note: We have to reverse the order for CSC matrices - spmm_cs_prealloc_checked(beta, &mut c.cs, alpha, &b.cs, &a.cs) + spmm_cs_prealloc(beta, &mut c.cs, alpha, &b.cs, &a.cs) } - _ => do_transposes(beta, c, alpha, a, b, spmm_csc_prealloc_checked), + _ => spmm_csc_transposed(beta, c, alpha, a, b, spmm_csc_prealloc), } } @@ -101,7 +101,7 @@ where /// Should be used for situations where pattern creation immediately preceeds multiplication. /// /// Panics if the dimensions of the matrices involved are not compatible with the expression. -pub(crate) fn spmm_csc_prealloc_unchecked( +pub fn spmm_csc_prealloc_unchecked( beta: T, c: &mut CscMatrix, alpha: T, @@ -120,17 +120,17 @@ where // Note: We have to reverse the order for CSC matrices spmm_cs_prealloc_unchecked(beta, &mut c.cs, alpha, &b.cs, &a.cs) } - _ => do_transposes(beta, c, alpha, a, b, spmm_csc_prealloc_unchecked), + _ => spmm_csc_transposed(beta, c, alpha, a, b, spmm_csc_prealloc_unchecked), } } -fn do_transposes( +fn spmm_csc_transposed( beta: T, c: &mut CscMatrix, alpha: T, a: Op<&CscMatrix>, b: Op<&CscMatrix>, - caller: F, + spmm_kernel: F, ) -> Result<(), OperationError> where T: Scalar + ClosedAdd + ClosedMul + Zero + One, @@ -157,7 +157,7 @@ where (Transpose(ref a), Transpose(ref b)) => (Owned(a.transpose()), Owned(b.transpose())), } }; - caller(beta, c, alpha, NoOp(a.as_ref()), NoOp(b.as_ref())) + spmm_kernel(beta, c, alpha, NoOp(a.as_ref()), NoOp(b.as_ref())) } /// Solve the lower triangular system `op(L) X = B`. diff --git a/nalgebra-sparse/src/ops/serial/csr.rs b/nalgebra-sparse/src/ops/serial/csr.rs index 967c02f2..708c81a3 100644 --- a/nalgebra-sparse/src/ops/serial/csr.rs +++ b/nalgebra-sparse/src/ops/serial/csr.rs @@ -1,6 +1,6 @@ use crate::csr::CsrMatrix; use crate::ops::serial::cs::{ - spadd_cs_prealloc, spmm_cs_dense, spmm_cs_prealloc_checked, spmm_cs_prealloc_unchecked, + spadd_cs_prealloc, spmm_cs_dense, spmm_cs_prealloc, spmm_cs_prealloc_unchecked, }; use crate::ops::serial::OperationError; use crate::ops::Op; @@ -67,7 +67,7 @@ where /// # Panics /// /// Panics if the dimensions of the matrices involved are not compatible with the expression. -pub fn spmm_csr_prealloc_checked( +pub fn spmm_csr_prealloc( beta: T, c: &mut CsrMatrix, alpha: T, @@ -82,10 +82,8 @@ where use Op::NoOp; match (&a, &b) { - (NoOp(ref a), NoOp(ref b)) => { - spmm_cs_prealloc_checked(beta, &mut c.cs, alpha, &a.cs, &b.cs) - } - _ => do_transposes(beta, c, alpha, a, b, spmm_csr_prealloc_checked), + (NoOp(ref a), NoOp(ref b)) => spmm_cs_prealloc(beta, &mut c.cs, alpha, &a.cs, &b.cs), + _ => spmm_csr_transposed(beta, c, alpha, a, b, spmm_csr_prealloc), } } @@ -94,7 +92,7 @@ where /// Should be used for situations where pattern creation immediately preceeds multiplication. /// /// Panics if the dimensions of the matrices involved are not compatible with the expression. -pub(crate) fn spmm_csr_prealloc_unchecked( +pub fn spmm_csr_prealloc_unchecked( beta: T, c: &mut CsrMatrix, alpha: T, @@ -112,17 +110,17 @@ where (NoOp(ref a), NoOp(ref b)) => { spmm_cs_prealloc_unchecked(beta, &mut c.cs, alpha, &a.cs, &b.cs) } - _ => do_transposes(beta, c, alpha, a, b, spmm_csr_prealloc_unchecked), + _ => spmm_csr_transposed(beta, c, alpha, a, b, spmm_csr_prealloc_unchecked), } } -fn do_transposes( +fn spmm_csr_transposed( beta: T, c: &mut CsrMatrix, alpha: T, a: Op<&CsrMatrix>, b: Op<&CsrMatrix>, - caller: F, + spmm_kernel: F, ) -> Result<(), OperationError> where T: Scalar + ClosedAdd + ClosedMul + Zero + One, @@ -149,5 +147,5 @@ where (Transpose(ref a), Transpose(ref b)) => (Owned(a.transpose()), Owned(b.transpose())), } }; - caller(beta, c, alpha, NoOp(a.as_ref()), NoOp(b.as_ref())) + spmm_kernel(beta, c, alpha, NoOp(a.as_ref()), NoOp(b.as_ref())) }