1 // SPDX-License-Identifier: Apache-2.0
2 //
3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
4 // Copyright 2008-2016 National ICT Australia (NICTA)
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // ------------------------------------------------------------------------
17 
18 
19 //! \addtogroup xvec_htrans
20 //! @{
21 
22 
23 template<typename eT>
24 inline
xvec_htrans(const eT * const in_mem,const uword in_n_rows,const uword in_n_cols)25 xvec_htrans<eT>::xvec_htrans(const eT* const in_mem, const uword in_n_rows, const uword in_n_cols)
26   : mem   (in_mem             )
27   , n_rows(in_n_cols          )  // deliberately swapped
28   , n_cols(in_n_rows          )
29   , n_elem(in_n_rows*in_n_cols)
30   {
31   arma_extra_debug_sigprint();
32   }
33 
34 
35 
36 template<typename eT>
37 inline
38 void
extract(Mat<eT> & out) const39 xvec_htrans<eT>::extract(Mat<eT>& out) const
40   {
41   arma_extra_debug_sigprint();
42 
43   // NOTE: this function assumes that matrix 'out' has already been set to the correct size
44 
45   const eT*  in_mem = mem;
46         eT* out_mem = out.memptr();
47 
48   const uword N = n_elem;
49 
50   for(uword ii=0; ii < N; ++ii)
51     {
52     out_mem[ii] = access::alt_conj( in_mem[ii] );
53     }
54   }
55 
56 
57 
58 template<typename eT>
59 inline
60 eT
operator [](const uword ii) const61 xvec_htrans<eT>::operator[](const uword ii) const
62   {
63   return access::alt_conj( mem[ii] );
64   }
65 
66 
67 
68 template<typename eT>
69 inline
70 eT
at_alt(const uword ii) const71 xvec_htrans<eT>::at_alt(const uword ii) const
72   {
73   return access::alt_conj( mem[ii] );
74   }
75 
76 
77 
78 template<typename eT>
79 inline
80 eT
at(const uword in_row,const uword in_col) const81 xvec_htrans<eT>::at(const uword in_row, const uword in_col) const
82   {
83   //return (n_rows == 1) ? access::alt_conj( mem[in_col] ) : access::alt_conj( mem[in_row] );
84 
85   return access::alt_conj( mem[in_row + in_col] );  // either in_row or in_col must be zero, as we're storing a vector
86   }
87 
88 
89 
90 //! @}
91