1 | // Copyright (C) 2013 Conrad Sanderson |
---|
2 | // |
---|
3 | // This Source Code Form is subject to the terms of the Mozilla Public |
---|
4 | // License, v. 2.0. If a copy of the MPL was not distributed with this |
---|
5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. |
---|
6 | |
---|
7 | |
---|
8 | //! \addtogroup xvec_htrans |
---|
9 | //! @{ |
---|
10 | |
---|
11 | |
---|
12 | template<typename eT> |
---|
13 | inline |
---|
14 | xvec_htrans<eT>::xvec_htrans(const eT* const in_mem, const uword in_n_rows, const uword in_n_cols) |
---|
15 | : mem (in_mem ) |
---|
16 | , n_rows(in_n_cols ) // deliberately swapped |
---|
17 | , n_cols(in_n_rows ) |
---|
18 | , n_elem(in_n_rows*in_n_cols) |
---|
19 | { |
---|
20 | arma_extra_debug_sigprint(); |
---|
21 | } |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | template<typename eT> |
---|
26 | inline |
---|
27 | void |
---|
28 | xvec_htrans<eT>::extract(Mat<eT>& out) const |
---|
29 | { |
---|
30 | arma_extra_debug_sigprint(); |
---|
31 | |
---|
32 | // NOTE: this function assumes that matrix 'out' has already been set to the correct size |
---|
33 | |
---|
34 | const eT* in_mem = mem; |
---|
35 | eT* out_mem = out.memptr(); |
---|
36 | |
---|
37 | const uword N = n_elem; |
---|
38 | |
---|
39 | for(uword ii=0; ii < N; ++ii) |
---|
40 | { |
---|
41 | out_mem[ii] = access::alt_conj( in_mem[ii] ); |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | template<typename eT> |
---|
48 | inline |
---|
49 | eT |
---|
50 | xvec_htrans<eT>::operator[](const uword ii) const |
---|
51 | { |
---|
52 | return access::alt_conj( mem[ii] ); |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | template<typename eT> |
---|
58 | inline |
---|
59 | eT |
---|
60 | xvec_htrans<eT>::at_alt(const uword ii) const |
---|
61 | { |
---|
62 | return access::alt_conj( mem[ii] ); |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | template<typename eT> |
---|
68 | inline |
---|
69 | eT |
---|
70 | xvec_htrans<eT>::at(const uword in_row, const uword in_col) const |
---|
71 | { |
---|
72 | //return (n_rows == 1) ? access::alt_conj( mem[in_col] ) : access::alt_conj( mem[in_row] ); |
---|
73 | |
---|
74 | return access::alt_conj( mem[in_row + in_col] ); // either in_row or in_col must be zero, as we're storing a vector |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | //! @} |
---|