Base_meat.hpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  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 Base
  16. //! @{
  17. template<typename elem_type, typename derived>
  18. arma_inline
  19. const derived&
  20. Base<elem_type,derived>::get_ref() const
  21. {
  22. return static_cast<const derived&>(*this);
  23. }
  24. template<typename elem_type, typename derived>
  25. arma_cold
  26. inline
  27. void
  28. Base<elem_type,derived>::print(const std::string extra_text) const
  29. {
  30. const quasi_unwrap<derived> tmp( (*this).get_ref() );
  31. tmp.M.impl_print(extra_text);
  32. }
  33. template<typename elem_type, typename derived>
  34. arma_cold
  35. inline
  36. void
  37. Base<elem_type,derived>::print(std::ostream& user_stream, const std::string extra_text) const
  38. {
  39. const quasi_unwrap<derived> tmp( (*this).get_ref() );
  40. tmp.M.impl_print(user_stream, extra_text);
  41. }
  42. template<typename elem_type, typename derived>
  43. arma_cold
  44. inline
  45. void
  46. Base<elem_type,derived>::raw_print(const std::string extra_text) const
  47. {
  48. const quasi_unwrap<derived> tmp( (*this).get_ref() );
  49. tmp.M.impl_raw_print(extra_text);
  50. }
  51. template<typename elem_type, typename derived>
  52. arma_cold
  53. inline
  54. void
  55. Base<elem_type,derived>::raw_print(std::ostream& user_stream, const std::string extra_text) const
  56. {
  57. const quasi_unwrap<derived> tmp( (*this).get_ref() );
  58. tmp.M.impl_raw_print(user_stream, extra_text);
  59. }
  60. template<typename elem_type, typename derived>
  61. inline
  62. arma_warn_unused
  63. elem_type
  64. Base<elem_type,derived>::min() const
  65. {
  66. return op_min::min( (*this).get_ref() );
  67. }
  68. template<typename elem_type, typename derived>
  69. inline
  70. arma_warn_unused
  71. elem_type
  72. Base<elem_type,derived>::max() const
  73. {
  74. return op_max::max( (*this).get_ref() );
  75. }
  76. template<typename elem_type, typename derived>
  77. inline
  78. elem_type
  79. Base<elem_type,derived>::min(uword& index_of_min_val) const
  80. {
  81. const Proxy<derived> P( (*this).get_ref() );
  82. return op_min::min_with_index(P, index_of_min_val);
  83. }
  84. template<typename elem_type, typename derived>
  85. inline
  86. elem_type
  87. Base<elem_type,derived>::max(uword& index_of_max_val) const
  88. {
  89. const Proxy<derived> P( (*this).get_ref() );
  90. return op_max::max_with_index(P, index_of_max_val);
  91. }
  92. template<typename elem_type, typename derived>
  93. inline
  94. elem_type
  95. Base<elem_type,derived>::min(uword& row_of_min_val, uword& col_of_min_val) const
  96. {
  97. const Proxy<derived> P( (*this).get_ref() );
  98. uword index = 0;
  99. const elem_type val = op_min::min_with_index(P, index);
  100. const uword local_n_rows = P.get_n_rows();
  101. row_of_min_val = index % local_n_rows;
  102. col_of_min_val = index / local_n_rows;
  103. return val;
  104. }
  105. template<typename elem_type, typename derived>
  106. inline
  107. elem_type
  108. Base<elem_type,derived>::max(uword& row_of_max_val, uword& col_of_max_val) const
  109. {
  110. const Proxy<derived> P( (*this).get_ref() );
  111. uword index = 0;
  112. const elem_type val = op_max::max_with_index(P, index);
  113. const uword local_n_rows = P.get_n_rows();
  114. row_of_max_val = index % local_n_rows;
  115. col_of_max_val = index / local_n_rows;
  116. return val;
  117. }
  118. template<typename elem_type, typename derived>
  119. inline
  120. arma_warn_unused
  121. uword
  122. Base<elem_type,derived>::index_min() const
  123. {
  124. const Proxy<derived> P( (*this).get_ref() );
  125. uword index = 0;
  126. if(P.get_n_elem() == 0)
  127. {
  128. arma_debug_check(true, "index_min(): object has no elements");
  129. }
  130. else
  131. {
  132. op_min::min_with_index(P, index);
  133. }
  134. return index;
  135. }
  136. template<typename elem_type, typename derived>
  137. inline
  138. arma_warn_unused
  139. uword
  140. Base<elem_type,derived>::index_max() const
  141. {
  142. const Proxy<derived> P( (*this).get_ref() );
  143. uword index = 0;
  144. if(P.get_n_elem() == 0)
  145. {
  146. arma_debug_check(true, "index_max(): object has no elements");
  147. }
  148. else
  149. {
  150. op_max::max_with_index(P, index);
  151. }
  152. return index;
  153. }
  154. template<typename elem_type, typename derived>
  155. inline
  156. arma_warn_unused
  157. bool
  158. Base<elem_type,derived>::is_symmetric() const
  159. {
  160. arma_extra_debug_sigprint();
  161. const quasi_unwrap<derived> U( (*this).get_ref() );
  162. const Mat<elem_type>& A = U.M;
  163. if(A.n_rows != A.n_cols) { return false; }
  164. if(A.n_elem <= 1 ) { return true; }
  165. const uword N = A.n_rows;
  166. const uword Nm1 = N-1;
  167. const elem_type* A_col = A.memptr();
  168. for(uword j=0; j < Nm1; ++j)
  169. {
  170. const uword jp1 = j+1;
  171. const elem_type* A_row = &(A.at(j,jp1));
  172. for(uword i=jp1; i < N; ++i)
  173. {
  174. if(A_col[i] != (*A_row)) { return false; }
  175. A_row += N;
  176. }
  177. A_col += N;
  178. }
  179. return true;
  180. }
  181. template<typename elem_type, typename derived>
  182. inline
  183. arma_warn_unused
  184. bool
  185. Base<elem_type,derived>::is_symmetric(const typename get_pod_type<elem_type>::result tol) const
  186. {
  187. arma_extra_debug_sigprint();
  188. typedef typename get_pod_type<elem_type>::result T;
  189. if(tol == T(0)) { return (*this).is_symmetric(); }
  190. arma_debug_check( (tol < T(0)), "is_symmetric(): parameter 'tol' must be >= 0" );
  191. const quasi_unwrap<derived> U( (*this).get_ref() );
  192. const Mat<elem_type>& A = U.M;
  193. if(A.n_rows != A.n_cols) { return false; }
  194. if(A.n_elem <= 1 ) { return true; }
  195. const T norm_A = as_scalar( arma::max(sum(abs(A), 1), 0) );
  196. if(norm_A == T(0)) { return true; }
  197. const T norm_A_Ast = as_scalar( arma::max(sum(abs(A - A.st()), 1), 0) );
  198. return ( (norm_A_Ast / norm_A) <= tol );
  199. }
  200. template<typename elem_type, typename derived>
  201. inline
  202. arma_warn_unused
  203. bool
  204. Base<elem_type,derived>::is_hermitian() const
  205. {
  206. arma_extra_debug_sigprint();
  207. typedef typename get_pod_type<elem_type>::result T;
  208. const quasi_unwrap<derived> U( (*this).get_ref() );
  209. const Mat<elem_type>& A = U.M;
  210. if(A.n_rows != A.n_cols) { return false; }
  211. if(A.n_elem == 0 ) { return true; }
  212. const uword N = A.n_rows;
  213. const elem_type* A_col = A.memptr();
  214. for(uword j=0; j < N; ++j)
  215. {
  216. if( access::tmp_imag(A_col[j]) != T(0) ) { return false; }
  217. A_col += N;
  218. }
  219. A_col = A.memptr();
  220. const uword Nm1 = N-1;
  221. for(uword j=0; j < Nm1; ++j)
  222. {
  223. const uword jp1 = j+1;
  224. const elem_type* A_row = &(A.at(j,jp1));
  225. for(uword i=jp1; i < N; ++i)
  226. {
  227. if(A_col[i] != access::alt_conj(*A_row)) { return false; }
  228. A_row += N;
  229. }
  230. A_col += N;
  231. }
  232. return true;
  233. }
  234. template<typename elem_type, typename derived>
  235. inline
  236. arma_warn_unused
  237. bool
  238. Base<elem_type,derived>::is_hermitian(const typename get_pod_type<elem_type>::result tol) const
  239. {
  240. arma_extra_debug_sigprint();
  241. typedef typename get_pod_type<elem_type>::result T;
  242. if(tol == T(0)) { return (*this).is_hermitian(); }
  243. arma_debug_check( (tol < T(0)), "is_hermitian(): parameter 'tol' must be >= 0" );
  244. const quasi_unwrap<derived> U( (*this).get_ref() );
  245. const Mat<elem_type>& A = U.M;
  246. if(A.n_rows != A.n_cols) { return false; }
  247. if(A.n_elem == 0 ) { return true; }
  248. const T norm_A = as_scalar( arma::max(sum(abs(A), 1), 0) );
  249. if(norm_A == T(0)) { return true; }
  250. const T norm_A_At = as_scalar( arma::max(sum(abs(A - A.t()), 1), 0) );
  251. return ( (norm_A_At / norm_A) <= tol );
  252. }
  253. template<typename elem_type, typename derived>
  254. inline
  255. arma_warn_unused
  256. bool
  257. Base<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::result tol) const
  258. {
  259. arma_extra_debug_sigprint();
  260. typedef typename get_pod_type<elem_type>::result T;
  261. arma_debug_check( (tol < T(0)), "is_zero(): parameter 'tol' must be >= 0" );
  262. if(Proxy<derived>::use_at || is_Mat<typename Proxy<derived>::stored_type>::value)
  263. {
  264. const quasi_unwrap<derived> U( (*this).get_ref() );
  265. return arrayops::is_zero( U.M.memptr(), U.M.n_elem, tol );
  266. }
  267. const Proxy<derived> P( (*this).get_ref() );
  268. const uword n_elem = P.get_n_elem();
  269. if(n_elem == 0) { return false; }
  270. const typename Proxy<derived>::ea_type Pea = P.get_ea();
  271. if(is_cx<elem_type>::yes)
  272. {
  273. for(uword i=0; i<n_elem; ++i)
  274. {
  275. const elem_type val = Pea[i];
  276. const T val_real = access::tmp_real(val);
  277. const T val_imag = access::tmp_imag(val);
  278. if(eop_aux::arma_abs(val_real) > tol) { return false; }
  279. if(eop_aux::arma_abs(val_imag) > tol) { return false; }
  280. }
  281. }
  282. else // not complex
  283. {
  284. for(uword i=0; i<n_elem; ++i)
  285. {
  286. if(eop_aux::arma_abs(Pea[i]) > tol) { return false; }
  287. }
  288. }
  289. return true;
  290. }
  291. template<typename elem_type, typename derived>
  292. inline
  293. arma_warn_unused
  294. bool
  295. Base<elem_type,derived>::is_trimatu() const
  296. {
  297. arma_extra_debug_sigprint();
  298. const quasi_unwrap<derived> U( (*this).get_ref() );
  299. if(U.M.n_rows != U.M.n_cols) { return false; }
  300. if(U.M.n_elem <= 1) { return true; }
  301. return trimat_helper::is_triu(U.M);
  302. }
  303. template<typename elem_type, typename derived>
  304. inline
  305. arma_warn_unused
  306. bool
  307. Base<elem_type,derived>::is_trimatl() const
  308. {
  309. arma_extra_debug_sigprint();
  310. const quasi_unwrap<derived> U( (*this).get_ref() );
  311. if(U.M.n_rows != U.M.n_cols) { return false; }
  312. if(U.M.n_elem <= 1) { return true; }
  313. return trimat_helper::is_tril(U.M);
  314. }
  315. template<typename elem_type, typename derived>
  316. inline
  317. arma_warn_unused
  318. bool
  319. Base<elem_type,derived>::is_diagmat() const
  320. {
  321. arma_extra_debug_sigprint();
  322. const quasi_unwrap<derived> U( (*this).get_ref() );
  323. const Mat<elem_type>& A = U.M;
  324. if(A.n_elem <= 1) { return true; }
  325. // NOTE: we're NOT assuming the matrix has a square size
  326. const uword A_n_rows = A.n_rows;
  327. const uword A_n_cols = A.n_cols;
  328. const elem_type* A_mem = A.memptr();
  329. if(A_mem[1] != elem_type(0)) { return false; }
  330. // if we got to this point, do a thorough check
  331. for(uword A_col=0; A_col < A_n_cols; ++A_col)
  332. {
  333. for(uword A_row=0; A_row < A_n_rows; ++A_row)
  334. {
  335. if( (A_mem[A_row] != elem_type(0)) && (A_row != A_col) ) { return false; }
  336. }
  337. A_mem += A_n_rows;
  338. }
  339. return true;
  340. }
  341. template<typename elem_type, typename derived>
  342. inline
  343. arma_warn_unused
  344. bool
  345. Base<elem_type,derived>::is_empty() const
  346. {
  347. arma_extra_debug_sigprint();
  348. const Proxy<derived> P( (*this).get_ref() );
  349. return (P.get_n_elem() == uword(0));
  350. }
  351. template<typename elem_type, typename derived>
  352. inline
  353. arma_warn_unused
  354. bool
  355. Base<elem_type,derived>::is_square() const
  356. {
  357. arma_extra_debug_sigprint();
  358. const Proxy<derived> P( (*this).get_ref() );
  359. return (P.get_n_rows() == P.get_n_cols());
  360. }
  361. template<typename elem_type, typename derived>
  362. inline
  363. arma_warn_unused
  364. bool
  365. Base<elem_type,derived>::is_vec() const
  366. {
  367. arma_extra_debug_sigprint();
  368. if( (Proxy<derived>::is_row) || (Proxy<derived>::is_col) || (Proxy<derived>::is_xvec) ) { return true; }
  369. const Proxy<derived> P( (*this).get_ref() );
  370. return ( (P.get_n_rows() == uword(1)) || (P.get_n_cols() == uword(1)) );
  371. }
  372. template<typename elem_type, typename derived>
  373. inline
  374. arma_warn_unused
  375. bool
  376. Base<elem_type,derived>::is_colvec() const
  377. {
  378. arma_extra_debug_sigprint();
  379. if(Proxy<derived>::is_col) { return true; }
  380. const Proxy<derived> P( (*this).get_ref() );
  381. return (P.get_n_cols() == uword(1));
  382. }
  383. template<typename elem_type, typename derived>
  384. inline
  385. arma_warn_unused
  386. bool
  387. Base<elem_type,derived>::is_rowvec() const
  388. {
  389. arma_extra_debug_sigprint();
  390. if(Proxy<derived>::is_row) { return true; }
  391. const Proxy<derived> P( (*this).get_ref() );
  392. return (P.get_n_rows() == uword(1));
  393. }
  394. template<typename elem_type, typename derived>
  395. inline
  396. arma_warn_unused
  397. bool
  398. Base<elem_type,derived>::is_finite() const
  399. {
  400. arma_extra_debug_sigprint();
  401. const Proxy<derived> P( (*this).get_ref() );
  402. if(is_Mat<typename Proxy<derived>::stored_type>::value)
  403. {
  404. const quasi_unwrap<typename Proxy<derived>::stored_type> U(P.Q);
  405. return arrayops::is_finite( U.M.memptr(), U.M.n_elem );
  406. }
  407. if(Proxy<derived>::use_at == false)
  408. {
  409. const typename Proxy<derived>::ea_type Pea = P.get_ea();
  410. const uword n_elem = P.get_n_elem();
  411. for(uword i=0; i<n_elem; ++i)
  412. {
  413. if(arma_isfinite(Pea[i]) == false) { return false; }
  414. }
  415. }
  416. else
  417. {
  418. const uword n_rows = P.get_n_rows();
  419. const uword n_cols = P.get_n_cols();
  420. for(uword col=0; col<n_cols; ++col)
  421. for(uword row=0; row<n_rows; ++row)
  422. {
  423. if(arma_isfinite(P.at(row,col)) == false) { return false; }
  424. }
  425. }
  426. return true;
  427. }
  428. template<typename elem_type, typename derived>
  429. inline
  430. arma_warn_unused
  431. bool
  432. Base<elem_type,derived>::has_inf() const
  433. {
  434. arma_extra_debug_sigprint();
  435. const Proxy<derived> P( (*this).get_ref() );
  436. if(is_Mat<typename Proxy<derived>::stored_type>::value)
  437. {
  438. const quasi_unwrap<typename Proxy<derived>::stored_type> U(P.Q);
  439. return arrayops::has_inf( U.M.memptr(), U.M.n_elem );
  440. }
  441. if(Proxy<derived>::use_at == false)
  442. {
  443. const typename Proxy<derived>::ea_type Pea = P.get_ea();
  444. const uword n_elem = P.get_n_elem();
  445. for(uword i=0; i<n_elem; ++i)
  446. {
  447. if(arma_isinf(Pea[i])) { return true; }
  448. }
  449. }
  450. else
  451. {
  452. const uword n_rows = P.get_n_rows();
  453. const uword n_cols = P.get_n_cols();
  454. for(uword col=0; col<n_cols; ++col)
  455. for(uword row=0; row<n_rows; ++row)
  456. {
  457. if(arma_isinf(P.at(row,col))) { return true; }
  458. }
  459. }
  460. return false;
  461. }
  462. template<typename elem_type, typename derived>
  463. inline
  464. arma_warn_unused
  465. bool
  466. Base<elem_type,derived>::has_nan() const
  467. {
  468. arma_extra_debug_sigprint();
  469. const Proxy<derived> P( (*this).get_ref() );
  470. if(is_Mat<typename Proxy<derived>::stored_type>::value)
  471. {
  472. const quasi_unwrap<typename Proxy<derived>::stored_type> U(P.Q);
  473. return arrayops::has_nan( U.M.memptr(), U.M.n_elem );
  474. }
  475. if(Proxy<derived>::use_at == false)
  476. {
  477. const typename Proxy<derived>::ea_type Pea = P.get_ea();
  478. const uword n_elem = P.get_n_elem();
  479. for(uword i=0; i<n_elem; ++i)
  480. {
  481. if(arma_isnan(Pea[i])) { return true; }
  482. }
  483. }
  484. else
  485. {
  486. const uword n_rows = P.get_n_rows();
  487. const uword n_cols = P.get_n_cols();
  488. for(uword col=0; col<n_cols; ++col)
  489. for(uword row=0; row<n_rows; ++row)
  490. {
  491. if(arma_isnan(P.at(row,col))) { return true; }
  492. }
  493. }
  494. return false;
  495. }
  496. template<typename elem_type, typename derived>
  497. inline
  498. arma_warn_unused
  499. const Op<derived,op_vectorise_col>
  500. Base<elem_type, derived>::as_col() const
  501. {
  502. return Op<derived,op_vectorise_col>( (*this).get_ref() );
  503. }
  504. template<typename elem_type, typename derived>
  505. inline
  506. arma_warn_unused
  507. const Op<derived,op_vectorise_row>
  508. Base<elem_type, derived>::as_row() const
  509. {
  510. return Op<derived,op_vectorise_row>( (*this).get_ref() );
  511. }
  512. //
  513. // extra functions defined in Base_extra_yes
  514. template<typename elem_type, typename derived>
  515. inline
  516. arma_warn_unused
  517. const Op<derived,op_inv>
  518. Base_extra_yes<elem_type, derived>::i() const
  519. {
  520. return Op<derived,op_inv>(static_cast<const derived&>(*this));
  521. }
  522. template<typename elem_type, typename derived>
  523. arma_deprecated
  524. inline
  525. const Op<derived,op_inv>
  526. Base_extra_yes<elem_type, derived>::i(const bool) const // argument kept only for compatibility with old user code
  527. {
  528. // arma_debug_warn(".i(bool) is deprecated and will be removed; change to .i()");
  529. return Op<derived,op_inv>(static_cast<const derived&>(*this));
  530. }
  531. template<typename elem_type, typename derived>
  532. arma_deprecated
  533. inline
  534. const Op<derived,op_inv>
  535. Base_extra_yes<elem_type, derived>::i(const char*) const // argument kept only for compatibility with old user code
  536. {
  537. // arma_debug_warn(".i(char*) is deprecated and will be removed; change to .i()");
  538. return Op<derived,op_inv>(static_cast<const derived&>(*this));
  539. }
  540. template<typename elem_type, typename derived>
  541. inline
  542. arma_warn_unused
  543. bool
  544. Base_extra_yes<elem_type,derived>::is_sympd() const
  545. {
  546. arma_extra_debug_sigprint();
  547. typedef typename get_pod_type<elem_type>::result T;
  548. Mat<elem_type> X = static_cast<const derived&>(*this);
  549. // default value for tol
  550. const T tol = T(100) * std::numeric_limits<T>::epsilon() * norm(X, "fro");
  551. if(X.is_hermitian(tol) == false) { return false; }
  552. if(X.is_empty()) { return false; }
  553. X.diag() -= elem_type(tol);
  554. return auxlib::chol_simple(X);
  555. }
  556. template<typename elem_type, typename derived>
  557. inline
  558. arma_warn_unused
  559. bool
  560. Base_extra_yes<elem_type,derived>::is_sympd(typename get_pod_type<elem_type>::result tol) const
  561. {
  562. arma_extra_debug_sigprint();
  563. typedef typename get_pod_type<elem_type>::result T;
  564. arma_debug_check( (tol < T(0)), "is_sympd(): parameter 'tol' must be >= 0" );
  565. Mat<elem_type> X = static_cast<const derived&>(*this);
  566. if(X.is_hermitian(tol) == false) { return false; }
  567. if(X.is_empty()) { return false; }
  568. X.diag() -= elem_type(tol);
  569. return auxlib::chol_simple(X);
  570. }
  571. //
  572. // extra functions defined in Base_eval_Mat
  573. template<typename elem_type, typename derived>
  574. arma_inline
  575. const derived&
  576. Base_eval_Mat<elem_type, derived>::eval() const
  577. {
  578. arma_extra_debug_sigprint();
  579. return static_cast<const derived&>(*this);
  580. }
  581. //
  582. // extra functions defined in Base_eval_expr
  583. template<typename elem_type, typename derived>
  584. arma_inline
  585. Mat<elem_type>
  586. Base_eval_expr<elem_type, derived>::eval() const
  587. {
  588. arma_extra_debug_sigprint();
  589. return Mat<elem_type>( static_cast<const derived&>(*this) );
  590. }
  591. //
  592. // extra functions defined in Base_trans_cx
  593. template<typename derived>
  594. arma_inline
  595. const Op<derived,op_htrans>
  596. Base_trans_cx<derived>::t() const
  597. {
  598. return Op<derived,op_htrans>( static_cast<const derived&>(*this) );
  599. }
  600. template<typename derived>
  601. arma_inline
  602. const Op<derived,op_htrans>
  603. Base_trans_cx<derived>::ht() const
  604. {
  605. return Op<derived,op_htrans>( static_cast<const derived&>(*this) );
  606. }
  607. template<typename derived>
  608. arma_inline
  609. const Op<derived,op_strans>
  610. Base_trans_cx<derived>::st() const
  611. {
  612. return Op<derived,op_strans>( static_cast<const derived&>(*this) );
  613. }
  614. //
  615. // extra functions defined in Base_trans_default
  616. template<typename derived>
  617. arma_inline
  618. const Op<derived,op_htrans>
  619. Base_trans_default<derived>::t() const
  620. {
  621. return Op<derived,op_htrans>( static_cast<const derived&>(*this) );
  622. }
  623. template<typename derived>
  624. arma_inline
  625. const Op<derived,op_htrans>
  626. Base_trans_default<derived>::ht() const
  627. {
  628. return Op<derived,op_htrans>( static_cast<const derived&>(*this) );
  629. }
  630. template<typename derived>
  631. arma_inline
  632. const Op<derived,op_htrans>
  633. Base_trans_default<derived>::st() const
  634. {
  635. return Op<derived,op_htrans>( static_cast<const derived&>(*this) );
  636. }
  637. //! @}