xtrans_mat_meat.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 xtrans_mat
  16. //! @{
  17. template<typename eT, bool do_conj>
  18. inline
  19. xtrans_mat<eT,do_conj>::xtrans_mat(const Mat<eT>& in_X)
  20. : X (in_X )
  21. , n_rows(in_X.n_cols) // deliberately swapped
  22. , n_cols(in_X.n_rows)
  23. , n_elem(in_X.n_elem)
  24. {
  25. arma_extra_debug_sigprint();
  26. }
  27. template<typename eT, bool do_conj>
  28. inline
  29. void
  30. xtrans_mat<eT,do_conj>::extract(Mat<eT>& out) const
  31. {
  32. arma_extra_debug_sigprint();
  33. really_do_conj ? op_htrans::apply_mat(out, X) : op_strans::apply_mat(out, X);
  34. }
  35. template<typename eT, bool do_conj>
  36. inline
  37. eT
  38. xtrans_mat<eT,do_conj>::operator[](const uword ii) const
  39. {
  40. if(Y.n_elem > 0)
  41. {
  42. return Y[ii];
  43. }
  44. else
  45. {
  46. really_do_conj ? op_htrans::apply_mat(Y, X) : op_strans::apply_mat(Y, X);
  47. return Y[ii];
  48. }
  49. }
  50. template<typename eT, bool do_conj>
  51. inline
  52. eT
  53. xtrans_mat<eT,do_conj>::at_alt(const uword ii) const
  54. {
  55. return (*this).operator[](ii);
  56. }
  57. template<typename eT, bool do_conj>
  58. arma_inline
  59. eT
  60. xtrans_mat<eT,do_conj>::at(const uword in_row, const uword in_col) const
  61. {
  62. return really_do_conj ? eT(access::alt_conj(X.at(in_col, in_row))) : eT(X.at(in_col, in_row));
  63. // in_row and in_col deliberately swapped above
  64. }
  65. //! @}