annotate armadillo-2.4.4/include/armadillo_bits/op_htrans_meat.hpp @ 18:8d046a9d36aa slimline

Back out rev 13:ac07c60aa798. Like an idiot, I committed a whole pile of unrelated changes in the guise of a single typo fix. Will re-commit in stages
author Chris Cannam
date Thu, 10 May 2012 10:45:44 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2008-2011 Conrad Sanderson
max@0 3 //
max@0 4 // This file is part of the Armadillo C++ library.
max@0 5 // It is provided without any warranty of fitness
max@0 6 // for any purpose. You can redistribute this file
max@0 7 // and/or modify it under the terms of the GNU
max@0 8 // Lesser General Public License (LGPL) as published
max@0 9 // by the Free Software Foundation, either version 3
max@0 10 // of the License or (at your option) any later version.
max@0 11 // (see http://www.opensource.org/licenses for more info)
max@0 12
max@0 13
max@0 14 //! \addtogroup op_htrans
max@0 15 //! @{
max@0 16
max@0 17
max@0 18
max@0 19 template<typename eT>
max@0 20 arma_inline
max@0 21 void
max@0 22 op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx<eT>::result* junk)
max@0 23 {
max@0 24 arma_extra_debug_sigprint();
max@0 25 arma_ignore(junk);
max@0 26
max@0 27 op_strans::apply_noalias(out, A);
max@0 28 }
max@0 29
max@0 30
max@0 31
max@0 32 template<typename eT>
max@0 33 inline
max@0 34 void
max@0 35 op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_only<eT>::result* junk)
max@0 36 {
max@0 37 arma_extra_debug_sigprint();
max@0 38 arma_ignore(junk);
max@0 39
max@0 40 const uword A_n_rows = A.n_rows;
max@0 41 const uword A_n_cols = A.n_cols;
max@0 42
max@0 43 out.set_size(A_n_cols, A_n_rows);
max@0 44
max@0 45 for(uword in_row = 0; in_row < A_n_rows; ++in_row)
max@0 46 {
max@0 47 const uword out_col = in_row;
max@0 48
max@0 49 for(uword in_col = 0; in_col < A_n_cols; ++in_col)
max@0 50 {
max@0 51 const uword out_row = in_col;
max@0 52 out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) );
max@0 53 }
max@0 54 }
max@0 55
max@0 56 }
max@0 57
max@0 58
max@0 59
max@0 60 template<typename eT>
max@0 61 arma_inline
max@0 62 void
max@0 63 op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx<eT>::result* junk)
max@0 64 {
max@0 65 arma_extra_debug_sigprint();
max@0 66 arma_ignore(junk);
max@0 67
max@0 68 op_strans::apply(out, A);
max@0 69 }
max@0 70
max@0 71
max@0 72
max@0 73 template<typename eT>
max@0 74 inline
max@0 75 void
max@0 76 op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_only<eT>::result* junk)
max@0 77 {
max@0 78 arma_extra_debug_sigprint();
max@0 79 arma_ignore(junk);
max@0 80
max@0 81 if(&out != &A)
max@0 82 {
max@0 83 op_htrans::apply_noalias(out, A);
max@0 84 }
max@0 85 else
max@0 86 {
max@0 87 if(out.n_rows == out.n_cols)
max@0 88 {
max@0 89 arma_extra_debug_print("doing in-place hermitian transpose of a square matrix");
max@0 90
max@0 91 const uword n_rows = out.n_rows;
max@0 92 const uword n_cols = out.n_cols;
max@0 93
max@0 94 for(uword col=0; col<n_cols; ++col)
max@0 95 {
max@0 96 eT* coldata = out.colptr(col);
max@0 97
max@0 98 out.at(col,col) = std::conj( out.at(col,col) );
max@0 99
max@0 100 for(uword row=(col+1); row<n_rows; ++row)
max@0 101 {
max@0 102 const eT val1 = std::conj(coldata[row]);
max@0 103 const eT val2 = std::conj(out.at(col,row));
max@0 104
max@0 105 out.at(col,row) = val1;
max@0 106 coldata[row] = val2;
max@0 107 }
max@0 108 }
max@0 109 }
max@0 110 else
max@0 111 {
max@0 112 Mat<eT> tmp;
max@0 113 op_strans::apply_noalias(tmp, A);
max@0 114
max@0 115 out.steal_mem(tmp);
max@0 116 }
max@0 117 }
max@0 118
max@0 119 }
max@0 120
max@0 121
max@0 122
max@0 123 template<typename T1>
max@0 124 inline
max@0 125 void
max@0 126 op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in)
max@0 127 {
max@0 128 arma_extra_debug_sigprint();
max@0 129
max@0 130 typedef typename T1::elem_type eT;
max@0 131
max@0 132 const unwrap<T1> tmp(in.m);
max@0 133 const Mat<eT>& A = tmp.M;
max@0 134
max@0 135 op_htrans::apply(out, A);
max@0 136 }
max@0 137
max@0 138
max@0 139
max@0 140 template<typename T1>
max@0 141 inline
max@0 142 void
max@0 143 op_htrans::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trimat>, op_htrans>& in)
max@0 144 {
max@0 145 arma_extra_debug_sigprint();
max@0 146
max@0 147 typedef typename T1::elem_type eT;
max@0 148
max@0 149 const unwrap<T1> tmp(in.m.m);
max@0 150 const Mat<eT>& A = tmp.M;
max@0 151
max@0 152 const bool upper = in.m.aux_uword_a;
max@0 153
max@0 154 op_trimat::apply_htrans(out, A, upper);
max@0 155 }
max@0 156
max@0 157
max@0 158
max@0 159 template<typename T1>
max@0 160 inline
max@0 161 void
max@0 162 op_htrans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2>& in)
max@0 163 {
max@0 164 arma_extra_debug_sigprint();
max@0 165
max@0 166 typedef typename T1::elem_type eT;
max@0 167
max@0 168 const unwrap<T1> tmp(in.m);
max@0 169
max@0 170 op_htrans::apply(out, tmp.M);
max@0 171
max@0 172 arrayops::inplace_mul( out.memptr(), in.aux, out.n_elem );
max@0 173 }
max@0 174
max@0 175
max@0 176
max@0 177 //! @}