//! More...
Classes | |
class | glue_cor |
Functions | |
template<typename eT > | |
static void | glue_cor::direct_cor (Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B, const u32 norm_type) |
template<typename T > | |
static void | glue_cor::direct_cor (Mat< std::complex< T > > &out, const Mat< std::complex< T > > &A, const Mat< std::complex< T > > &B, const u32 norm_type) |
template<typename T1 , typename T2 > | |
static void | glue_cor::apply (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_cor > &X) |
//!
void glue_cor::direct_cor | ( | Mat< eT > & | out, | |
const Mat< eT > & | A, | |||
const Mat< eT > & | B, | |||
const u32 | norm_type | |||
) | [inline, static, inherited] |
Definition at line 26 of file glue_cor_meat.hpp.
References Mat< eT >::is_vec(), Mat< eT >::memptr(), Mat< eT >::n_elem, Mat< eT >::n_rows, Mat< eT >::set_size(), stddev(), sum(), and trans().
Referenced by apply().
{ arma_extra_debug_sigprint(); if(A.is_vec() && B.is_vec()) { arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of elements in A and B must match" ); const eT* A_ptr = A.memptr(); const eT* B_ptr = B.memptr(); eT A_acc = eT(0); eT B_acc = eT(0); eT out_acc = eT(0); const u32 N = A.n_elem; for(u32 i=0; i<N; ++i) { const eT A_tmp = A_ptr[i]; const eT B_tmp = B_ptr[i]; A_acc += A_tmp; B_acc += B_tmp; out_acc += A_tmp * B_tmp; } out_acc -= (A_acc * B_acc)/eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); out.set_size(1,1); out[0] = out_acc/norm_val; const Mat<eT> stddev_A = (A.n_rows == 1) ? stddev(trans(A)) : stddev(A); const Mat<eT> stddev_B = (B.n_rows == 1) ? stddev(trans(B)) : stddev(B); out /= stddev_A * stddev_B; } else { arma_debug_assert_same_size(A, B, "cor()"); const u32 N = A.n_rows; const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); out = trans(A) * B; out -= (trans(sum(A)) * sum(B))/eT(N); out /= norm_val; out /= trans(stddev(A)) * stddev(B); } }
void glue_cor::direct_cor | ( | Mat< std::complex< T > > & | out, | |
const Mat< std::complex< T > > & | A, | |||
const Mat< std::complex< T > > & | B, | |||
const u32 | norm_type | |||
) | [inline, static, inherited] |
Definition at line 85 of file glue_cor_meat.hpp.
References conj(), stddev(), sum(), and trans().
{ arma_extra_debug_sigprint(); typedef typename std::complex<T> eT; if(A.is_vec() && B.is_vec()) { arma_debug_check( (A.n_elem != B.n_elem), "cor(): the number of elements in A and B must match" ); const eT* A_ptr = A.memptr(); const eT* B_ptr = B.memptr(); eT A_acc = eT(0); eT B_acc = eT(0); eT out_acc = eT(0); const u32 N = A.n_elem; for(u32 i=0; i<N; ++i) { const eT A_tmp = A_ptr[i]; const eT B_tmp = B_ptr[i]; A_acc += A_tmp; B_acc += B_tmp; out_acc += std::conj(A_tmp) * B_tmp; } out_acc -= (std::conj(A_acc) * B_acc)/eT(N); const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); out.set_size(1,1); out[0] = out_acc/norm_val; const Mat<T> stddev_A = (A.n_rows == 1) ? stddev(trans(A)) : stddev(A); const Mat<T> stddev_B = (B.n_rows == 1) ? stddev(trans(B)) : stddev(B); out /= conv_to< Mat<eT> >::from( stddev_A * stddev_B ); } else { arma_debug_assert_same_size(A, B, "cor()"); const u32 N = A.n_rows; const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N); out = trans(conj(A)) * B; out -= (trans(conj(sum(A))) * sum(B))/eT(N); out /= norm_val; out /= conv_to< Mat<eT> >::from( trans(stddev(A)) * stddev(B) ); } }
void glue_cor::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_cor > & | X | |||
) | [inline, static, inherited] |
Definition at line 146 of file glue_cor_meat.hpp.
References Glue< T1, T2, glue_type >::A, Glue< T1, T2, glue_type >::aux_u32, Glue< T1, T2, glue_type >::B, direct_cor(), and unwrap_check< T1 >::M.
{ arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const unwrap_check<T1> A_tmp(X.A, out); const unwrap_check<T2> B_tmp(X.B, out); const Mat<eT>& A = A_tmp.M; const Mat<eT>& B = B_tmp.M; const u32 norm_type = X.aux_u32; if(&A != &B) { glue_cor::direct_cor(out, A, B, norm_type); } else { op_cor::direct_cor(out, A, norm_type); } }