Op_trans

Classes

class  op_trans
 'matrix transpose' operation More...
class  op_trans2

Functions

template<typename eT >
static void op_trans::apply_noalias (Mat< eT > &out, const Mat< eT > &A)
 Immediate transpose of a dense matrix.
template<typename eT >
static void op_trans::apply (Mat< eT > &out, const Mat< eT > &A)
template<typename T1 >
static void op_trans::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_trans > &in)
template<typename T1 >
static void op_trans2::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_trans2 > &in)

Function Documentation

template<typename eT >
void op_trans::apply_noalias ( Mat< eT > &  out,
const Mat< eT > &  A 
) [inline, static, inherited]

Immediate transpose of a dense matrix.

Definition at line 26 of file op_trans_meat.hpp.

References Mat< eT >::at(), syslib::copy_elem(), Mat< eT >::mem, Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, and Mat< eT >::set_size().

Referenced by apply(), Mat< eT >::print_trans(), and Mat< eT >::raw_print_trans().

00027   {
00028   arma_extra_debug_sigprint();
00029   
00030   const u32 A_n_cols = A.n_cols;
00031   const u32 A_n_rows = A.n_rows;
00032   
00033   out.set_size(A_n_cols, A_n_rows);
00034   
00035   if( (A_n_cols == 1) || (A_n_rows == 1) )
00036     {
00037     syslib::copy_elem( out.memptr(), A.mem, A.n_elem );
00038     }
00039   else
00040     {
00041     for(u32 in_row = 0; in_row<A_n_rows; ++in_row)
00042       {
00043       const u32 out_col = in_row;
00044     
00045       for(u32 in_col = 0; in_col<A_n_cols; ++in_col)
00046         {
00047         const u32 out_row = in_col;
00048         out.at(out_row, out_col) = A.at(in_row, in_col);
00049         }
00050       }
00051     }
00052   
00053   }

template<typename eT >
void op_trans::apply ( Mat< eT > &  out,
const Mat< eT > &  A 
) [inline, static, inherited]

Definition at line 60 of file op_trans_meat.hpp.

References apply_noalias(), Mat< eT >::at(), Mat< eT >::colptr(), Mat< eT >::n_cols, and Mat< eT >::n_rows.

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

00061   {
00062   arma_extra_debug_sigprint();
00063   
00064   if(&out != &A)
00065     {
00066     op_trans::apply_noalias(out, A);
00067     }
00068   else
00069     {
00070     if(out.n_rows == out.n_cols)
00071       {
00072       arma_extra_debug_print("op_trans::apply(): doing in-place transpose of a square matrix");
00073       
00074       const u32 n_rows = out.n_rows;
00075       const u32 n_cols = out.n_cols;
00076       
00077       for(u32 col=0; col<n_cols; ++col)
00078         {
00079         eT* coldata = out.colptr(col);
00080         
00081         for(u32 row=(col+1); row<n_rows; ++row)
00082           {
00083           std::swap( out.at(col,row), coldata[row] );
00084           }
00085         }
00086       }
00087     else
00088       {
00089       const Mat<eT> A_copy = A;
00090       op_trans::apply_noalias(out, A_copy);
00091       }
00092     }
00093   }

template<typename T1 >
void op_trans::apply ( Mat< typename T1::elem_type > &  out,
const Op< T1, op_trans > &  in 
) [inline, static, inherited]

Definition at line 100 of file op_trans_meat.hpp.

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

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

template<typename T1 >
void op_trans2::apply ( Mat< typename T1::elem_type > &  out,
const Op< T1, op_trans2 > &  in 
) [inline, static, inherited]

Definition at line 161 of file op_trans_meat.hpp.

References Op< T1, op_type >::aux, unwrap< T1 >::M, Op< T1, op_type >::m, Mat< eT >::memptr(), and Mat< eT >::n_elem.

00162   {
00163   arma_extra_debug_sigprint();
00164   
00165   typedef typename T1::elem_type eT;
00166   
00167   const unwrap<T1> tmp(in.m);
00168   
00169   op_trans::apply(out, tmp.M);
00170   
00171         eT* out_mem = out.memptr();
00172   const u32 n_elem  = out.n_elem;
00173   const eT  k       = in.aux;
00174   
00175   for(u32 i=0; i<n_elem; ++i)
00176     {
00177     out_mem[i] *= k;
00178     }
00179   
00180   }