Op_neg


Classes

class  op_neg
 'negate matrix' operation More...

Functions

template<typename T1 >
static void op_neg::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_neg > &in)
 Negate all element of a matrix and store the result in a dense matrix.

Function Documentation

template<typename T1 >
void op_neg::apply ( Mat< typename T1::elem_type > &  out,
const Op< T1, op_neg > &  in 
) [inline, static, inherited]

Negate all element of a matrix and store the result in a dense matrix.

Definition at line 24 of file op_neg_meat.hpp.

References Op< T1, op_type >::m, Mat< eT >::mem, Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, and Mat< eT >::set_size().

00025   {
00026   arma_extra_debug_sigprint();
00027   
00028   typedef typename T1::elem_type eT;
00029   
00030   const unwrap<T1> tmp(in.m);
00031   const Mat<eT>& X = tmp.M;
00032   
00033   // no alias problems
00034   out.set_size(X.n_rows, X.n_cols);
00035   
00036   const eT* X_mem = X.mem;
00037   eT* out_mem = out.memptr();
00038   
00039   
00040   for(u32 i=0; i<X.n_elem; ++i)
00041     {
00042     out_mem[i] = -X_mem[i];
00043     }
00044     
00045   }