spglue_times_meat.hpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup spglue_times
  16. //! @{
  17. template<typename T1, typename T2>
  18. inline
  19. void
  20. spglue_times::apply(SpMat<typename T1::elem_type>& out, const SpGlue<T1,T2,spglue_times>& X)
  21. {
  22. arma_extra_debug_sigprint();
  23. typedef typename T1::elem_type eT;
  24. const unwrap_spmat<T1> UA(X.A);
  25. const unwrap_spmat<T2> UB(X.B);
  26. const bool is_alias = (UA.is_alias(out) || UB.is_alias(out));
  27. if(is_alias == false)
  28. {
  29. spglue_times::apply_noalias(out, UA.M, UB.M);
  30. }
  31. else
  32. {
  33. SpMat<eT> tmp;
  34. spglue_times::apply_noalias(tmp, UA.M, UB.M);
  35. out.steal_mem(tmp);
  36. }
  37. }
  38. template<typename T1, typename T2>
  39. inline
  40. void
  41. spglue_times::apply(SpMat<typename T1::elem_type>& out, const SpGlue<SpOp<T1,spop_scalar_times>,T2,spglue_times>& X)
  42. {
  43. arma_extra_debug_sigprint();
  44. typedef typename T1::elem_type eT;
  45. const unwrap_spmat<T1> UA(X.A.m);
  46. const unwrap_spmat<T2> UB(X.B);
  47. const bool is_alias = (UA.is_alias(out) || UB.is_alias(out));
  48. if(is_alias == false)
  49. {
  50. spglue_times::apply_noalias(out, UA.M, UB.M);
  51. }
  52. else
  53. {
  54. SpMat<eT> tmp;
  55. spglue_times::apply_noalias(tmp, UA.M, UB.M);
  56. out.steal_mem(tmp);
  57. }
  58. out *= X.A.aux;
  59. }
  60. template<typename eT>
  61. arma_hot
  62. inline
  63. void
  64. spglue_times::apply_noalias(SpMat<eT>& c, const SpMat<eT>& x, const SpMat<eT>& y)
  65. {
  66. arma_extra_debug_sigprint();
  67. const uword x_n_rows = x.n_rows;
  68. const uword x_n_cols = x.n_cols;
  69. const uword y_n_rows = y.n_rows;
  70. const uword y_n_cols = y.n_cols;
  71. arma_debug_assert_mul_size(x_n_rows, x_n_cols, y_n_rows, y_n_cols, "matrix multiplication");
  72. // First we must determine the structure of the new matrix (column pointers).
  73. // This follows the algorithm described in 'Sparse Matrix Multiplication
  74. // Package (SMMP)' (R.E. Bank and C.C. Douglas, 2001). Their description of
  75. // "SYMBMM" does not include anything about memory allocation. In addition it
  76. // does not consider that there may be elements which space may be allocated
  77. // for but which evaluate to zero anyway. So we have to modify the algorithm
  78. // to work that way. For the "SYMBMM" implementation we will not determine
  79. // the row indices but instead just the column pointers.
  80. //SpMat<typename T1::elem_type> c(x_n_rows, y_n_cols); // Initializes col_ptrs to 0.
  81. c.zeros(x_n_rows, y_n_cols);
  82. //if( (x.n_elem == 0) || (y.n_elem == 0) )
  83. if( (x.n_nonzero == 0) || (y.n_nonzero == 0) )
  84. {
  85. return;
  86. }
  87. // Auxiliary storage which denotes when items have been found.
  88. podarray<uword> index(x_n_rows);
  89. index.fill(x_n_rows); // Fill with invalid links.
  90. typename SpMat<eT>::const_iterator y_it = y.begin();
  91. typename SpMat<eT>::const_iterator y_end = y.end();
  92. // SYMBMM: calculate column pointers for resultant matrix to obtain a good
  93. // upper bound on the number of nonzero elements.
  94. uword cur_col_length = 0;
  95. uword last_ind = x_n_rows + 1;
  96. do
  97. {
  98. const uword y_it_row = y_it.row();
  99. // Look through the column that this point (*y_it) could affect.
  100. typename SpMat<eT>::const_iterator x_it = x.begin_col_no_sync(y_it_row);
  101. while(x_it.col() == y_it_row)
  102. {
  103. const uword x_it_row = x_it.row();
  104. // A point at x(i, j) and y(j, k) implies a point at c(i, k).
  105. if(index[x_it_row] == x_n_rows)
  106. {
  107. index[x_it_row] = last_ind;
  108. last_ind = x_it_row;
  109. ++cur_col_length;
  110. }
  111. ++x_it;
  112. }
  113. const uword old_col = y_it.col();
  114. ++y_it;
  115. // See if column incremented.
  116. if(old_col != y_it.col())
  117. {
  118. // Set column pointer (this is not a cumulative count; that is done later).
  119. access::rw(c.col_ptrs[old_col + 1]) = cur_col_length;
  120. cur_col_length = 0;
  121. // Return index markers to zero. Use last_ind for traversal.
  122. while(last_ind != x_n_rows + 1)
  123. {
  124. const uword tmp = index[last_ind];
  125. index[last_ind] = x_n_rows;
  126. last_ind = tmp;
  127. }
  128. }
  129. }
  130. while(y_it != y_end);
  131. // Accumulate column pointers.
  132. for(uword i = 0; i < c.n_cols; ++i)
  133. {
  134. access::rw(c.col_ptrs[i + 1]) += c.col_ptrs[i];
  135. }
  136. // Now that we know a decent bound on the number of nonzero elements, allocate
  137. // the memory and fill it.
  138. c.mem_resize(c.col_ptrs[c.n_cols]);
  139. // Now the implementation of the NUMBMM algorithm.
  140. uword cur_pos = 0; // Current position in c matrix.
  141. podarray<eT> sums(x_n_rows); // Partial sums.
  142. sums.zeros();
  143. podarray<uword> sorted_indices(x_n_rows); // upper bound
  144. // last_ind is already set to x_n_rows, and cur_col_length is already set to 0.
  145. // We will loop through all columns as necessary.
  146. uword cur_col = 0;
  147. while(cur_col < c.n_cols)
  148. {
  149. // Skip to next column with elements in it.
  150. while((cur_col < c.n_cols) && (c.col_ptrs[cur_col] == c.col_ptrs[cur_col + 1]))
  151. {
  152. // Update current column pointer to actual number of nonzero elements up
  153. // to this point.
  154. access::rw(c.col_ptrs[cur_col]) = cur_pos;
  155. ++cur_col;
  156. }
  157. if(cur_col == c.n_cols)
  158. {
  159. break;
  160. }
  161. // Update current column pointer.
  162. access::rw(c.col_ptrs[cur_col]) = cur_pos;
  163. // Check all elements in this column.
  164. typename SpMat<eT>::const_iterator y_col_it = y.begin_col_no_sync(cur_col);
  165. while(y_col_it.col() == cur_col)
  166. {
  167. const uword y_col_it_row = y_col_it.row();
  168. // Check all elements in the column of the other matrix corresponding to
  169. // the row of this column.
  170. typename SpMat<eT>::const_iterator x_col_it = x.begin_col_no_sync(y_col_it_row);
  171. const eT y_value = (*y_col_it);
  172. while(x_col_it.col() == y_col_it_row)
  173. {
  174. const uword x_col_it_row = x_col_it.row();
  175. // A point at x(i, j) and y(j, k) implies a point at c(i, k).
  176. // Add to partial sum.
  177. const eT x_value = (*x_col_it);
  178. sums[x_col_it_row] += (x_value * y_value);
  179. // Add point if it hasn't already been marked.
  180. if(index[x_col_it_row] == x_n_rows)
  181. {
  182. index[x_col_it_row] = last_ind;
  183. last_ind = x_col_it_row;
  184. }
  185. ++x_col_it;
  186. }
  187. ++y_col_it;
  188. }
  189. // Now sort the indices that were used in this column.
  190. uword cur_index = 0;
  191. while(last_ind != x_n_rows + 1)
  192. {
  193. const uword tmp = last_ind;
  194. // Check that it wasn't a "fake" nonzero element.
  195. if(sums[tmp] != eT(0))
  196. {
  197. // Assign to next open position.
  198. sorted_indices[cur_index] = tmp;
  199. ++cur_index;
  200. }
  201. last_ind = index[tmp];
  202. index[tmp] = x_n_rows;
  203. }
  204. // Now sort the indices.
  205. if (cur_index != 0)
  206. {
  207. op_sort::direct_sort_ascending(sorted_indices.memptr(), cur_index);
  208. for(uword k = 0; k < cur_index; ++k)
  209. {
  210. const uword row = sorted_indices[k];
  211. access::rw(c.row_indices[cur_pos]) = row;
  212. access::rw(c.values[cur_pos]) = sums[row];
  213. sums[row] = eT(0);
  214. ++cur_pos;
  215. }
  216. }
  217. // Move to next column.
  218. ++cur_col;
  219. }
  220. // Update last column pointer and resize to actual memory size.
  221. access::rw(c.col_ptrs[c.n_cols]) = cur_pos;
  222. c.mem_resize(cur_pos);
  223. }
  224. //
  225. //
  226. //
  227. template<typename T1, typename T2>
  228. inline
  229. void
  230. spglue_times_misc::sparse_times_dense(Mat<typename T1::elem_type>& out, const T1& x, const T2& y)
  231. {
  232. arma_extra_debug_sigprint();
  233. typedef typename T1::elem_type eT;
  234. if(is_op_diagmat<T2>::value)
  235. {
  236. const SpMat<eT> tmp(y);
  237. out = x * tmp;
  238. }
  239. else
  240. {
  241. const unwrap_spmat<T1> UA(x);
  242. const quasi_unwrap<T2> UB(y);
  243. const SpMat<eT>& A = UA.M;
  244. const Mat<eT>& B = UB.M;
  245. if( (resolves_to_vector<T2>::no) && (B.is_vec() == false) && B.is_diagmat() )
  246. {
  247. const SpMat<eT> tmp(diagmat(B));
  248. out = A * tmp;
  249. return;
  250. }
  251. const uword A_n_rows = A.n_rows;
  252. const uword A_n_cols = A.n_cols;
  253. const uword B_n_rows = B.n_rows;
  254. const uword B_n_cols = B.n_cols;
  255. arma_debug_assert_mul_size(A_n_rows, A_n_cols, B_n_rows, B_n_cols, "matrix multiplication");
  256. if(B_n_cols >= (B_n_rows / uword(100)))
  257. {
  258. arma_extra_debug_print("using transpose-based multiplication");
  259. const SpMat<eT> At = A.st();
  260. const Mat<eT> Bt = B.st();
  261. if(A_n_rows == B_n_cols)
  262. {
  263. spglue_times_misc::dense_times_sparse(out, Bt, At);
  264. op_strans::apply_mat(out, out); // since 'out' is square-sized, this will do an inplace transpose
  265. }
  266. else
  267. {
  268. Mat<eT> tmp;
  269. spglue_times_misc::dense_times_sparse(tmp, Bt, At);
  270. op_strans::apply_mat(out, tmp);
  271. }
  272. }
  273. else
  274. {
  275. arma_extra_debug_print("using standard multiplication");
  276. out.zeros(A_n_rows, B_n_cols);
  277. typename SpMat<eT>::const_iterator A_it = A.begin();
  278. typename SpMat<eT>::const_iterator A_it_end = A.end();
  279. while(A_it != A_it_end)
  280. {
  281. const eT A_it_val = (*A_it);
  282. const uword A_it_row = A_it.row();
  283. const uword A_it_col = A_it.col();
  284. for(uword col = 0; col < B_n_cols; ++col)
  285. {
  286. out.at(A_it_row, col) += A_it_val * B.at(A_it_col, col);
  287. }
  288. ++A_it;
  289. }
  290. }
  291. }
  292. }
  293. template<typename T1, typename T2>
  294. inline
  295. void
  296. spglue_times_misc::dense_times_sparse(Mat<typename T1::elem_type>& out, const T1& x, const T2& y)
  297. {
  298. arma_extra_debug_sigprint();
  299. typedef typename T1::elem_type eT;
  300. if(is_op_diagmat<T1>::value)
  301. {
  302. const SpMat<eT> tmp(x);
  303. out = tmp * y;
  304. }
  305. else
  306. {
  307. const quasi_unwrap<T1> UA(x);
  308. const unwrap_spmat<T2> UB(y);
  309. const Mat<eT>& A = UA.M;
  310. const SpMat<eT>& B = UB.M;
  311. if( (resolves_to_vector<T1>::no) && (A.is_vec() == false) && A.is_diagmat() )
  312. {
  313. const SpMat<eT> tmp(diagmat(A));
  314. out = tmp * B;
  315. return;
  316. }
  317. arma_debug_assert_mul_size(A.n_rows, A.n_cols, B.n_rows, B.n_cols, "matrix multiplication");
  318. out.zeros(A.n_rows, B.n_cols);
  319. if( (A.n_elem > 0) && (B.n_nonzero > 0) )
  320. {
  321. if( (arma_config::openmp) && (mp_thread_limit::in_parallel() == false) && (A.n_rows <= (A.n_cols / uword(100))) )
  322. {
  323. #if defined(ARMA_USE_OPENMP)
  324. {
  325. arma_extra_debug_print("using parallelised multiplication");
  326. const uword B_n_cols = B.n_cols;
  327. const int n_threads = mp_thread_limit::get();
  328. #pragma omp parallel for schedule(static) num_threads(n_threads)
  329. for(uword i=0; i < B_n_cols; ++i)
  330. {
  331. const uword col_offset_1 = B.col_ptrs[i ];
  332. const uword col_offset_2 = B.col_ptrs[i+1];
  333. const uword col_offset_delta = col_offset_2 - col_offset_1;
  334. const uvec indices(const_cast<uword*>(&(B.row_indices[col_offset_1])), col_offset_delta, false, false);
  335. const Col<eT> B_col(const_cast< eT*>(&( B.values[col_offset_1])), col_offset_delta, false, false);
  336. out.col(i) = A.cols(indices) * B_col;
  337. }
  338. }
  339. #endif
  340. }
  341. else
  342. {
  343. arma_extra_debug_print("using standard multiplication");
  344. typename SpMat<eT>::const_iterator B_it = B.begin();
  345. typename SpMat<eT>::const_iterator B_it_end = B.end();
  346. const uword out_n_rows = out.n_rows;
  347. while(B_it != B_it_end)
  348. {
  349. const eT B_it_val = (*B_it);
  350. const uword B_it_col = B_it.col();
  351. const uword B_it_row = B_it.row();
  352. eT* out_col = out.colptr(B_it_col);
  353. for(uword row = 0; row < out_n_rows; ++row)
  354. {
  355. out_col[row] += A.at(row, B_it_row) * B_it_val;
  356. }
  357. ++B_it;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. //
  364. template<typename T1, typename T2>
  365. inline
  366. void
  367. spglue_times_mixed::apply(SpMat<typename eT_promoter<T1,T2>::eT>& out, const mtSpGlue<typename eT_promoter<T1,T2>::eT, T1, T2, spglue_times_mixed>& expr)
  368. {
  369. arma_extra_debug_sigprint();
  370. typedef typename T1::elem_type eT1;
  371. typedef typename T2::elem_type eT2;
  372. typedef typename eT_promoter<T1,T2>::eT out_eT;
  373. if( (is_same_type<eT1,out_eT>::no) && (is_same_type<eT2,out_eT>::yes) )
  374. {
  375. // upgrade T1
  376. const unwrap_spmat<T1> UA(expr.A);
  377. const unwrap_spmat<T2> UB(expr.B);
  378. const SpMat<eT1>& A = UA.M;
  379. const SpMat<eT2>& B = UB.M;
  380. SpMat<out_eT> AA(arma_layout_indicator(), A);
  381. for(uword i=0; i < A.n_nonzero; ++i) { access::rw(AA.values[i]) = out_eT(A.values[i]); }
  382. const SpMat<out_eT>& BB = reinterpret_cast< const SpMat<out_eT>& >(B);
  383. out = AA * BB;
  384. }
  385. else
  386. if( (is_same_type<eT1,out_eT>::yes) && (is_same_type<eT2,out_eT>::no) )
  387. {
  388. // upgrade T2
  389. const unwrap_spmat<T1> UA(expr.A);
  390. const unwrap_spmat<T2> UB(expr.B);
  391. const SpMat<eT1>& A = UA.M;
  392. const SpMat<eT2>& B = UB.M;
  393. const SpMat<out_eT>& AA = reinterpret_cast< const SpMat<out_eT>& >(A);
  394. SpMat<out_eT> BB(arma_layout_indicator(), B);
  395. for(uword i=0; i < B.n_nonzero; ++i) { access::rw(BB.values[i]) = out_eT(B.values[i]); }
  396. out = AA * BB;
  397. }
  398. else
  399. {
  400. // upgrade T1 and T2
  401. const unwrap_spmat<T1> UA(expr.A);
  402. const unwrap_spmat<T2> UB(expr.B);
  403. const SpMat<eT1>& A = UA.M;
  404. const SpMat<eT2>& B = UB.M;
  405. SpMat<out_eT> AA(arma_layout_indicator(), A);
  406. SpMat<out_eT> BB(arma_layout_indicator(), B);
  407. for(uword i=0; i < A.n_nonzero; ++i) { access::rw(AA.values[i]) = out_eT(A.values[i]); }
  408. for(uword i=0; i < B.n_nonzero; ++i) { access::rw(BB.values[i]) = out_eT(B.values[i]); }
  409. out = AA * BB;
  410. }
  411. }
  412. template<typename T1, typename T2>
  413. inline
  414. void
  415. spglue_times_mixed::sparse_times_dense(Mat< typename promote_type<typename T1::elem_type, typename T2::elem_type>::result >& out, const T1& X, const T2& Y)
  416. {
  417. arma_extra_debug_sigprint();
  418. typedef typename T1::elem_type eT1;
  419. typedef typename T2::elem_type eT2;
  420. typedef typename promote_type<eT1,eT2>::result out_eT;
  421. promote_type<eT1,eT2>::check();
  422. if( (is_same_type<eT1,out_eT>::no) && (is_same_type<eT2,out_eT>::yes) )
  423. {
  424. // upgrade T1
  425. const unwrap_spmat<T1> UA(X);
  426. const quasi_unwrap<T2> UB(Y);
  427. const SpMat<eT1>& A = UA.M;
  428. const Mat<eT2>& B = UB.M;
  429. SpMat<out_eT> AA(arma_layout_indicator(), A);
  430. for(uword i=0; i < A.n_nonzero; ++i) { access::rw(AA.values[i]) = out_eT(A.values[i]); }
  431. const Mat<out_eT>& BB = reinterpret_cast< const Mat<out_eT>& >(B);
  432. spglue_times_misc::sparse_times_dense(out, AA, BB);
  433. }
  434. else
  435. if( (is_same_type<eT1,out_eT>::yes) && (is_same_type<eT2,out_eT>::no) )
  436. {
  437. // upgrade T2
  438. const unwrap_spmat<T1> UA(X);
  439. const quasi_unwrap<T2> UB(Y);
  440. const SpMat<eT1>& A = UA.M;
  441. const Mat<eT2>& B = UB.M;
  442. const SpMat<out_eT>& AA = reinterpret_cast< const SpMat<out_eT>& >(A);
  443. const Mat<out_eT> BB = conv_to< Mat<out_eT> >::from(B);
  444. spglue_times_misc::sparse_times_dense(out, AA, BB);
  445. }
  446. else
  447. {
  448. // upgrade T1 and T2
  449. const unwrap_spmat<T1> UA(X);
  450. const quasi_unwrap<T2> UB(Y);
  451. const SpMat<eT1>& A = UA.M;
  452. const Mat<eT2>& B = UB.M;
  453. SpMat<out_eT> AA(arma_layout_indicator(), A);
  454. for(uword i=0; i < A.n_nonzero; ++i) { access::rw(AA.values[i]) = out_eT(A.values[i]); }
  455. const Mat<out_eT> BB = conv_to< Mat<out_eT> >::from(B);
  456. spglue_times_misc::sparse_times_dense(out, AA, BB);
  457. }
  458. }
  459. template<typename T1, typename T2>
  460. inline
  461. void
  462. spglue_times_mixed::dense_times_sparse(Mat< typename promote_type<typename T1::elem_type, typename T2::elem_type>::result >& out, const T1& X, const T2& Y)
  463. {
  464. arma_extra_debug_sigprint();
  465. typedef typename T1::elem_type eT1;
  466. typedef typename T2::elem_type eT2;
  467. typedef typename promote_type<eT1,eT2>::result out_eT;
  468. promote_type<eT1,eT2>::check();
  469. if( (is_same_type<eT1,out_eT>::no) && (is_same_type<eT2,out_eT>::yes) )
  470. {
  471. // upgrade T1
  472. const quasi_unwrap<T1> UA(X);
  473. const unwrap_spmat<T2> UB(Y);
  474. const Mat<eT1>& A = UA.M;
  475. const SpMat<eT2>& B = UB.M;
  476. const Mat<out_eT> AA = conv_to< Mat<out_eT> >::from(A);
  477. const SpMat<out_eT>& BB = reinterpret_cast< const SpMat<out_eT>& >(B);
  478. spglue_times_misc::dense_times_sparse(out, AA, BB);
  479. }
  480. else
  481. if( (is_same_type<eT1,out_eT>::yes) && (is_same_type<eT2,out_eT>::no) )
  482. {
  483. // upgrade T2
  484. const quasi_unwrap<T1> UA(X);
  485. const unwrap_spmat<T2> UB(Y);
  486. const Mat<eT1>& A = UA.M;
  487. const SpMat<eT2>& B = UB.M;
  488. const Mat<out_eT>& AA = reinterpret_cast< const Mat<out_eT>& >(A);
  489. SpMat<out_eT> BB(arma_layout_indicator(), B);
  490. for(uword i=0; i < B.n_nonzero; ++i) { access::rw(BB.values[i]) = out_eT(B.values[i]); }
  491. spglue_times_misc::dense_times_sparse(out, AA, BB);
  492. }
  493. else
  494. {
  495. // upgrade T1 and T2
  496. const quasi_unwrap<T1> UA(X);
  497. const unwrap_spmat<T2> UB(Y);
  498. const Mat<eT1>& A = UA.M;
  499. const SpMat<eT2>& B = UB.M;
  500. const Mat<out_eT> AA = conv_to< Mat<out_eT> >::from(A);
  501. SpMat<out_eT> BB(arma_layout_indicator(), B);
  502. for(uword i=0; i < B.n_nonzero; ++i) { access::rw(BB.values[i]) = out_eT(B.values[i]); }
  503. spglue_times_misc::dense_times_sparse(out, AA, BB);
  504. }
  505. }
  506. //! @}