31 const eT* A_ptr = A.
memptr();
32 const eT* B_ptr = B.
memptr();
40 for(
uword i=0; i<N; ++i)
42 const eT A_tmp = A_ptr[i];
43 const eT B_tmp = B_ptr[i];
48 out_acc += A_tmp * B_tmp;
51 out_acc -= (A_acc * B_acc)/eT(N);
53 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
56 out[0] = out_acc/norm_val;
63 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
80 typedef typename std::complex<T> eT;
82 if(A.is_vec() && B.is_vec())
84 arma_debug_check( (A.n_elem != B.n_elem),
"cov(): the number of elements in A and B must match" );
86 const eT* A_ptr = A.memptr();
87 const eT* B_ptr = B.memptr();
93 const uword N = A.n_elem;
95 for(
uword i=0; i<N; ++i)
97 const eT A_tmp = A_ptr[i];
98 const eT B_tmp = B_ptr[i];
106 out_acc -= (
std::conj(A_acc) * B_acc)/eT(N);
108 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
111 out[0] = out_acc/norm_val;
117 const uword N = A.n_rows;
118 const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
128 template<
typename T1,
typename T2>
135 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)
#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_cov(Mat< eT > &out, const Mat< eT > &X, const uword norm_type)
const T2 & B
second operand
static void apply(Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_cov > &X)
static void direct_cov(Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B, const uword norm_type)
#define arma_extra_debug_sigprint
uword aux_uword
storage of auxiliary data, uword format