xvec_htrans_meat.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 xvec_htrans
  16. //! @{
  17. template<typename eT>
  18. inline
  19. xvec_htrans<eT>::xvec_htrans(const eT* const in_mem, const uword in_n_rows, const uword in_n_cols)
  20. : mem (in_mem )
  21. , n_rows(in_n_cols ) // deliberately swapped
  22. , n_cols(in_n_rows )
  23. , n_elem(in_n_rows*in_n_cols)
  24. {
  25. arma_extra_debug_sigprint();
  26. }
  27. template<typename eT>
  28. inline
  29. void
  30. xvec_htrans<eT>::extract(Mat<eT>& out) const
  31. {
  32. arma_extra_debug_sigprint();
  33. // NOTE: this function assumes that matrix 'out' has already been set to the correct size
  34. const eT* in_mem = mem;
  35. eT* out_mem = out.memptr();
  36. const uword N = n_elem;
  37. for(uword ii=0; ii < N; ++ii)
  38. {
  39. out_mem[ii] = access::alt_conj( in_mem[ii] );
  40. }
  41. }
  42. template<typename eT>
  43. inline
  44. eT
  45. xvec_htrans<eT>::operator[](const uword ii) const
  46. {
  47. return access::alt_conj( mem[ii] );
  48. }
  49. template<typename eT>
  50. inline
  51. eT
  52. xvec_htrans<eT>::at_alt(const uword ii) const
  53. {
  54. return access::alt_conj( mem[ii] );
  55. }
  56. template<typename eT>
  57. inline
  58. eT
  59. xvec_htrans<eT>::at(const uword in_row, const uword in_col) const
  60. {
  61. //return (n_rows == 1) ? access::alt_conj( mem[in_col] ) : access::alt_conj( mem[in_row] );
  62. return access::alt_conj( mem[in_row + in_col] ); // either in_row or in_col must be zero, as we're storing a vector
  63. }
  64. //! @}