Functions

Operator_cube_plus

//! More...

Functions

template<typename T1 >
arma_inline const BaseCube
< typename T1::elem_type, T1 > & 
operator+ (const BaseCube< typename T1::elem_type, T1 > &X)
 unary plus operation (does nothing, but is required for completeness)
template<typename T1 >
arma_inline const eOpCube< T1,
eop_cube_scalar_plus
operator+ (const BaseCube< typename T1::elem_type, T1 > &X, const typename T1::elem_type k)
 BaseCube + scalar.
template<typename T1 >
arma_inline const eOpCube< T1,
eop_cube_scalar_plus
operator+ (const typename T1::elem_type k, const BaseCube< typename T1::elem_type, T1 > &X)
 scalar + BaseCube
template<typename T1 , typename T2 >
arma_inline const eGlueCube
< T1, T2, eglue_cube_plus
operator+ (const BaseCube< typename T1::elem_type, T1 > &X, const BaseCube< typename T1::elem_type, T2 > &Y)
 addition of BaseCube objects with same element type
template<typename T1 , typename T2 >
arma_inline Cube< typename
promote_type< typename
T1::elem_type, typename
T2::elem_type >::result > 
operator+ (const BaseCube< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T1_result, T1 > &X, const BaseCube< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T2_result, T2 > &Y)
 addition of BaseCube objects with different element types

Detailed Description

//!


Function Documentation

template<typename T1 >
arma_inline const BaseCube<typename T1::elem_type,T1>& operator+ ( const BaseCube< typename T1::elem_type, T1 > &  X  ) 

unary plus operation (does nothing, but is required for completeness)

Definition at line 27 of file operator_cube_plus.hpp.

  {
  arma_extra_debug_sigprint();
  
  return X;
  }

template<typename T1 >
arma_inline const eOpCube<T1, eop_cube_scalar_plus> operator+ ( const BaseCube< typename T1::elem_type, T1 > &  X,
const typename T1::elem_type  k 
)

BaseCube + scalar.

Definition at line 43 of file operator_cube_plus.hpp.

References BaseCube< elem_type, derived >::get_ref().

  {
  arma_extra_debug_sigprint();
  
  return eOpCube<T1, eop_cube_scalar_plus>(X.get_ref(), k);
  }

template<typename T1 >
arma_inline const eOpCube<T1, eop_cube_scalar_plus> operator+ ( const typename T1::elem_type  k,
const BaseCube< typename T1::elem_type, T1 > &  X 
)

scalar + BaseCube

Definition at line 60 of file operator_cube_plus.hpp.

References BaseCube< elem_type, derived >::get_ref().

  {
  arma_extra_debug_sigprint();
  
  return eOpCube<T1, eop_cube_scalar_plus>(X.get_ref(), k);
  }

template<typename T1 , typename T2 >
arma_inline const eGlueCube<T1, T2, eglue_cube_plus> operator+ ( const BaseCube< typename T1::elem_type, T1 > &  X,
const BaseCube< typename T1::elem_type, T2 > &  Y 
)

addition of BaseCube objects with same element type

Definition at line 77 of file operator_cube_plus.hpp.

References BaseCube< elem_type, derived >::get_ref().

  {
  arma_extra_debug_sigprint();
  
  return eGlueCube<T1, T2, eglue_cube_plus>(X.get_ref(), Y.get_ref());
  }

template<typename T1 , typename T2 >
arma_inline Cube<typename promote_type<typename T1::elem_type, typename T2::elem_type>::result> operator+ ( const BaseCube< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T1_result, T1 > &  X,
const BaseCube< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T2_result, T2 > &  Y 
)

addition of BaseCube objects with different element types

Definition at line 94 of file operator_cube_plus.hpp.

References upgrade_val< T1, T2 >::apply(), promote_type< T1, T2 >::check(), BaseCube< elem_type, derived >::get_ref(), Cube< eT >::memptr(), and Cube< eT >::n_elem.

  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT1;
  typedef typename T2::elem_type eT2;
  
  typedef typename promote_type<eT1,eT2>::result out_eT;
  
  promote_type<eT1,eT2>::check();
  
  const ProxyCube<T1> A(X.get_ref());
  const ProxyCube<T2> B(Y.get_ref());
  
  arma_debug_assert_same_size(A, B, "cube addition");
  
  Cube<out_eT> out(A.n_rows, A.n_cols, A.n_slices);

        out_eT* out_mem = out.memptr();
  const u32     n_elem  = out.n_elem;
  
  for(u32 i=0; i<n_elem; ++i)
    {
    out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) + upgrade_val<eT1,eT2>::apply(B[i]);
    }
  
  return out;
  }