Op_htrans

Classes

class  op_htrans
 'hermitian transpose' operation (only valid for complex number matrices) More...

Functions

template<typename T >
static void op_htrans::apply_noalias (Mat< std::complex< T > > &out, const Mat< std::complex< T > > &A)
 Immediate transpose of a complex matrix.
template<typename T >
static void op_htrans::apply (Mat< std::complex< T > > &out, const Mat< std::complex< T > > &A)
 Immediate transpose of a complex matrix.
template<typename T , typename T1 >
static void op_htrans::apply (Mat< std::complex< T > > &out, const Op< T1, op_htrans > &in)

Function Documentation

template<typename T >
void op_htrans::apply_noalias ( Mat< std::complex< T > > &  out,
const Mat< std::complex< T > > &  A 
) [inline, static, inherited]

Immediate transpose of a complex matrix.

Definition at line 26 of file op_htrans_meat.hpp.

References conj().

Referenced by apply().

00027   {
00028   arma_extra_debug_sigprint();
00029   
00030   out.set_size(A.n_cols, A.n_rows);
00031   
00032   for(u32 in_row = 0; in_row<A.n_rows; ++in_row)
00033     {
00034     const u32 out_col = in_row;
00035   
00036     for(u32 in_col = 0; in_col<A.n_cols; ++in_col)
00037       {
00038       const u32 out_row = in_col;
00039       out.at(out_row, out_col) = std::conj( A.at(in_row, in_col) );
00040       }
00041     }
00042   
00043   }

template<typename T >
void op_htrans::apply ( Mat< std::complex< T > > &  out,
const Mat< std::complex< T > > &  A 
) [inline, static, inherited]

Immediate transpose of a complex matrix.

Definition at line 51 of file op_htrans_meat.hpp.

References apply_noalias(), and conj().

Referenced by apply(), and auxlib::svd().

00052   {
00053   arma_extra_debug_sigprint();
00054   
00055   typedef typename std::complex<T> eT;
00056 
00057   if(&out != &A)
00058     {
00059     op_htrans::apply_noalias(out, A);
00060     }
00061   else
00062     {
00063     if(out.n_rows == out.n_cols)
00064       {
00065       arma_extra_debug_print("doing in-place hermitian transpose of a square matrix");
00066       
00067       const u32 n_rows = out.n_rows;
00068       const u32 n_cols = out.n_cols;
00069       
00070       for(u32 col=0; col<n_cols; ++col)
00071         {
00072         eT* coldata = out.colptr(col);
00073         
00074         out.at(col,col) = std::conj( out.at(col,col) );
00075         
00076         for(u32 row=(col+1); row<n_rows; ++row)
00077           {
00078           const eT val1 = std::conj(coldata[row]);
00079           const eT val2 = std::conj(out.at(col,row));
00080           
00081           out.at(col,row) = val1;
00082           coldata[row]    = val2;
00083           }
00084         }
00085       }
00086     else
00087       {
00088       const Mat<eT> A_copy = A;
00089       op_htrans::apply_noalias(out, A_copy);
00090       }
00091     }
00092   
00093   }

template<typename T , typename T1 >
void op_htrans::apply ( Mat< std::complex< T > > &  out,
const Op< T1, op_htrans > &  in 
) [inline, static, inherited]

Definition at line 100 of file op_htrans_meat.hpp.

References apply(), unwrap< T1 >::M, and Op< T1, op_type >::m.

00101   {
00102   arma_extra_debug_sigprint();
00103   
00104   typedef typename std::complex<T> eT;
00105   
00106   isnt_same_type<eT,typename T1::elem_type>::check();
00107   
00108   const unwrap<T1> tmp(in.m);
00109   const Mat<eT>& A = tmp.M;
00110   
00111   op_htrans::apply(out, A);
00112   }