op_htrans_meat.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2008-2011 Conrad Sanderson
00003 // 
00004 // This file is part of the Armadillo C++ library.
00005 // It is provided without any warranty of fitness
00006 // for any purpose. You can redistribute this file
00007 // and/or modify it under the terms of the GNU
00008 // Lesser General Public License (LGPL) as published
00009 // by the Free Software Foundation, either version 3
00010 // of the License or (at your option) any later version.
00011 // (see http://www.opensource.org/licenses for more info)
00012 
00013 
00016 
00017 
00018 
00019 template<typename eT>
00020 arma_inline
00021 void
00022 op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx<eT>::result* junk)
00023   {
00024   arma_extra_debug_sigprint();
00025   arma_ignore(junk);
00026   
00027   op_strans::apply_noalias(out, A);
00028   }
00029 
00030 
00031 
00032 template<typename eT>
00033 inline
00034 void
00035 op_htrans::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_only<eT>::result* junk)
00036   {
00037   arma_extra_debug_sigprint();
00038   arma_ignore(junk);
00039   
00040   const uword A_n_rows = A.n_rows;
00041   const uword A_n_cols = A.n_cols;
00042   
00043   out.set_size(A_n_cols, A_n_rows);
00044   
00045   for(uword in_row = 0; in_row < A_n_rows; ++in_row)
00046     {
00047     const uword out_col = in_row;
00048   
00049     for(uword in_col = 0; in_col < A_n_cols; ++in_col)
00050       {
00051       const uword out_row = in_col;
00052       out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) );
00053       }
00054     }
00055   
00056   }
00057 
00058 
00059 
00060 template<typename eT>
00061 arma_inline
00062 void
00063 op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_not_cx<eT>::result* junk)
00064   {
00065   arma_extra_debug_sigprint();
00066   arma_ignore(junk);
00067   
00068   op_strans::apply(out, A);
00069   }
00070 
00071 
00072 
00073 template<typename eT>
00074 inline
00075 void
00076 op_htrans::apply(Mat<eT>& out, const Mat<eT>& A, const typename arma_cx_only<eT>::result* junk)
00077   {
00078   arma_extra_debug_sigprint();
00079   arma_ignore(junk);
00080   
00081   if(&out != &A)
00082     {
00083     op_htrans::apply_noalias(out, A);
00084     }
00085   else
00086     {
00087     if(out.n_rows == out.n_cols)
00088       {
00089       arma_extra_debug_print("doing in-place hermitian transpose of a square matrix");
00090       
00091       const uword n_rows = out.n_rows;
00092       const uword n_cols = out.n_cols;
00093       
00094       for(uword col=0; col<n_cols; ++col)
00095         {
00096         eT* coldata = out.colptr(col);
00097         
00098         out.at(col,col) = std::conj( out.at(col,col) );
00099         
00100         for(uword row=(col+1); row<n_rows; ++row)
00101           {
00102           const eT val1 = std::conj(coldata[row]);
00103           const eT val2 = std::conj(out.at(col,row));
00104           
00105           out.at(col,row) = val1;
00106           coldata[row]    = val2;
00107           }
00108         }
00109       }
00110     else
00111       {
00112       Mat<eT> tmp;
00113       op_strans::apply_noalias(tmp, A);
00114       
00115       out.steal_mem(tmp);
00116       }
00117     }
00118   
00119   }
00120 
00121 
00122 
00123 template<typename T1>
00124 inline
00125 void
00126 op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in)
00127   {
00128   arma_extra_debug_sigprint();
00129   
00130   typedef typename T1::elem_type eT;
00131   
00132   const unwrap<T1> tmp(in.m);
00133   const Mat<eT>& A = tmp.M;
00134   
00135   op_htrans::apply(out, A);
00136   }
00137 
00138 
00139 
00140 template<typename T1>
00141 inline
00142 void
00143 op_htrans::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1, op_trimat>, op_htrans>& in)
00144   {
00145   arma_extra_debug_sigprint();
00146   
00147   typedef typename T1::elem_type eT;
00148   
00149   const unwrap<T1>   tmp(in.m.m);
00150   const Mat<eT>& A = tmp.M;
00151   
00152   const bool upper = in.m.aux_uword_a;
00153   
00154   op_trimat::apply_htrans(out, A, upper);
00155   }
00156 
00157 
00158 
00159 template<typename T1>
00160 inline
00161 void
00162 op_htrans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans2>& in)
00163   {
00164   arma_extra_debug_sigprint();
00165   
00166   typedef typename T1::elem_type eT;
00167   
00168   const unwrap<T1> tmp(in.m);
00169   
00170   op_htrans::apply(out, tmp.M);
00171   
00172   arrayops::inplace_mul( out.memptr(), in.aux, out.n_elem );
00173   }
00174 
00175 
00176 


armadillo_matrix
Author(s): Conrad Sanderson - NICTA (www.nicta.com.au), (Wrapper by Sjoerd van den Dries)
autogenerated on Tue Jan 7 2014 11:42:05