pub fn mul_acc_mat_vec_csr<N, I, Iptr, V>(
    mat: CsMatViewI<N, I, Iptr>,
    in_vec: V,
    res_vec: &mut [N],
) where
    N: Num + Copy,
    I: SpIndex,
    Iptr: SpIndex,
    V: DenseVector<N>,
{
    if mat.cols() != in_vec.dim() || mat.rows() != res_vec.len() {
        panic!("Dimension mismatch");
    }
    if !mat.is_csr() {
        panic!("Storage mismatch");
    }

    for (row_ind, vec) in mat.outer_iterator().enumerate() {
        for (col_ind, &value) in vec.iter() {
            // TODO: unsafe access to value? needs bench
            res_vec[row_ind] =
                res_vec[row_ind] + *in_vec.index(col_ind) * value;
        }
    }
}
/// Multiply a sparse CSR matrix with a dense vector and accumulate the result
/// into another dense vector
Multiply a sparse CSR matrix with a dense vector and accumulate the result
into another dense vector
Multiply a sparse CSR matrix with a dense vector and accumulate the result into another dense vector
pub fn mul_acc_mat_vec_csr<N, I, Iptr, V>(
    mat: CsMatViewI<N, I, Iptr>,
    in_vec: V,
    res_vec: &mut [N],
) where
    N: Num + Copy,
    I: SpIndex,
    Iptr: SpIndex,
    V: DenseVector<N>,
{
    if mat.cols() != in_vec.dim() || mat.rows() != res_vec.len() {
        panic!("Dimension mismatch");
    }
    if !mat.is_csr() {
        panic!("Storage mismatch");
    }
    for (row_ind, vec) in mat.outer_iterator().enumerate() {
        for (col_ind, &value) in vec.iter() {
            // TODO: unsafe access to value? needs bench
            res_vec[row_ind] =
                res_vec[row_ind] + *in_vec.index(col_ind) * value;
        }
    }
}
pub fn mul_acc_mat_vec_csr < N , I , Iptr , V > ( mat : CsMatViewI < N , I , Iptr > , in_vec : V , res_vec : & mut [ N ] , ) where N : Num + Copy , I : SpIndex , Iptr : SpIndex , V : DenseVector < N > , { if mat . cols ( ) != in_vec . dim ( ) || mat . rows ( ) != res_vec . len ( ) { panic ! ( " " ) ; } if ! mat . is_csr ( ) { panic ! ( " " ) ; } for ( row_ind , vec ) in mat . outer_iterator ( ) . enumerate ( ) { for ( col_ind , & value ) in vec . iter ( ) { // TODO: unsafe access to value? needs bench res_vec [ row_ind ] = res_vec [ row_ind ] + * in_vec . index ( col_ind ) * value ; } } }
Multiply a sparse CSR matrix with a dense vector and accumulate the result
into another dense vector
Multiply a sparse CSR matrix with a dense vector and accumulate the result into another dense vector
mat
CsMatViewI<N, I, Iptr>
in_vec
V
res_vec
&mut [N]
mat
CsMatViewI<N, I, Iptr>
in_vec
V
res_vec
&mut [N]