subview_elem2_meat.hpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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 subview_elem2
  16. //! @{
  17. template<typename eT, typename T1, typename T2>
  18. inline
  19. subview_elem2<eT,T1,T2>::~subview_elem2()
  20. {
  21. arma_extra_debug_sigprint();
  22. }
  23. template<typename eT, typename T1, typename T2>
  24. arma_inline
  25. subview_elem2<eT,T1,T2>::subview_elem2
  26. (
  27. const Mat<eT>& in_m,
  28. const Base<uword,T1>& in_ri,
  29. const Base<uword,T2>& in_ci,
  30. const bool in_all_rows,
  31. const bool in_all_cols
  32. )
  33. : m (in_m )
  34. , base_ri (in_ri )
  35. , base_ci (in_ci )
  36. , all_rows (in_all_rows)
  37. , all_cols (in_all_cols)
  38. {
  39. arma_extra_debug_sigprint();
  40. }
  41. template<typename eT, typename T1, typename T2>
  42. template<typename op_type>
  43. inline
  44. void
  45. subview_elem2<eT,T1,T2>::inplace_op(const eT val)
  46. {
  47. arma_extra_debug_sigprint();
  48. Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
  49. const uword m_n_rows = m_local.n_rows;
  50. const uword m_n_cols = m_local.n_cols;
  51. if( (all_rows == false) && (all_cols == false) )
  52. {
  53. const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
  54. const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
  55. const umat& ri = tmp1.M;
  56. const umat& ci = tmp2.M;
  57. arma_debug_check
  58. (
  59. ( ((ri.is_vec() == false) && (ri.is_empty() == false)) || ((ci.is_vec() == false) && (ci.is_empty() == false)) ),
  60. "Mat::elem(): given object is not a vector"
  61. );
  62. const uword* ri_mem = ri.memptr();
  63. const uword ri_n_elem = ri.n_elem;
  64. const uword* ci_mem = ci.memptr();
  65. const uword ci_n_elem = ci.n_elem;
  66. for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
  67. {
  68. const uword col = ci_mem[ci_count];
  69. arma_debug_check( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
  70. for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
  71. {
  72. const uword row = ri_mem[ri_count];
  73. arma_debug_check( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
  74. if(is_same_type<op_type, op_internal_equ >::yes) { m_local.at(row,col) = val; }
  75. if(is_same_type<op_type, op_internal_plus >::yes) { m_local.at(row,col) += val; }
  76. if(is_same_type<op_type, op_internal_minus>::yes) { m_local.at(row,col) -= val; }
  77. if(is_same_type<op_type, op_internal_schur>::yes) { m_local.at(row,col) *= val; }
  78. if(is_same_type<op_type, op_internal_div >::yes) { m_local.at(row,col) /= val; }
  79. }
  80. }
  81. }
  82. else
  83. if( (all_rows == true) && (all_cols == false) )
  84. {
  85. const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
  86. const umat& ci = tmp2.M;
  87. arma_debug_check
  88. (
  89. ( (ci.is_vec() == false) && (ci.is_empty() == false) ),
  90. "Mat::elem(): given object is not a vector"
  91. );
  92. const uword* ci_mem = ci.memptr();
  93. const uword ci_n_elem = ci.n_elem;
  94. for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
  95. {
  96. const uword col = ci_mem[ci_count];
  97. arma_debug_check( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
  98. eT* colptr = m_local.colptr(col);
  99. if(is_same_type<op_type, op_internal_equ >::yes) { arrayops::inplace_set (colptr, val, m_n_rows); }
  100. if(is_same_type<op_type, op_internal_plus >::yes) { arrayops::inplace_plus (colptr, val, m_n_rows); }
  101. if(is_same_type<op_type, op_internal_minus>::yes) { arrayops::inplace_minus(colptr, val, m_n_rows); }
  102. if(is_same_type<op_type, op_internal_schur>::yes) { arrayops::inplace_mul (colptr, val, m_n_rows); }
  103. if(is_same_type<op_type, op_internal_div >::yes) { arrayops::inplace_div (colptr, val, m_n_rows); }
  104. }
  105. }
  106. else
  107. if( (all_rows == false) && (all_cols == true) )
  108. {
  109. const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
  110. const umat& ri = tmp1.M;
  111. arma_debug_check
  112. (
  113. ( (ri.is_vec() == false) && (ri.is_empty() == false) ),
  114. "Mat::elem(): given object is not a vector"
  115. );
  116. const uword* ri_mem = ri.memptr();
  117. const uword ri_n_elem = ri.n_elem;
  118. for(uword col=0; col < m_n_cols; ++col)
  119. {
  120. for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
  121. {
  122. const uword row = ri_mem[ri_count];
  123. arma_debug_check( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
  124. if(is_same_type<op_type, op_internal_equ >::yes) { m_local.at(row,col) = val; }
  125. if(is_same_type<op_type, op_internal_plus >::yes) { m_local.at(row,col) += val; }
  126. if(is_same_type<op_type, op_internal_minus>::yes) { m_local.at(row,col) -= val; }
  127. if(is_same_type<op_type, op_internal_schur>::yes) { m_local.at(row,col) *= val; }
  128. if(is_same_type<op_type, op_internal_div >::yes) { m_local.at(row,col) /= val; }
  129. }
  130. }
  131. }
  132. }
  133. template<typename eT, typename T1, typename T2>
  134. template<typename op_type, typename expr>
  135. inline
  136. void
  137. subview_elem2<eT,T1,T2>::inplace_op(const Base<eT,expr>& x)
  138. {
  139. arma_extra_debug_sigprint();
  140. Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
  141. const uword m_n_rows = m_local.n_rows;
  142. const uword m_n_cols = m_local.n_cols;
  143. const unwrap_check<expr> tmp(x.get_ref(), m_local);
  144. const Mat<eT>& X = tmp.M;
  145. if( (all_rows == false) && (all_cols == false) )
  146. {
  147. const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
  148. const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
  149. const umat& ri = tmp1.M;
  150. const umat& ci = tmp2.M;
  151. arma_debug_check
  152. (
  153. ( ((ri.is_vec() == false) && (ri.is_empty() == false)) || ((ci.is_vec() == false) && (ci.is_empty() == false)) ),
  154. "Mat::elem(): given object is not a vector"
  155. );
  156. const uword* ri_mem = ri.memptr();
  157. const uword ri_n_elem = ri.n_elem;
  158. const uword* ci_mem = ci.memptr();
  159. const uword ci_n_elem = ci.n_elem;
  160. arma_debug_assert_same_size( ri_n_elem, ci_n_elem, X.n_rows, X.n_cols, "Mat::elem()" );
  161. for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
  162. {
  163. const uword col = ci_mem[ci_count];
  164. arma_debug_check( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
  165. for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
  166. {
  167. const uword row = ri_mem[ri_count];
  168. arma_debug_check( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
  169. if(is_same_type<op_type, op_internal_equ >::yes) { m_local.at(row,col) = X.at(ri_count, ci_count); }
  170. if(is_same_type<op_type, op_internal_plus >::yes) { m_local.at(row,col) += X.at(ri_count, ci_count); }
  171. if(is_same_type<op_type, op_internal_minus>::yes) { m_local.at(row,col) -= X.at(ri_count, ci_count); }
  172. if(is_same_type<op_type, op_internal_schur>::yes) { m_local.at(row,col) *= X.at(ri_count, ci_count); }
  173. if(is_same_type<op_type, op_internal_div >::yes) { m_local.at(row,col) /= X.at(ri_count, ci_count); }
  174. }
  175. }
  176. }
  177. else
  178. if( (all_rows == true) && (all_cols == false) )
  179. {
  180. const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
  181. const umat& ci = tmp2.M;
  182. arma_debug_check
  183. (
  184. ( (ci.is_vec() == false) && (ci.is_empty() == false) ),
  185. "Mat::elem(): given object is not a vector"
  186. );
  187. const uword* ci_mem = ci.memptr();
  188. const uword ci_n_elem = ci.n_elem;
  189. arma_debug_assert_same_size( m_n_rows, ci_n_elem, X.n_rows, X.n_cols, "Mat::elem()" );
  190. for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
  191. {
  192. const uword col = ci_mem[ci_count];
  193. arma_debug_check( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
  194. eT* m_colptr = m_local.colptr(col);
  195. const eT* X_colptr = X.colptr(ci_count);
  196. if(is_same_type<op_type, op_internal_equ >::yes) { arrayops::copy (m_colptr, X_colptr, m_n_rows); }
  197. if(is_same_type<op_type, op_internal_plus >::yes) { arrayops::inplace_plus (m_colptr, X_colptr, m_n_rows); }
  198. if(is_same_type<op_type, op_internal_minus>::yes) { arrayops::inplace_minus(m_colptr, X_colptr, m_n_rows); }
  199. if(is_same_type<op_type, op_internal_schur>::yes) { arrayops::inplace_mul (m_colptr, X_colptr, m_n_rows); }
  200. if(is_same_type<op_type, op_internal_div >::yes) { arrayops::inplace_div (m_colptr, X_colptr, m_n_rows); }
  201. }
  202. }
  203. else
  204. if( (all_rows == false) && (all_cols == true) )
  205. {
  206. const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
  207. const umat& ri = tmp1.M;
  208. arma_debug_check
  209. (
  210. ( (ri.is_vec() == false) && (ri.is_empty() == false) ),
  211. "Mat::elem(): given object is not a vector"
  212. );
  213. const uword* ri_mem = ri.memptr();
  214. const uword ri_n_elem = ri.n_elem;
  215. arma_debug_assert_same_size( ri_n_elem, m_n_cols, X.n_rows, X.n_cols, "Mat::elem()" );
  216. for(uword col=0; col < m_n_cols; ++col)
  217. {
  218. for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
  219. {
  220. const uword row = ri_mem[ri_count];
  221. arma_debug_check( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
  222. if(is_same_type<op_type, op_internal_equ >::yes) { m_local.at(row,col) = X.at(ri_count, col); }
  223. if(is_same_type<op_type, op_internal_plus >::yes) { m_local.at(row,col) += X.at(ri_count, col); }
  224. if(is_same_type<op_type, op_internal_minus>::yes) { m_local.at(row,col) -= X.at(ri_count, col); }
  225. if(is_same_type<op_type, op_internal_schur>::yes) { m_local.at(row,col) *= X.at(ri_count, col); }
  226. if(is_same_type<op_type, op_internal_div >::yes) { m_local.at(row,col) /= X.at(ri_count, col); }
  227. }
  228. }
  229. }
  230. }
  231. //
  232. //
  233. template<typename eT, typename T1, typename T2>
  234. inline
  235. void
  236. subview_elem2<eT,T1,T2>::fill(const eT val)
  237. {
  238. arma_extra_debug_sigprint();
  239. inplace_op<op_internal_equ>(val);
  240. }
  241. template<typename eT, typename T1, typename T2>
  242. inline
  243. void
  244. subview_elem2<eT,T1,T2>::zeros()
  245. {
  246. arma_extra_debug_sigprint();
  247. inplace_op<op_internal_equ>(eT(0));
  248. }
  249. template<typename eT, typename T1, typename T2>
  250. inline
  251. void
  252. subview_elem2<eT,T1,T2>::ones()
  253. {
  254. arma_extra_debug_sigprint();
  255. inplace_op<op_internal_equ>(eT(1));
  256. }
  257. template<typename eT, typename T1, typename T2>
  258. inline
  259. void
  260. subview_elem2<eT,T1,T2>::operator+= (const eT val)
  261. {
  262. arma_extra_debug_sigprint();
  263. inplace_op<op_internal_plus>(val);
  264. }
  265. template<typename eT, typename T1, typename T2>
  266. inline
  267. void
  268. subview_elem2<eT,T1,T2>::operator-= (const eT val)
  269. {
  270. arma_extra_debug_sigprint();
  271. inplace_op<op_internal_minus>(val);
  272. }
  273. template<typename eT, typename T1, typename T2>
  274. inline
  275. void
  276. subview_elem2<eT,T1,T2>::operator*= (const eT val)
  277. {
  278. arma_extra_debug_sigprint();
  279. inplace_op<op_internal_schur>(val);
  280. }
  281. template<typename eT, typename T1, typename T2>
  282. inline
  283. void
  284. subview_elem2<eT,T1,T2>::operator/= (const eT val)
  285. {
  286. arma_extra_debug_sigprint();
  287. inplace_op<op_internal_div>(val);
  288. }
  289. //
  290. //
  291. template<typename eT, typename T1, typename T2>
  292. template<typename T3, typename T4>
  293. inline
  294. void
  295. subview_elem2<eT,T1,T2>::operator_equ(const subview_elem2<eT,T3,T4>& x)
  296. {
  297. arma_extra_debug_sigprint();
  298. inplace_op<op_internal_equ>(x);
  299. }
  300. template<typename eT, typename T1, typename T2>
  301. template<typename T3, typename T4>
  302. inline
  303. void
  304. subview_elem2<eT,T1,T2>::operator= (const subview_elem2<eT,T3,T4>& x)
  305. {
  306. arma_extra_debug_sigprint();
  307. (*this).operator_equ(x);
  308. }
  309. //! work around compiler bugs
  310. template<typename eT, typename T1, typename T2>
  311. inline
  312. void
  313. subview_elem2<eT,T1,T2>::operator= (const subview_elem2<eT,T1,T2>& x)
  314. {
  315. arma_extra_debug_sigprint();
  316. (*this).operator_equ(x);
  317. }
  318. template<typename eT, typename T1, typename T2>
  319. template<typename T3, typename T4>
  320. inline
  321. void
  322. subview_elem2<eT,T1,T2>::operator+= (const subview_elem2<eT,T3,T4>& x)
  323. {
  324. arma_extra_debug_sigprint();
  325. inplace_op<op_internal_plus>(x);
  326. }
  327. template<typename eT, typename T1, typename T2>
  328. template<typename T3, typename T4>
  329. inline
  330. void
  331. subview_elem2<eT,T1,T2>::operator-= (const subview_elem2<eT,T3,T4>& x)
  332. {
  333. arma_extra_debug_sigprint();
  334. inplace_op<op_internal_minus>(x);
  335. }
  336. template<typename eT, typename T1, typename T2>
  337. template<typename T3, typename T4>
  338. inline
  339. void
  340. subview_elem2<eT,T1,T2>::operator%= (const subview_elem2<eT,T3,T4>& x)
  341. {
  342. arma_extra_debug_sigprint();
  343. inplace_op<op_internal_schur>(x);
  344. }
  345. template<typename eT, typename T1, typename T2>
  346. template<typename T3, typename T4>
  347. inline
  348. void
  349. subview_elem2<eT,T1,T2>::operator/= (const subview_elem2<eT,T3,T4>& x)
  350. {
  351. arma_extra_debug_sigprint();
  352. inplace_op<op_internal_div>(x);
  353. }
  354. template<typename eT, typename T1, typename T2>
  355. template<typename expr>
  356. inline
  357. void
  358. subview_elem2<eT,T1,T2>::operator= (const Base<eT,expr>& x)
  359. {
  360. arma_extra_debug_sigprint();
  361. inplace_op<op_internal_equ>(x);
  362. }
  363. template<typename eT, typename T1, typename T2>
  364. template<typename expr>
  365. inline
  366. void
  367. subview_elem2<eT,T1,T2>::operator+= (const Base<eT,expr>& x)
  368. {
  369. arma_extra_debug_sigprint();
  370. inplace_op<op_internal_plus>(x);
  371. }
  372. template<typename eT, typename T1, typename T2>
  373. template<typename expr>
  374. inline
  375. void
  376. subview_elem2<eT,T1,T2>::operator-= (const Base<eT,expr>& x)
  377. {
  378. arma_extra_debug_sigprint();
  379. inplace_op<op_internal_minus>(x);
  380. }
  381. template<typename eT, typename T1, typename T2>
  382. template<typename expr>
  383. inline
  384. void
  385. subview_elem2<eT,T1,T2>::operator%= (const Base<eT,expr>& x)
  386. {
  387. arma_extra_debug_sigprint();
  388. inplace_op<op_internal_schur>(x);
  389. }
  390. template<typename eT, typename T1, typename T2>
  391. template<typename expr>
  392. inline
  393. void
  394. subview_elem2<eT,T1,T2>::operator/= (const Base<eT,expr>& x)
  395. {
  396. arma_extra_debug_sigprint();
  397. inplace_op<op_internal_div>(x);
  398. }
  399. //
  400. //
  401. template<typename eT, typename T1, typename T2>
  402. inline
  403. void
  404. subview_elem2<eT,T1,T2>::extract(Mat<eT>& actual_out, const subview_elem2<eT,T1,T2>& in)
  405. {
  406. arma_extra_debug_sigprint();
  407. Mat<eT>& m_local = const_cast< Mat<eT>& >(in.m);
  408. const uword m_n_rows = m_local.n_rows;
  409. const uword m_n_cols = m_local.n_cols;
  410. const bool alias = (&actual_out == &m_local);
  411. if(alias) { arma_extra_debug_print("subview_elem2::extract(): aliasing detected"); }
  412. Mat<eT>* tmp_out = alias ? new Mat<eT>() : 0;
  413. Mat<eT>& out = alias ? *tmp_out : actual_out;
  414. if( (in.all_rows == false) && (in.all_cols == false) )
  415. {
  416. const unwrap_check_mixed<T1> tmp1(in.base_ri.get_ref(), actual_out);
  417. const unwrap_check_mixed<T2> tmp2(in.base_ci.get_ref(), actual_out);
  418. const umat& ri = tmp1.M;
  419. const umat& ci = tmp2.M;
  420. arma_debug_check
  421. (
  422. ( ((ri.is_vec() == false) && (ri.is_empty() == false)) || ((ci.is_vec() == false) && (ci.is_empty() == false)) ),
  423. "Mat::elem(): given object is not a vector"
  424. );
  425. const uword* ri_mem = ri.memptr();
  426. const uword ri_n_elem = ri.n_elem;
  427. const uword* ci_mem = ci.memptr();
  428. const uword ci_n_elem = ci.n_elem;
  429. out.set_size(ri_n_elem, ci_n_elem);
  430. eT* out_mem = out.memptr();
  431. uword out_count = 0;
  432. for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
  433. {
  434. const uword col = ci_mem[ci_count];
  435. arma_debug_check( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
  436. for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
  437. {
  438. const uword row = ri_mem[ri_count];
  439. arma_debug_check( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
  440. out_mem[out_count] = m_local.at(row,col);
  441. ++out_count;
  442. }
  443. }
  444. }
  445. else
  446. if( (in.all_rows == true) && (in.all_cols == false) )
  447. {
  448. const unwrap_check_mixed<T2> tmp2(in.base_ci.get_ref(), m_local);
  449. const umat& ci = tmp2.M;
  450. arma_debug_check
  451. (
  452. ( (ci.is_vec() == false) && (ci.is_empty() == false) ),
  453. "Mat::elem(): given object is not a vector"
  454. );
  455. const uword* ci_mem = ci.memptr();
  456. const uword ci_n_elem = ci.n_elem;
  457. out.set_size(m_n_rows, ci_n_elem);
  458. for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
  459. {
  460. const uword col = ci_mem[ci_count];
  461. arma_debug_check( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
  462. arrayops::copy( out.colptr(ci_count), m_local.colptr(col), m_n_rows );
  463. }
  464. }
  465. else
  466. if( (in.all_rows == false) && (in.all_cols == true) )
  467. {
  468. const unwrap_check_mixed<T1> tmp1(in.base_ri.get_ref(), m_local);
  469. const umat& ri = tmp1.M;
  470. arma_debug_check
  471. (
  472. ( (ri.is_vec() == false) && (ri.is_empty() == false) ),
  473. "Mat::elem(): given object is not a vector"
  474. );
  475. const uword* ri_mem = ri.memptr();
  476. const uword ri_n_elem = ri.n_elem;
  477. out.set_size(ri_n_elem, m_n_cols);
  478. for(uword col=0; col < m_n_cols; ++col)
  479. {
  480. for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
  481. {
  482. const uword row = ri_mem[ri_count];
  483. arma_debug_check( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
  484. out.at(ri_count,col) = m_local.at(row,col);
  485. }
  486. }
  487. }
  488. if(alias)
  489. {
  490. actual_out.steal_mem(out);
  491. delete tmp_out;
  492. }
  493. }
  494. // TODO: implement a dedicated function instead of creating a temporary (but lots of potential aliasing issues)
  495. template<typename eT, typename T1, typename T2>
  496. inline
  497. void
  498. subview_elem2<eT,T1,T2>::plus_inplace(Mat<eT>& out, const subview_elem2& in)
  499. {
  500. arma_extra_debug_sigprint();
  501. const Mat<eT> tmp(in);
  502. out += tmp;
  503. }
  504. template<typename eT, typename T1, typename T2>
  505. inline
  506. void
  507. subview_elem2<eT,T1,T2>::minus_inplace(Mat<eT>& out, const subview_elem2& in)
  508. {
  509. arma_extra_debug_sigprint();
  510. const Mat<eT> tmp(in);
  511. out -= tmp;
  512. }
  513. template<typename eT, typename T1, typename T2>
  514. inline
  515. void
  516. subview_elem2<eT,T1,T2>::schur_inplace(Mat<eT>& out, const subview_elem2& in)
  517. {
  518. arma_extra_debug_sigprint();
  519. const Mat<eT> tmp(in);
  520. out %= tmp;
  521. }
  522. template<typename eT, typename T1, typename T2>
  523. inline
  524. void
  525. subview_elem2<eT,T1,T2>::div_inplace(Mat<eT>& out, const subview_elem2& in)
  526. {
  527. arma_extra_debug_sigprint();
  528. const Mat<eT> tmp(in);
  529. out /= tmp;
  530. }
  531. //! @}