Row_meat.hpp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719
  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 Row
  16. //! @{
  17. //! construct an empty row vector
  18. template<typename eT>
  19. inline
  20. Row<eT>::Row()
  21. : Mat<eT>(arma_vec_indicator(), 2)
  22. {
  23. arma_extra_debug_sigprint();
  24. }
  25. template<typename eT>
  26. inline
  27. Row<eT>::Row(const Row<eT>& X)
  28. : Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 2)
  29. {
  30. arma_extra_debug_sigprint();
  31. arrayops::copy((*this).memptr(), X.memptr(), X.n_elem);
  32. }
  33. //! construct a row vector with the specified number of n_elem
  34. template<typename eT>
  35. inline
  36. Row<eT>::Row(const uword in_n_elem)
  37. : Mat<eT>(arma_vec_indicator(), 1, in_n_elem, 2)
  38. {
  39. arma_extra_debug_sigprint();
  40. }
  41. template<typename eT>
  42. inline
  43. Row<eT>::Row(const uword in_n_rows, const uword in_n_cols)
  44. : Mat<eT>(arma_vec_indicator(), 0, 0, 2)
  45. {
  46. arma_extra_debug_sigprint();
  47. Mat<eT>::init_warm(in_n_rows, in_n_cols);
  48. }
  49. template<typename eT>
  50. inline
  51. Row<eT>::Row(const SizeMat& s)
  52. : Mat<eT>(arma_vec_indicator(), 0, 0, 2)
  53. {
  54. arma_extra_debug_sigprint();
  55. Mat<eT>::init_warm(s.n_rows, s.n_cols);
  56. }
  57. template<typename eT>
  58. template<typename fill_type>
  59. inline
  60. Row<eT>::Row(const uword in_n_elem, const fill::fill_class<fill_type>& f)
  61. : Mat<eT>(arma_vec_indicator(), 1, in_n_elem, 2)
  62. {
  63. arma_extra_debug_sigprint();
  64. (*this).fill(f);
  65. }
  66. template<typename eT>
  67. template<typename fill_type>
  68. inline
  69. Row<eT>::Row(const uword in_n_rows, const uword in_n_cols, const fill::fill_class<fill_type>& f)
  70. : Mat<eT>(arma_vec_indicator(), 0, 0, 2)
  71. {
  72. arma_extra_debug_sigprint();
  73. Mat<eT>::init_warm(in_n_rows, in_n_cols);
  74. (*this).fill(f);
  75. }
  76. template<typename eT>
  77. template<typename fill_type>
  78. inline
  79. Row<eT>::Row(const SizeMat& s, const fill::fill_class<fill_type>& f)
  80. : Mat<eT>(arma_vec_indicator(), 0, 0, 2)
  81. {
  82. arma_extra_debug_sigprint();
  83. Mat<eT>::init_warm(s.n_rows, s.n_cols);
  84. (*this).fill(f);
  85. }
  86. template<typename eT>
  87. inline
  88. Row<eT>::Row(const char* text)
  89. : Mat<eT>(arma_vec_indicator(), 2)
  90. {
  91. arma_extra_debug_sigprint();
  92. (*this).operator=(text);
  93. }
  94. template<typename eT>
  95. inline
  96. Row<eT>&
  97. Row<eT>::operator=(const char* text)
  98. {
  99. arma_extra_debug_sigprint();
  100. Mat<eT> tmp(text);
  101. arma_debug_check( ((tmp.n_elem > 0) && (tmp.is_vec() == false)), "Mat::init(): requested size is not compatible with row vector layout" );
  102. access::rw(tmp.n_rows) = 1;
  103. access::rw(tmp.n_cols) = tmp.n_elem;
  104. (*this).steal_mem(tmp);
  105. return *this;
  106. }
  107. template<typename eT>
  108. inline
  109. Row<eT>::Row(const std::string& text)
  110. : Mat<eT>(arma_vec_indicator(), 2)
  111. {
  112. arma_extra_debug_sigprint();
  113. (*this).operator=(text);
  114. }
  115. template<typename eT>
  116. inline
  117. Row<eT>&
  118. Row<eT>::operator=(const std::string& text)
  119. {
  120. arma_extra_debug_sigprint();
  121. Mat<eT> tmp(text);
  122. arma_debug_check( ((tmp.n_elem > 0) && (tmp.is_vec() == false)), "Mat::init(): requested size is not compatible with row vector layout" );
  123. access::rw(tmp.n_rows) = 1;
  124. access::rw(tmp.n_cols) = tmp.n_elem;
  125. (*this).steal_mem(tmp);
  126. return *this;
  127. }
  128. //! create a row vector from std::vector
  129. template<typename eT>
  130. inline
  131. Row<eT>::Row(const std::vector<eT>& x)
  132. : Mat<eT>(arma_vec_indicator(), 1, uword(x.size()), 2)
  133. {
  134. arma_extra_debug_sigprint_this(this);
  135. if(x.size() > 0)
  136. {
  137. arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) );
  138. }
  139. }
  140. //! create a row vector from std::vector
  141. template<typename eT>
  142. inline
  143. Row<eT>&
  144. Row<eT>::operator=(const std::vector<eT>& x)
  145. {
  146. arma_extra_debug_sigprint();
  147. Mat<eT>::init_warm(1, uword(x.size()));
  148. if(x.size() > 0)
  149. {
  150. arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) );
  151. }
  152. return *this;
  153. }
  154. #if defined(ARMA_USE_CXX11)
  155. template<typename eT>
  156. inline
  157. Row<eT>::Row(const std::initializer_list<eT>& list)
  158. : Mat<eT>(arma_vec_indicator(), 2)
  159. {
  160. arma_extra_debug_sigprint();
  161. (*this).operator=(list);
  162. }
  163. template<typename eT>
  164. inline
  165. Row<eT>&
  166. Row<eT>::operator=(const std::initializer_list<eT>& list)
  167. {
  168. arma_extra_debug_sigprint();
  169. Mat<eT> tmp(list);
  170. arma_debug_check( ((tmp.n_elem > 0) && (tmp.is_vec() == false)), "Mat::init(): requested size is not compatible with row vector layout" );
  171. access::rw(tmp.n_rows) = 1;
  172. access::rw(tmp.n_cols) = tmp.n_elem;
  173. (*this).steal_mem(tmp);
  174. return *this;
  175. }
  176. template<typename eT>
  177. inline
  178. Row<eT>::Row(Row<eT>&& X)
  179. : Mat<eT>(arma_vec_indicator(), 2)
  180. {
  181. arma_extra_debug_sigprint(arma_str::format("this = %x X = %x") % this % &X);
  182. access::rw(Mat<eT>::n_rows) = 1;
  183. access::rw(Mat<eT>::n_cols) = X.n_cols;
  184. access::rw(Mat<eT>::n_elem) = X.n_elem;
  185. if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || (X.mem_state == 1) || (X.mem_state == 2) )
  186. {
  187. access::rw(Mat<eT>::mem_state) = X.mem_state;
  188. access::rw(Mat<eT>::mem) = X.mem;
  189. access::rw(X.n_rows) = 1;
  190. access::rw(X.n_cols) = 0;
  191. access::rw(X.n_elem) = 0;
  192. access::rw(X.mem_state) = 0;
  193. access::rw(X.mem) = 0;
  194. }
  195. else
  196. {
  197. (*this).init_cold();
  198. arrayops::copy( (*this).memptr(), X.mem, X.n_elem );
  199. if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) )
  200. {
  201. access::rw(X.n_rows) = 1;
  202. access::rw(X.n_cols) = 0;
  203. access::rw(X.n_elem) = 0;
  204. access::rw(X.mem) = 0;
  205. }
  206. }
  207. }
  208. template<typename eT>
  209. inline
  210. Row<eT>&
  211. Row<eT>::operator=(Row<eT>&& X)
  212. {
  213. arma_extra_debug_sigprint(arma_str::format("this = %x X = %x") % this % &X);
  214. (*this).steal_mem(X);
  215. if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) && (this != &X) )
  216. {
  217. access::rw(X.n_rows) = 1;
  218. access::rw(X.n_cols) = 0;
  219. access::rw(X.n_elem) = 0;
  220. access::rw(X.mem) = 0;
  221. }
  222. return *this;
  223. }
  224. #endif
  225. template<typename eT>
  226. inline
  227. Row<eT>&
  228. Row<eT>::operator=(const eT val)
  229. {
  230. arma_extra_debug_sigprint();
  231. Mat<eT>::operator=(val);
  232. return *this;
  233. }
  234. template<typename eT>
  235. inline
  236. Row<eT>&
  237. Row<eT>::operator=(const Row<eT>& X)
  238. {
  239. arma_extra_debug_sigprint();
  240. Mat<eT>::operator=(X);
  241. return *this;
  242. }
  243. template<typename eT>
  244. template<typename T1>
  245. inline
  246. Row<eT>::Row(const Base<eT,T1>& X)
  247. : Mat<eT>(arma_vec_indicator(), 2)
  248. {
  249. arma_extra_debug_sigprint();
  250. Mat<eT>::operator=(X.get_ref());
  251. }
  252. template<typename eT>
  253. template<typename T1>
  254. inline
  255. Row<eT>&
  256. Row<eT>::operator=(const Base<eT,T1>& X)
  257. {
  258. arma_extra_debug_sigprint();
  259. Mat<eT>::operator=(X.get_ref());
  260. return *this;
  261. }
  262. template<typename eT>
  263. template<typename T1>
  264. inline
  265. Row<eT>::Row(const SpBase<eT,T1>& X)
  266. : Mat<eT>(arma_vec_indicator(), 2)
  267. {
  268. arma_extra_debug_sigprint();
  269. Mat<eT>::operator=(X.get_ref());
  270. }
  271. template<typename eT>
  272. template<typename T1>
  273. inline
  274. Row<eT>&
  275. Row<eT>::operator=(const SpBase<eT,T1>& X)
  276. {
  277. arma_extra_debug_sigprint();
  278. Mat<eT>::operator=(X.get_ref());
  279. return *this;
  280. }
  281. //! construct a row vector from a given auxiliary array
  282. template<typename eT>
  283. inline
  284. Row<eT>::Row(eT* aux_mem, const uword aux_length, const bool copy_aux_mem, const bool strict)
  285. : Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict)
  286. {
  287. arma_extra_debug_sigprint();
  288. access::rw(Mat<eT>::vec_state) = 2;
  289. }
  290. //! construct a row vector from a given auxiliary array
  291. template<typename eT>
  292. inline
  293. Row<eT>::Row(const eT* aux_mem, const uword aux_length)
  294. : Mat<eT>(aux_mem, 1, aux_length)
  295. {
  296. arma_extra_debug_sigprint();
  297. access::rw(Mat<eT>::vec_state) = 2;
  298. }
  299. template<typename eT>
  300. template<typename T1, typename T2>
  301. inline
  302. Row<eT>::Row
  303. (
  304. const Base<typename Row<eT>::pod_type, T1>& A,
  305. const Base<typename Row<eT>::pod_type, T2>& B
  306. )
  307. {
  308. arma_extra_debug_sigprint();
  309. access::rw(Mat<eT>::vec_state) = 2;
  310. Mat<eT>::init(A,B);
  311. }
  312. template<typename eT>
  313. template<typename T1>
  314. inline
  315. Row<eT>::Row(const BaseCube<eT,T1>& X)
  316. {
  317. arma_extra_debug_sigprint();
  318. access::rw(Mat<eT>::vec_state) = 2;
  319. Mat<eT>::operator=(X);
  320. }
  321. template<typename eT>
  322. template<typename T1>
  323. inline
  324. Row<eT>&
  325. Row<eT>::operator=(const BaseCube<eT,T1>& X)
  326. {
  327. arma_extra_debug_sigprint();
  328. Mat<eT>::operator=(X);
  329. return *this;
  330. }
  331. template<typename eT>
  332. inline
  333. Row<eT>::Row(const subview_cube<eT>& X)
  334. {
  335. arma_extra_debug_sigprint();
  336. access::rw(Mat<eT>::vec_state) = 2;
  337. Mat<eT>::operator=(X);
  338. }
  339. template<typename eT>
  340. inline
  341. Row<eT>&
  342. Row<eT>::operator=(const subview_cube<eT>& X)
  343. {
  344. arma_extra_debug_sigprint();
  345. Mat<eT>::operator=(X);
  346. return *this;
  347. }
  348. template<typename eT>
  349. inline
  350. mat_injector< Row<eT> >
  351. Row<eT>::operator<<(const eT val)
  352. {
  353. return mat_injector< Row<eT> >(*this, val);
  354. }
  355. template<typename eT>
  356. arma_inline
  357. const Op<Row<eT>,op_htrans>
  358. Row<eT>::t() const
  359. {
  360. return Op<Row<eT>,op_htrans>(*this);
  361. }
  362. template<typename eT>
  363. arma_inline
  364. const Op<Row<eT>,op_htrans>
  365. Row<eT>::ht() const
  366. {
  367. return Op<Row<eT>,op_htrans>(*this);
  368. }
  369. template<typename eT>
  370. arma_inline
  371. const Op<Row<eT>,op_strans>
  372. Row<eT>::st() const
  373. {
  374. return Op<Row<eT>,op_strans>(*this);
  375. }
  376. template<typename eT>
  377. arma_inline
  378. const Op<Row<eT>,op_strans>
  379. Row<eT>::as_col() const
  380. {
  381. return Op<Row<eT>,op_strans>(*this);
  382. }
  383. template<typename eT>
  384. arma_inline
  385. subview_row<eT>
  386. Row<eT>::col(const uword in_col1)
  387. {
  388. arma_extra_debug_sigprint();
  389. arma_debug_check( (in_col1 >= Mat<eT>::n_cols), "Row::col(): indices out of bounds or incorrectly used");
  390. return subview_row<eT>(*this, 0, in_col1, 1);
  391. }
  392. template<typename eT>
  393. arma_inline
  394. const subview_row<eT>
  395. Row<eT>::col(const uword in_col1) const
  396. {
  397. arma_extra_debug_sigprint();
  398. arma_debug_check( (in_col1 >= Mat<eT>::n_cols), "Row::col(): indices out of bounds or incorrectly used");
  399. return subview_row<eT>(*this, 0, in_col1, 1);
  400. }
  401. template<typename eT>
  402. arma_inline
  403. subview_row<eT>
  404. Row<eT>::cols(const uword in_col1, const uword in_col2)
  405. {
  406. arma_extra_debug_sigprint();
  407. arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::cols(): indices out of bounds or incorrectly used");
  408. const uword subview_n_cols = in_col2 - in_col1 + 1;
  409. return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
  410. }
  411. template<typename eT>
  412. arma_inline
  413. const subview_row<eT>
  414. Row<eT>::cols(const uword in_col1, const uword in_col2) const
  415. {
  416. arma_extra_debug_sigprint();
  417. arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::cols(): indices out of bounds or incorrectly used");
  418. const uword subview_n_cols = in_col2 - in_col1 + 1;
  419. return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
  420. }
  421. template<typename eT>
  422. arma_inline
  423. subview_row<eT>
  424. Row<eT>::subvec(const uword in_col1, const uword in_col2)
  425. {
  426. arma_extra_debug_sigprint();
  427. arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::subvec(): indices out of bounds or incorrectly used");
  428. const uword subview_n_cols = in_col2 - in_col1 + 1;
  429. return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
  430. }
  431. template<typename eT>
  432. arma_inline
  433. const subview_row<eT>
  434. Row<eT>::subvec(const uword in_col1, const uword in_col2) const
  435. {
  436. arma_extra_debug_sigprint();
  437. arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::subvec(): indices out of bounds or incorrectly used");
  438. const uword subview_n_cols = in_col2 - in_col1 + 1;
  439. return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
  440. }
  441. template<typename eT>
  442. arma_inline
  443. subview_row<eT>
  444. Row<eT>::cols(const span& col_span)
  445. {
  446. arma_extra_debug_sigprint();
  447. return subvec(col_span);
  448. }
  449. template<typename eT>
  450. arma_inline
  451. const subview_row<eT>
  452. Row<eT>::cols(const span& col_span) const
  453. {
  454. arma_extra_debug_sigprint();
  455. return subvec(col_span);
  456. }
  457. template<typename eT>
  458. arma_inline
  459. subview_row<eT>
  460. Row<eT>::subvec(const span& col_span)
  461. {
  462. arma_extra_debug_sigprint();
  463. const bool col_all = col_span.whole;
  464. const uword local_n_cols = Mat<eT>::n_cols;
  465. const uword in_col1 = col_all ? 0 : col_span.a;
  466. const uword in_col2 = col_span.b;
  467. const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
  468. arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly used");
  469. return subview_row<eT>(*this, 0, in_col1, subvec_n_cols);
  470. }
  471. template<typename eT>
  472. arma_inline
  473. const subview_row<eT>
  474. Row<eT>::subvec(const span& col_span) const
  475. {
  476. arma_extra_debug_sigprint();
  477. const bool col_all = col_span.whole;
  478. const uword local_n_cols = Mat<eT>::n_cols;
  479. const uword in_col1 = col_all ? 0 : col_span.a;
  480. const uword in_col2 = col_span.b;
  481. const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
  482. arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly used");
  483. return subview_row<eT>(*this, 0, in_col1, subvec_n_cols);
  484. }
  485. template<typename eT>
  486. arma_inline
  487. subview_row<eT>
  488. Row<eT>::operator()(const span& col_span)
  489. {
  490. arma_extra_debug_sigprint();
  491. return subvec(col_span);
  492. }
  493. template<typename eT>
  494. arma_inline
  495. const subview_row<eT>
  496. Row<eT>::operator()(const span& col_span) const
  497. {
  498. arma_extra_debug_sigprint();
  499. return subvec(col_span);
  500. }
  501. template<typename eT>
  502. arma_inline
  503. subview_row<eT>
  504. Row<eT>::subvec(const uword start_col, const SizeMat& s)
  505. {
  506. arma_extra_debug_sigprint();
  507. arma_debug_check( (s.n_rows != 1), "Row::subvec(): given size does not specify a row vector" );
  508. arma_debug_check( ( (start_col >= Mat<eT>::n_cols) || ((start_col + s.n_cols) > Mat<eT>::n_cols) ), "Row::subvec(): size out of bounds" );
  509. return subview_row<eT>(*this, 0, start_col, s.n_cols);
  510. }
  511. template<typename eT>
  512. arma_inline
  513. const subview_row<eT>
  514. Row<eT>::subvec(const uword start_col, const SizeMat& s) const
  515. {
  516. arma_extra_debug_sigprint();
  517. arma_debug_check( (s.n_rows != 1), "Row::subvec(): given size does not specify a row vector" );
  518. arma_debug_check( ( (start_col >= Mat<eT>::n_cols) || ((start_col + s.n_cols) > Mat<eT>::n_cols) ), "Row::subvec(): size out of bounds" );
  519. return subview_row<eT>(*this, 0, start_col, s.n_cols);
  520. }
  521. template<typename eT>
  522. arma_inline
  523. subview_row<eT>
  524. Row<eT>::head(const uword N)
  525. {
  526. arma_extra_debug_sigprint();
  527. arma_debug_check( (N > Mat<eT>::n_cols), "Row::head(): size out of bounds");
  528. return subview_row<eT>(*this, 0, 0, N);
  529. }
  530. template<typename eT>
  531. arma_inline
  532. const subview_row<eT>
  533. Row<eT>::head(const uword N) const
  534. {
  535. arma_extra_debug_sigprint();
  536. arma_debug_check( (N > Mat<eT>::n_cols), "Row::head(): size out of bounds");
  537. return subview_row<eT>(*this, 0, 0, N);
  538. }
  539. template<typename eT>
  540. arma_inline
  541. subview_row<eT>
  542. Row<eT>::tail(const uword N)
  543. {
  544. arma_extra_debug_sigprint();
  545. arma_debug_check( (N > Mat<eT>::n_cols), "Row::tail(): size out of bounds");
  546. const uword start_col = Mat<eT>::n_cols - N;
  547. return subview_row<eT>(*this, 0, start_col, N);
  548. }
  549. template<typename eT>
  550. arma_inline
  551. const subview_row<eT>
  552. Row<eT>::tail(const uword N) const
  553. {
  554. arma_extra_debug_sigprint();
  555. arma_debug_check( (N > Mat<eT>::n_cols), "Row::tail(): size out of bounds");
  556. const uword start_col = Mat<eT>::n_cols - N;
  557. return subview_row<eT>(*this, 0, start_col, N);
  558. }
  559. template<typename eT>
  560. arma_inline
  561. subview_row<eT>
  562. Row<eT>::head_cols(const uword N)
  563. {
  564. arma_extra_debug_sigprint();
  565. return (*this).head(N);
  566. }
  567. template<typename eT>
  568. arma_inline
  569. const subview_row<eT>
  570. Row<eT>::head_cols(const uword N) const
  571. {
  572. arma_extra_debug_sigprint();
  573. return (*this).head(N);
  574. }
  575. template<typename eT>
  576. arma_inline
  577. subview_row<eT>
  578. Row<eT>::tail_cols(const uword N)
  579. {
  580. arma_extra_debug_sigprint();
  581. return (*this).tail(N);
  582. }
  583. template<typename eT>
  584. arma_inline
  585. const subview_row<eT>
  586. Row<eT>::tail_cols(const uword N) const
  587. {
  588. arma_extra_debug_sigprint();
  589. return (*this).tail(N);
  590. }
  591. //! remove specified columns
  592. template<typename eT>
  593. inline
  594. void
  595. Row<eT>::shed_col(const uword col_num)
  596. {
  597. arma_extra_debug_sigprint();
  598. arma_debug_check( col_num >= Mat<eT>::n_cols, "Row::shed_col(): index out of bounds");
  599. shed_cols(col_num, col_num);
  600. }
  601. //! remove specified columns
  602. template<typename eT>
  603. inline
  604. void
  605. Row<eT>::shed_cols(const uword in_col1, const uword in_col2)
  606. {
  607. arma_extra_debug_sigprint();
  608. arma_debug_check
  609. (
  610. (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols),
  611. "Row::shed_cols(): indices out of bounds or incorrectly used"
  612. );
  613. const uword n_keep_front = in_col1;
  614. const uword n_keep_back = Mat<eT>::n_cols - (in_col2 + 1);
  615. Row<eT> X(n_keep_front + n_keep_back);
  616. eT* X_mem = X.memptr();
  617. const eT* t_mem = (*this).memptr();
  618. if(n_keep_front > 0)
  619. {
  620. arrayops::copy( X_mem, t_mem, n_keep_front );
  621. }
  622. if(n_keep_back > 0)
  623. {
  624. arrayops::copy( &(X_mem[n_keep_front]), &(t_mem[in_col2+1]), n_keep_back);
  625. }
  626. Mat<eT>::steal_mem(X);
  627. }
  628. //! remove specified columns
  629. template<typename eT>
  630. template<typename T1>
  631. inline
  632. void
  633. Row<eT>::shed_cols(const Base<uword, T1>& indices)
  634. {
  635. arma_extra_debug_sigprint();
  636. Mat<eT>::shed_cols(indices);
  637. }
  638. //! insert N cols at the specified col position,
  639. //! optionally setting the elements of the inserted cols to zero
  640. template<typename eT>
  641. inline
  642. void
  643. Row<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_zero)
  644. {
  645. arma_extra_debug_sigprint();
  646. const uword t_n_cols = Mat<eT>::n_cols;
  647. const uword A_n_cols = col_num;
  648. const uword B_n_cols = t_n_cols - col_num;
  649. // insertion at col_num == n_cols is in effect an append operation
  650. arma_debug_check( (col_num > t_n_cols), "Row::insert_cols(): index out of bounds");
  651. if(N > 0)
  652. {
  653. Row<eT> out(t_n_cols + N);
  654. eT* out_mem = out.memptr();
  655. const eT* t_mem = (*this).memptr();
  656. if(A_n_cols > 0)
  657. {
  658. arrayops::copy( out_mem, t_mem, A_n_cols );
  659. }
  660. if(B_n_cols > 0)
  661. {
  662. arrayops::copy( &(out_mem[col_num + N]), &(t_mem[col_num]), B_n_cols );
  663. }
  664. if(set_to_zero)
  665. {
  666. arrayops::inplace_set( &(out_mem[col_num]), eT(0), N );
  667. }
  668. Mat<eT>::steal_mem(out);
  669. }
  670. }
  671. //! insert the given object at the specified col position;
  672. //! the given object must have one row
  673. template<typename eT>
  674. template<typename T1>
  675. inline
  676. void
  677. Row<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
  678. {
  679. arma_extra_debug_sigprint();
  680. Mat<eT>::insert_cols(col_num, X);
  681. }
  682. template<typename eT>
  683. arma_inline
  684. arma_warn_unused
  685. eT&
  686. Row<eT>::at(const uword i)
  687. {
  688. return access::rw(Mat<eT>::mem[i]);
  689. }
  690. template<typename eT>
  691. arma_inline
  692. arma_warn_unused
  693. const eT&
  694. Row<eT>::at(const uword i) const
  695. {
  696. return Mat<eT>::mem[i];
  697. }
  698. template<typename eT>
  699. arma_inline
  700. arma_warn_unused
  701. eT&
  702. Row<eT>::at(const uword, const uword in_col)
  703. {
  704. return access::rw( Mat<eT>::mem[in_col] );
  705. }
  706. template<typename eT>
  707. arma_inline
  708. arma_warn_unused
  709. const eT&
  710. Row<eT>::at(const uword, const uword in_col) const
  711. {
  712. return Mat<eT>::mem[in_col];
  713. }
  714. template<typename eT>
  715. inline
  716. typename Row<eT>::row_iterator
  717. Row<eT>::begin_row(const uword row_num)
  718. {
  719. arma_extra_debug_sigprint();
  720. arma_debug_check( (row_num >= Mat<eT>::n_rows), "Row::begin_row(): index out of bounds");
  721. return Mat<eT>::memptr();
  722. }
  723. template<typename eT>
  724. inline
  725. typename Row<eT>::const_row_iterator
  726. Row<eT>::begin_row(const uword row_num) const
  727. {
  728. arma_extra_debug_sigprint();
  729. arma_debug_check( (row_num >= Mat<eT>::n_rows), "Row::begin_row(): index out of bounds");
  730. return Mat<eT>::memptr();
  731. }
  732. template<typename eT>
  733. inline
  734. typename Row<eT>::row_iterator
  735. Row<eT>::end_row(const uword row_num)
  736. {
  737. arma_extra_debug_sigprint();
  738. arma_debug_check( (row_num >= Mat<eT>::n_rows), "Row::end_row(): index out of bounds");
  739. return Mat<eT>::memptr() + Mat<eT>::n_cols;
  740. }
  741. template<typename eT>
  742. inline
  743. typename Row<eT>::const_row_iterator
  744. Row<eT>::end_row(const uword row_num) const
  745. {
  746. arma_extra_debug_sigprint();
  747. arma_debug_check( (row_num >= Mat<eT>::n_rows), "Row::end_row(): index out of bounds");
  748. return Mat<eT>::memptr() + Mat<eT>::n_cols;
  749. }
  750. template<typename eT>
  751. template<uword fixed_n_elem>
  752. arma_inline
  753. Row<eT>::fixed<fixed_n_elem>::fixed()
  754. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  755. {
  756. arma_extra_debug_sigprint_this(this);
  757. }
  758. template<typename eT>
  759. template<uword fixed_n_elem>
  760. arma_inline
  761. Row<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X)
  762. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  763. {
  764. arma_extra_debug_sigprint_this(this);
  765. eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
  766. const eT* src = (use_extra) ? X.mem_local_extra : X.mem_local;
  767. arrayops::copy( dest, src, fixed_n_elem );
  768. }
  769. template<typename eT>
  770. template<uword fixed_n_elem>
  771. arma_inline
  772. Row<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X)
  773. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  774. {
  775. arma_extra_debug_sigprint_this(this);
  776. Row<eT>::operator=(X);
  777. }
  778. template<typename eT>
  779. template<uword fixed_n_elem>
  780. template<typename fill_type>
  781. inline
  782. Row<eT>::fixed<fixed_n_elem>::fixed(const fill::fill_class<fill_type>&)
  783. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  784. {
  785. arma_extra_debug_sigprint_this(this);
  786. if(is_same_type<fill_type, fill::fill_zeros>::yes) (*this).zeros();
  787. if(is_same_type<fill_type, fill::fill_ones >::yes) (*this).ones();
  788. if(is_same_type<fill_type, fill::fill_eye >::yes) (*this).eye();
  789. if(is_same_type<fill_type, fill::fill_randu>::yes) (*this).randu();
  790. if(is_same_type<fill_type, fill::fill_randn>::yes) (*this).randn();
  791. }
  792. template<typename eT>
  793. template<uword fixed_n_elem>
  794. template<typename T1>
  795. arma_inline
  796. Row<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A)
  797. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  798. {
  799. arma_extra_debug_sigprint_this(this);
  800. Row<eT>::operator=(A.get_ref());
  801. }
  802. template<typename eT>
  803. template<uword fixed_n_elem>
  804. template<typename T1, typename T2>
  805. arma_inline
  806. Row<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B)
  807. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  808. {
  809. arma_extra_debug_sigprint_this(this);
  810. Row<eT>::init(A,B);
  811. }
  812. template<typename eT>
  813. template<uword fixed_n_elem>
  814. inline
  815. Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
  816. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  817. {
  818. arma_extra_debug_sigprint_this(this);
  819. eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
  820. arrayops::copy( dest, aux_mem, fixed_n_elem );
  821. }
  822. template<typename eT>
  823. template<uword fixed_n_elem>
  824. inline
  825. Row<eT>::fixed<fixed_n_elem>::fixed(const char* text)
  826. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  827. {
  828. arma_extra_debug_sigprint_this(this);
  829. Row<eT>::operator=(text);
  830. }
  831. template<typename eT>
  832. template<uword fixed_n_elem>
  833. inline
  834. Row<eT>::fixed<fixed_n_elem>::fixed(const std::string& text)
  835. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  836. {
  837. arma_extra_debug_sigprint_this(this);
  838. Row<eT>::operator=(text);
  839. }
  840. template<typename eT>
  841. template<uword fixed_n_elem>
  842. template<typename T1>
  843. Row<eT>&
  844. Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
  845. {
  846. arma_extra_debug_sigprint();
  847. Row<eT>::operator=(A.get_ref());
  848. return *this;
  849. }
  850. template<typename eT>
  851. template<uword fixed_n_elem>
  852. Row<eT>&
  853. Row<eT>::fixed<fixed_n_elem>::operator=(const eT val)
  854. {
  855. arma_extra_debug_sigprint();
  856. Row<eT>::operator=(val);
  857. return *this;
  858. }
  859. template<typename eT>
  860. template<uword fixed_n_elem>
  861. Row<eT>&
  862. Row<eT>::fixed<fixed_n_elem>::operator=(const char* text)
  863. {
  864. arma_extra_debug_sigprint();
  865. Row<eT>::operator=(text);
  866. return *this;
  867. }
  868. template<typename eT>
  869. template<uword fixed_n_elem>
  870. Row<eT>&
  871. Row<eT>::fixed<fixed_n_elem>::operator=(const std::string& text)
  872. {
  873. arma_extra_debug_sigprint();
  874. Row<eT>::operator=(text);
  875. return *this;
  876. }
  877. template<typename eT>
  878. template<uword fixed_n_elem>
  879. Row<eT>&
  880. Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
  881. {
  882. arma_extra_debug_sigprint();
  883. Row<eT>::operator=(X);
  884. return *this;
  885. }
  886. #if defined(ARMA_USE_CXX11)
  887. template<typename eT>
  888. template<uword fixed_n_elem>
  889. inline
  890. Row<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list)
  891. : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) )
  892. {
  893. arma_extra_debug_sigprint_this(this);
  894. (*this).operator=(list);
  895. }
  896. template<typename eT>
  897. template<uword fixed_n_elem>
  898. inline
  899. Row<eT>&
  900. Row<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>& list)
  901. {
  902. arma_extra_debug_sigprint();
  903. const uword N = uword(list.size());
  904. arma_debug_check( (N > fixed_n_elem), "Row::fixed: initialiser list is too long" );
  905. eT* this_mem = (*this).memptr();
  906. arrayops::copy( this_mem, list.begin(), N );
  907. for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); }
  908. return *this;
  909. }
  910. #endif
  911. template<typename eT>
  912. template<uword fixed_n_elem>
  913. arma_inline
  914. Row<eT>&
  915. Row<eT>::fixed<fixed_n_elem>::operator=(const fixed<fixed_n_elem>& X)
  916. {
  917. arma_extra_debug_sigprint();
  918. if(this != &X)
  919. {
  920. eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
  921. const eT* src = (use_extra) ? X.mem_local_extra : X.mem_local;
  922. arrayops::copy( dest, src, fixed_n_elem );
  923. }
  924. return *this;
  925. }
  926. #if defined(ARMA_GOOD_COMPILER)
  927. template<typename eT>
  928. template<uword fixed_n_elem>
  929. template<typename T1, typename eop_type>
  930. inline
  931. Row<eT>&
  932. Row<eT>::fixed<fixed_n_elem>::operator=(const eOp<T1, eop_type>& X)
  933. {
  934. arma_extra_debug_sigprint();
  935. arma_type_check(( is_same_type< eT, typename T1::elem_type >::no ));
  936. const bool bad_alias = (eOp<T1, eop_type>::proxy_type::has_subview && X.P.is_alias(*this));
  937. if(bad_alias == false)
  938. {
  939. arma_debug_assert_same_size(uword(1), fixed_n_elem, X.get_n_rows(), X.get_n_cols(), "Row::fixed::operator=");
  940. eop_type::apply(*this, X);
  941. }
  942. else
  943. {
  944. arma_extra_debug_print("bad_alias = true");
  945. Row<eT> tmp(X);
  946. (*this) = tmp;
  947. }
  948. return *this;
  949. }
  950. template<typename eT>
  951. template<uword fixed_n_elem>
  952. template<typename T1, typename T2, typename eglue_type>
  953. inline
  954. Row<eT>&
  955. Row<eT>::fixed<fixed_n_elem>::operator=(const eGlue<T1, T2, eglue_type>& X)
  956. {
  957. arma_extra_debug_sigprint();
  958. arma_type_check(( is_same_type< eT, typename T1::elem_type >::no ));
  959. arma_type_check(( is_same_type< eT, typename T2::elem_type >::no ));
  960. const bool bad_alias =
  961. (
  962. (eGlue<T1, T2, eglue_type>::proxy1_type::has_subview && X.P1.is_alias(*this))
  963. ||
  964. (eGlue<T1, T2, eglue_type>::proxy2_type::has_subview && X.P2.is_alias(*this))
  965. );
  966. if(bad_alias == false)
  967. {
  968. arma_debug_assert_same_size(uword(1), fixed_n_elem, X.get_n_rows(), X.get_n_cols(), "Row::fixed::operator=");
  969. eglue_type::apply(*this, X);
  970. }
  971. else
  972. {
  973. arma_extra_debug_print("bad_alias = true");
  974. Row<eT> tmp(X);
  975. (*this) = tmp;
  976. }
  977. return *this;
  978. }
  979. #endif
  980. template<typename eT>
  981. template<uword fixed_n_elem>
  982. arma_inline
  983. const Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans >
  984. Row<eT>::fixed<fixed_n_elem>::t() const
  985. {
  986. return Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans >(*this);
  987. }
  988. template<typename eT>
  989. template<uword fixed_n_elem>
  990. arma_inline
  991. const Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans >
  992. Row<eT>::fixed<fixed_n_elem>::ht() const
  993. {
  994. return Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans >(*this);
  995. }
  996. template<typename eT>
  997. template<uword fixed_n_elem>
  998. arma_inline
  999. const Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_strans >
  1000. Row<eT>::fixed<fixed_n_elem>::st() const
  1001. {
  1002. return Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_strans >(*this);
  1003. }
  1004. template<typename eT>
  1005. template<uword fixed_n_elem>
  1006. arma_inline
  1007. arma_warn_unused
  1008. const eT&
  1009. Row<eT>::fixed<fixed_n_elem>::at_alt(const uword ii) const
  1010. {
  1011. #if defined(ARMA_HAVE_ALIGNED_ATTRIBUTE)
  1012. return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
  1013. #else
  1014. const eT* mem_aligned = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
  1015. memory::mark_as_aligned(mem_aligned);
  1016. return mem_aligned[ii];
  1017. #endif
  1018. }
  1019. template<typename eT>
  1020. template<uword fixed_n_elem>
  1021. arma_inline
  1022. arma_warn_unused
  1023. eT&
  1024. Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii)
  1025. {
  1026. return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
  1027. }
  1028. template<typename eT>
  1029. template<uword fixed_n_elem>
  1030. arma_inline
  1031. arma_warn_unused
  1032. const eT&
  1033. Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii) const
  1034. {
  1035. return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
  1036. }
  1037. template<typename eT>
  1038. template<uword fixed_n_elem>
  1039. arma_inline
  1040. arma_warn_unused
  1041. eT&
  1042. Row<eT>::fixed<fixed_n_elem>::at(const uword ii)
  1043. {
  1044. return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
  1045. }
  1046. template<typename eT>
  1047. template<uword fixed_n_elem>
  1048. arma_inline
  1049. arma_warn_unused
  1050. const eT&
  1051. Row<eT>::fixed<fixed_n_elem>::at(const uword ii) const
  1052. {
  1053. return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
  1054. }
  1055. template<typename eT>
  1056. template<uword fixed_n_elem>
  1057. arma_inline
  1058. arma_warn_unused
  1059. eT&
  1060. Row<eT>::fixed<fixed_n_elem>::operator() (const uword ii)
  1061. {
  1062. arma_debug_check( (ii >= fixed_n_elem), "Row::operator(): index out of bounds");
  1063. return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
  1064. }
  1065. template<typename eT>
  1066. template<uword fixed_n_elem>
  1067. arma_inline
  1068. arma_warn_unused
  1069. const eT&
  1070. Row<eT>::fixed<fixed_n_elem>::operator() (const uword ii) const
  1071. {
  1072. arma_debug_check( (ii >= fixed_n_elem), "Row::operator(): index out of bounds");
  1073. return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii];
  1074. }
  1075. template<typename eT>
  1076. template<uword fixed_n_elem>
  1077. arma_inline
  1078. arma_warn_unused
  1079. eT&
  1080. Row<eT>::fixed<fixed_n_elem>::at(const uword, const uword in_col)
  1081. {
  1082. return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col];
  1083. }
  1084. template<typename eT>
  1085. template<uword fixed_n_elem>
  1086. arma_inline
  1087. arma_warn_unused
  1088. const eT&
  1089. Row<eT>::fixed<fixed_n_elem>::at(const uword, const uword in_col) const
  1090. {
  1091. return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col];
  1092. }
  1093. template<typename eT>
  1094. template<uword fixed_n_elem>
  1095. arma_inline
  1096. arma_warn_unused
  1097. eT&
  1098. Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword in_col)
  1099. {
  1100. arma_debug_check( ((in_row > 0) || (in_col >= fixed_n_elem)), "Row::operator(): index out of bounds" );
  1101. return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col];
  1102. }
  1103. template<typename eT>
  1104. template<uword fixed_n_elem>
  1105. arma_inline
  1106. arma_warn_unused
  1107. const eT&
  1108. Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword in_col) const
  1109. {
  1110. arma_debug_check( ((in_row > 0) || (in_col >= fixed_n_elem)), "Row::operator(): index out of bounds" );
  1111. return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col];
  1112. }
  1113. template<typename eT>
  1114. template<uword fixed_n_elem>
  1115. arma_inline
  1116. arma_warn_unused
  1117. eT*
  1118. Row<eT>::fixed<fixed_n_elem>::memptr()
  1119. {
  1120. return (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
  1121. }
  1122. template<typename eT>
  1123. template<uword fixed_n_elem>
  1124. arma_inline
  1125. arma_warn_unused
  1126. const eT*
  1127. Row<eT>::fixed<fixed_n_elem>::memptr() const
  1128. {
  1129. return (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
  1130. }
  1131. template<typename eT>
  1132. template<uword fixed_n_elem>
  1133. arma_hot
  1134. inline
  1135. const Row<eT>&
  1136. Row<eT>::fixed<fixed_n_elem>::fill(const eT val)
  1137. {
  1138. arma_extra_debug_sigprint();
  1139. eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[0]);
  1140. arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, val );
  1141. return *this;
  1142. }
  1143. template<typename eT>
  1144. template<uword fixed_n_elem>
  1145. arma_hot
  1146. inline
  1147. const Row<eT>&
  1148. Row<eT>::fixed<fixed_n_elem>::zeros()
  1149. {
  1150. arma_extra_debug_sigprint();
  1151. eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[0]);
  1152. arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(0) );
  1153. return *this;
  1154. }
  1155. template<typename eT>
  1156. template<uword fixed_n_elem>
  1157. arma_hot
  1158. inline
  1159. const Row<eT>&
  1160. Row<eT>::fixed<fixed_n_elem>::ones()
  1161. {
  1162. arma_extra_debug_sigprint();
  1163. eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[0]);
  1164. arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(1) );
  1165. return *this;
  1166. }
  1167. template<typename eT>
  1168. inline
  1169. Row<eT>::Row(const arma_fixed_indicator&, const uword in_n_elem, const eT* in_mem)
  1170. : Mat<eT>(arma_fixed_indicator(), 1, in_n_elem, 2, in_mem)
  1171. {
  1172. arma_extra_debug_sigprint_this(this);
  1173. }
  1174. #ifdef ARMA_EXTRA_ROW_MEAT
  1175. #include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT)
  1176. #endif
  1177. //! @}