37 const eT* A_ptr = A.
memptr();
38 const eT* B_ptr = B.
memptr();
46 for(
uword i=0; i<N; ++i)
48 const eT A_tmp = A_ptr[i];
49 const eT B_tmp = B_ptr[i];
54 out_acc += A_tmp * B_tmp;
57 out_acc -= (A_acc * B_acc)/eT(N);
59 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
62 out[0] = out_acc/norm_val;
67 out /= stddev_A * stddev_B;
74 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
92 typedef typename std::complex<T> eT;
94 if(A.is_empty() || B.is_empty() )
100 if(A.is_vec() && B.is_vec())
102 arma_debug_check( (A.n_elem != B.n_elem),
"cor(): the number of elements in the two vectors must match" );
104 const eT* A_ptr = A.memptr();
105 const eT* B_ptr = B.memptr();
111 const uword N = A.n_elem;
113 for(
uword i=0; i<N; ++i)
115 const eT A_tmp = A_ptr[i];
116 const eT B_tmp = B_ptr[i];
124 out_acc -= (
std::conj(A_acc) * B_acc)/eT(N);
126 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
129 out[0] = out_acc/norm_val;
140 const uword N = A.n_rows;
141 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
152 template<
typename T1,
typename T2>
159 typedef typename T1::elem_type eT;
arma_inline const Op< T1, op_sum > sum(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed sum of elements of a matrix along a specified dimension (either rows or columns). The result is stored in a dense matrix that has either one column or one row. For dim = 0, find the sum of each column. For dim = 1, find the sum of each row. The default is dim = 0. NOTE: this function works differently than in Matlab/Octave.
arma_inline arma_warn_unused bool is_vec() const
returns true if the object can be interpreted as a column or row vector
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
void set_size(const uword in_elem)
change the matrix to have user specified dimensions (data is not preserved)
const mtOp< typename T1::pod_type, T1, op_stddev > stddev(const Base< typename T1::elem_type, T1 > &X, const uword norm_type=0, const uword dim=0)
#define arma_debug_assert_same_size
arma_inline const T1 & conj(const Base< typename T1::pod_type, T1 > &A)
const uword n_elem
number of elements in the matrix (read-only)
const uword n_rows
number of rows in the matrix (read-only)
arma_inline const Op< T1, op_htrans > trans(const Base< typename T1::elem_type, T1 > &X)
const T1 & A
first operand
static void direct_cor(Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B, const uword norm_type)
const T2 & B
second operand
#define arma_extra_debug_sigprint
static void direct_cor(Mat< eT > &out, const Mat< eT > &X, const uword norm_type)
uword aux_uword
storage of auxiliary data, uword format
arma_inline arma_warn_unused bool is_empty() const
returns true if the matrix has no elements
static void apply(Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_cor > &X)