//! More...
Classes | |
class | op_dot |
//! dot product operation More... | |
class | op_norm_dot |
//! normalised dot product operation More... | |
Functions | |
template<typename eT > | |
arma_hot static arma_pure eT | op_dot::direct_dot_arma (const u32 n_elem, const eT *const A, const eT *const B) |
for two arrays, generic version | |
template<typename eT > | |
arma_hot static arma_pure arma_float_only< eT >::result | op_dot::direct_dot (const u32 n_elem, const eT *const A, const eT *const B) |
for two arrays, float and double version | |
template<typename eT > | |
arma_hot static arma_pure eT | op_dot::direct_dot (const u32 n_elem, const eT *const A, const eT *const B, const eT *C) |
for three arrays | |
template<typename T1 , typename T2 > | |
arma_hot static arma_inline T1::elem_type | op_dot::apply (const Base< typename T1::elem_type, T1 > &X, const Base< typename T1::elem_type, T2 > &Y) |
template<typename T1 , typename T2 > | |
static arma_hot T1::elem_type | op_dot::apply_unwrap (const Base< typename T1::elem_type, T1 > &X, const Base< typename T1::elem_type, T2 > &Y) |
template<typename T1 , typename T2 > | |
static arma_hot T1::elem_type | op_dot::apply_proxy (const Base< typename T1::elem_type, T1 > &X, const Base< typename T1::elem_type, T2 > &Y) |
template<typename T1 , typename T2 > | |
arma_hot static arma_inline T1::elem_type | op_norm_dot::apply (const Base< typename T1::elem_type, T1 > &X, const Base< typename T1::elem_type, T2 > &Y) |
template<typename T1 , typename T2 > | |
static arma_hot T1::elem_type | op_norm_dot::apply_unwrap (const Base< typename T1::elem_type, T1 > &X, const Base< typename T1::elem_type, T2 > &Y) |
template<typename T1 , typename T2 > | |
static arma_hot T1::elem_type | op_norm_dot::apply_proxy (const Base< typename T1::elem_type, T1 > &X, const Base< typename T1::elem_type, T2 > &Y) |
//!
arma_hot arma_pure eT op_dot::direct_dot_arma | ( | const u32 | n_elem, | |
const eT *const | A, | |||
const eT *const | B | |||
) | [inline, static, inherited] |
for two arrays, generic version
Definition at line 29 of file op_dot_meat.hpp.
Referenced by direct_dot().
{ arma_extra_debug_sigprint(); eT val1 = eT(0); eT val2 = eT(0); u32 i, j; for(i=0, j=1; j<n_elem; i+=2, j+=2) { val1 += A[i] * B[i]; val2 += A[j] * B[j]; } if(i < n_elem) { val1 += A[i] * B[i]; } return val1 + val2; }
arma_hot arma_pure arma_integral_only< eT >::result op_dot::direct_dot | ( | const u32 | n_elem, | |
const eT *const | A, | |||
const eT *const | B | |||
) | [inline, static, inherited] |
for two arrays, float and double version
for two arrays, integral version
for two arrays, complex version
Definition at line 60 of file op_dot_meat.hpp.
References atlas::cblas_dot(), direct_dot_arma(), and blas::dot_().
Referenced by as_scalar_redirect< 3 >::apply(), as_scalar_redirect< 2 >::apply(), apply_unwrap(), as_scalar_diag(), op_dotext::direct_rowvec_mat_colvec(), and op_dotext::direct_rowvec_transmat_colvec().
{ arma_extra_debug_sigprint(); if( n_elem <= (128/sizeof(eT)) ) { return op_dot::direct_dot_arma(n_elem, A, B); } else { #if defined(ARMA_USE_ATLAS) { return atlas::cblas_dot(n_elem, A, B); } #elif defined(ARMA_USE_BLAS) { const int n = n_elem; return blas::dot_(&n, A, B); } #else { return op_dot::direct_dot_arma(n_elem, A, B); } #endif } }
arma_hot arma_pure eT op_dot::direct_dot | ( | const u32 | n_elem, | |
const eT *const | A, | |||
const eT *const | B, | |||
const eT * | C | |||
) | [inline, static, inherited] |
for three arrays
Definition at line 135 of file op_dot_meat.hpp.
{ arma_extra_debug_sigprint(); eT val = eT(0); for(u32 i=0; i<n_elem; ++i) { val += A[i] * B[i] * C[i]; } return val; }
arma_hot arma_inline T1::elem_type op_dot::apply | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const Base< typename T1::elem_type, T2 > & | Y | |||
) | [static, inherited] |
Definition at line 155 of file op_dot_meat.hpp.
References apply_proxy(), and apply_unwrap().
Referenced by dot().
{ arma_extra_debug_sigprint(); if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) ) { return op_dot::apply_unwrap(X,Y); } else { return op_dot::apply_proxy(X,Y); } }
arma_hot arma_inline T1::elem_type op_dot::apply_unwrap | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const Base< typename T1::elem_type, T2 > & | Y | |||
) | [inline, static, inherited] |
Definition at line 175 of file op_dot_meat.hpp.
References direct_dot(), Base< elem_type, derived >::get_ref(), Mat< eT >::mem, and Mat< eT >::n_elem.
Referenced by apply().
{ arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const unwrap<T1> tmp1(X.get_ref()); const unwrap<T2> tmp2(Y.get_ref()); const Mat<eT>& A = tmp1.M; const Mat<eT>& B = tmp2.M; arma_debug_check( (A.n_elem != B.n_elem), "dot(): objects must have the same number of elements" ); return op_dot::direct_dot(A.n_elem, A.mem, B.mem); }
arma_hot T1::elem_type op_dot::apply_proxy | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const Base< typename T1::elem_type, T2 > & | Y | |||
) | [inline, static, inherited] |
Definition at line 198 of file op_dot_meat.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by apply().
{ arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const Proxy<T1> A(X.get_ref()); const Proxy<T2> B(Y.get_ref()); arma_debug_check( (A.n_elem != B.n_elem), "dot(): objects must have the same number of elements" ); const u32 n_elem = A.n_elem; eT val = eT(0); for(u32 i=0; i<n_elem; ++i) { val += A[i] * B[i]; } return val; }
arma_hot arma_inline T1::elem_type op_norm_dot::apply | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const Base< typename T1::elem_type, T2 > & | Y | |||
) | [static, inherited] |
Definition at line 230 of file op_dot_meat.hpp.
References op_norm_dot::apply_proxy(), and op_norm_dot::apply_unwrap().
Referenced by norm_dot().
{ arma_extra_debug_sigprint(); if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) ) { return op_norm_dot::apply_unwrap(X,Y); } else { return op_norm_dot::apply_proxy(X,Y); } }
arma_hot T1::elem_type op_norm_dot::apply_unwrap | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const Base< typename T1::elem_type, T2 > & | Y | |||
) | [inline, static, inherited] |
Definition at line 250 of file op_dot_meat.hpp.
References Base< elem_type, derived >::get_ref(), Mat< eT >::memptr(), Mat< eT >::n_elem, and sqrt().
Referenced by op_norm_dot::apply().
{ arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const unwrap<T1> tmp1(X.get_ref()); const unwrap<T2> tmp2(Y.get_ref()); const Mat<eT>& A = tmp1.M; const Mat<eT>& B = tmp2.M; arma_debug_check( (A.n_elem != B.n_elem), "norm_dot(): objects must have the same number of elements" ); const eT* A_mem = A.memptr(); const eT* B_mem = B.memptr(); const u32 N = A.n_elem; eT acc1 = eT(0); eT acc2 = eT(0); eT acc3 = eT(0); for(u32 i=0; i<N; ++i) { const eT tmpA = A_mem[i]; const eT tmpB = B_mem[i]; acc1 += tmpA * tmpA; acc2 += tmpB * tmpB; acc3 += tmpA * tmpB; } return acc3 / ( std::sqrt(acc1 * acc2) ); }
arma_hot T1::elem_type op_norm_dot::apply_proxy | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const Base< typename T1::elem_type, T2 > & | Y | |||
) | [inline, static, inherited] |
Definition at line 292 of file op_dot_meat.hpp.
References Base< elem_type, derived >::get_ref(), and sqrt().
Referenced by op_norm_dot::apply().
{ arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const Proxy<T1> A(X.get_ref()); const Proxy<T2> B(Y.get_ref()); arma_debug_check( (A.n_elem != B.n_elem), "norm_dot(): objects must have the same number of elements" ); const u32 N = A.n_elem; eT acc1 = eT(0); eT acc2 = eT(0); eT acc3 = eT(0); for(u32 i=0; i<N; ++i) { const eT tmpA = A[i]; const eT tmpB = B[i]; acc1 += tmpA * tmpA; acc2 += tmpB * tmpB; acc3 += tmpA * tmpB; } return acc3 / ( std::sqrt(acc1 * acc2) ); }