20 #ifndef TENSOR_MMULT_TENSOR_SPARSE_H
21 #define TENSOR_MMULT_TENSOR_SPARSE_H
27 template<
typename elt_t>
29 mult_t_sp(elt_t *dest,
31 const index *row_start,
const index *column,
const elt_t *matrix,
32 index i_len, index j_len, index k_len, index l_len)
35 for (index j = 0; j < j_len; j++, vector += i_len) {
36 for (index x = row_start[j]; x < row_start[j+1]; x++) {
38 elt_t *d = dest + l * (k_len*i_len);
39 const elt_t *v = vector;
41 for (index k = 0; k < k_len; k++) {
42 for (index i = 0; i < i_len; i++, d++) {
55 template<
typename elt_t>
56 static inline const Tensor<elt_t>
57 do_mmult(
const Tensor<elt_t> &m1,
const Sparse<elt_t> &m2)
62 for (index k = 0; k < N-1; k++) {
63 dims.at(k) = m1.dimension(k);
66 index j_len = m1.dimension(-1);
67 index l_len = dims.at(N-1) = m2.columns();
69 if (j_len != m2.rows()) {
71 "In mmult(T,S), the last index of tensor T does not match the number of rows\n"
72 "in sparse matrix S.";
78 mult_t_sp<elt_t>(output.begin(),
80 m2.priv_row_start().begin(),
81 m2.priv_column().begin(), m2.priv_data().begin(),
82 i_len, j_len, 1, l_len);
static const Tensor< elt_t > zeros(index rows)
Matrix of zeros.