Operator_minus

Functions

template<typename T1 >
arma_inline const eOp< T1,
eop_neg
operator- (const Base< typename T1::elem_type, T1 > &X)
 unary -
template<typename T1 >
arma_inline const T1 & operator- (const eOp< T1, eop_neg > &X)
 cancellation of two consecutive negations: -(-T1)
template<typename T1 >
arma_inline const eOp< T1,
eop_scalar_minus_post
operator- (const Base< typename T1::elem_type, T1 > &X, const typename T1::elem_type k)
 Base - scalar.
template<typename T1 >
arma_inline const eOp< T1,
eop_scalar_minus_pre
operator- (const typename T1::elem_type k, const Base< typename T1::elem_type, T1 > &X)
 scalar - Base
template<typename T1 , typename T2 >
arma_inline const eGlue< T1,
T2, eglue_minus
operator- (const Base< typename T1::elem_type, T1 > &X, const Base< typename T1::elem_type, T2 > &Y)
 subtraction of Base objects with same element type
template<typename T1 , typename T2 >
arma_inline Mat< typename
promote_type< typename
T1::elem_type, typename
T2::elem_type >::result > 
operator- (const Base< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T1_result, T1 > &X, const Base< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T2_result, T2 > &Y)
 subtraction of Base objects with different element types

Function Documentation

template<typename T1 >
arma_inline const eOp<T1, eop_neg> operator- ( const Base< typename T1::elem_type, T1 > &  X  )  [inline]

unary -

Definition at line 27 of file operator_minus.hpp.

00028   {
00029   arma_extra_debug_sigprint();
00030   
00031   return eOp<T1,eop_neg>(X.get_ref());
00032   }

template<typename T1 >
arma_inline const T1& operator- ( const eOp< T1, eop_neg > &  X  )  [inline]

cancellation of two consecutive negations: -(-T1)

Definition at line 41 of file operator_minus.hpp.

00042   {
00043   arma_extra_debug_sigprint();
00044   
00045   return X.m;
00046   }

template<typename T1 >
arma_inline const eOp<T1, eop_scalar_minus_post> operator- ( const Base< typename T1::elem_type, T1 > &  X,
const typename T1::elem_type  k 
) [inline]

Base - scalar.

Definition at line 55 of file operator_minus.hpp.

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

00059   {
00060   arma_extra_debug_sigprint();
00061   
00062   return eOp<T1, eop_scalar_minus_post>(X.get_ref(), k);
00063   }

template<typename T1 >
arma_inline const eOp<T1, eop_scalar_minus_pre> operator- ( const typename T1::elem_type  k,
const Base< typename T1::elem_type, T1 > &  X 
) [inline]

scalar - Base

Definition at line 72 of file operator_minus.hpp.

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

00076   {
00077   arma_extra_debug_sigprint();
00078   
00079   return eOp<T1, eop_scalar_minus_pre>(X.get_ref(), k);
00080   }

template<typename T1 , typename T2 >
arma_inline const eGlue<T1, T2, eglue_minus> operator- ( const Base< typename T1::elem_type, T1 > &  X,
const Base< typename T1::elem_type, T2 > &  Y 
) [inline]

subtraction of Base objects with same element type

Definition at line 89 of file operator_minus.hpp.

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

00093   {
00094   arma_extra_debug_sigprint();
00095   
00096   return eGlue<T1, T2, eglue_minus>(X.get_ref(), Y.get_ref());
00097   }

template<typename T1 , typename T2 >
arma_inline Mat<typename promote_type<typename T1::elem_type, typename T2::elem_type>::result> operator- ( const Base< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T1_result, T1 > &  X,
const Base< typename force_different_type< typename T1::elem_type, typename T2::elem_type >::T2_result, T2 > &  Y 
) [inline]

subtraction of Base objects with different element types

Definition at line 106 of file operator_minus.hpp.

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

00110   {
00111   arma_extra_debug_sigprint();
00112   
00113   typedef typename T1::elem_type eT1;
00114   typedef typename T2::elem_type eT2;
00115   
00116   typedef typename promote_type<eT1,eT2>::result out_eT;
00117   
00118   promote_type<eT1,eT2>::check();
00119   
00120   const Proxy<T1> A(X.get_ref());
00121   const Proxy<T2> B(Y.get_ref());
00122   
00123   arma_debug_assert_same_size(A, B, "matrix subtraction");
00124   
00125   Mat<out_eT> out(A.n_rows, A.n_cols);
00126 
00127         out_eT* out_mem = out.memptr();
00128   const u32     n_elem  = out.n_elem;
00129   
00130   for(u32 i=0; i<n_elem; ++i)
00131     {
00132     out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) - upgrade_val<eT1,eT2>::apply(B[i]);
00133     }
00134   
00135   return out;
00136   }