Op_cor

Classes

class  op_cor

Functions

template<typename eT >
static void op_cor::direct_cor (Mat< eT > &out, const Mat< eT > &X, const u32 norm_type)
template<typename T >
static void op_cor::direct_cor (Mat< std::complex< T > > &out, const Mat< std::complex< T > > &X, const u32 norm_type)
template<typename T1 >
static void op_cor::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_cor > &in)

Function Documentation

template<typename eT >
void op_cor::direct_cor ( Mat< eT > &  out,
const Mat< eT > &  X,
const u32  norm_type 
) [inline, static, inherited]

Definition at line 27 of file op_cor_meat.hpp.

References Mat< eT >::is_vec(), Mat< eT >::n_rows, Mat< eT >::set_size(), stddev(), sum(), and trans().

Referenced by apply().

00028   {
00029   arma_extra_debug_sigprint();
00030 
00031   if(A.is_vec())
00032     {
00033     out.set_size(1,1);
00034     out[0] = eT(1);
00035     }
00036   else
00037     {
00038     const u32 N = A.n_rows;
00039     const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
00040 
00041     const Row<eT> acc = sum(A);
00042     const Row<eT> sd  = stddev(A);
00043 
00044     out = (trans(A) * A);
00045     out -= (trans(acc) * acc)/eT(N);
00046     out /= norm_val;
00047     out /= trans(sd) * sd;
00048     }
00049   }

template<typename T >
void op_cor::direct_cor ( Mat< std::complex< T > > &  out,
const Mat< std::complex< T > > &  X,
const u32  norm_type 
) [inline, static, inherited]

Definition at line 56 of file op_cor_meat.hpp.

References conj(), stddev(), sum(), and trans().

00057   {
00058   arma_extra_debug_sigprint();
00059 
00060   typedef typename std::complex<T> eT;
00061 
00062   if(A.is_vec())
00063     {
00064     out.set_size(1,1);
00065     out[0] = eT(1);
00066     }
00067   else
00068     {
00069     const u32 N = A.n_rows;
00070     const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
00071 
00072     const Row<eT> acc = sum(A);
00073     const Row<T>  sd  = stddev(A);
00074 
00075     out = trans(conj(A)) * A;
00076     out -= (trans(conj(acc)) * acc)/eT(N);
00077     out /= norm_val;
00078 
00079     //out = out / (trans(sd) * sd);
00080     out /= conv_to< Mat<eT> >::from(trans(sd) * sd);
00081     }
00082   }

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

Definition at line 89 of file op_cor_meat.hpp.

References Op< T1, op_type >::aux_u32_a, direct_cor(), unwrap_check< T1 >::M, and Op< T1, op_type >::m.

00090   {
00091   arma_extra_debug_sigprint();
00092   
00093   typedef typename T1::elem_type eT;
00094   
00095   const unwrap_check<T1> tmp(in.m, out);
00096   const Mat<eT>& A     = tmp.M;
00097   
00098   const u32 norm_type = in.aux_u32_a;
00099   
00100   op_cor::direct_cor(out, A, norm_type);
00101   }