Op_randn


Classes

class  op_randn
 'generate matrix with random values' operation More...

Functions

template<typename eT >
static eT op_randn::randn ()
template<typename eT >
static void op_randn::direct_randn (eT *x, const u32 n_elem)
template<typename eT >
static void op_randn::apply (Mat< eT > &out, const Op< Mat< eT >, op_randn > &in)
template<typename eT >
static void op_randn::apply (Mat< eT > &out, const Op< Col< eT >, op_randn > &in)
template<typename eT >
static void op_randn::apply (Mat< eT > &out, const Op< Row< eT >, op_randn > &in)
template<typename eT >
static void op_randn::apply (Col< eT > &out, const Op< Col< eT >, op_randn > &in)
template<typename eT >
static void op_randn::apply (Row< eT > &out, const Op< Row< eT >, op_randn > &in)

Function Documentation

template<typename eT >
eT op_randn::randn (  )  [inline, static, private, inherited]

Definition at line 34 of file op_randn_meat.hpp.

References rand().

00035   {
00036   const u32 N = 12;
00037   eT acc = eT(0);
00038   
00039   for(u32 i=0; i<N; ++i)
00040     {
00041     acc += eT(std::rand()) / eT(RAND_MAX);
00042     }
00043   
00044   return acc/eT(N) - eT(0.5);
00045   }

template<typename eT >
void op_randn::direct_randn ( eT *  x,
const u32  n_elem 
) [inline, static, private, inherited]

Definition at line 52 of file op_randn_meat.hpp.

Referenced by apply().

00053   {
00054   arma_extra_debug_sigprint();
00055   
00056   for(u32 i=0; i<n_elem; ++i)
00057     {
00058     x[i] = eT(op_randn::randn<eT>());
00059     }
00060   
00061   }

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

Definition at line 68 of file op_randn_meat.hpp.

References direct_randn(), Mat< eT >::memptr(), Mat< eT >::n_elem, and Mat< eT >::set_size().

00069   {
00070   arma_extra_debug_sigprint();
00071   
00072   const u32 n_rows = in.aux_u32_a;
00073   const u32 n_cols = (in.aux_u32_b > 0) ? in.aux_u32_b : 1;
00074   
00075   out.set_size(n_rows, n_cols);
00076   
00077   op_randn::direct_randn(out.memptr(), out.n_elem);
00078   }

template<typename eT >
void op_randn::apply ( Mat< eT > &  out,
const Op< Col< eT >, op_randn > &  in 
) [inline, static, inherited]

Definition at line 85 of file op_randn_meat.hpp.

References direct_randn(), Mat< eT >::memptr(), Mat< eT >::n_elem, and Mat< eT >::set_size().

00086   {
00087   arma_extra_debug_sigprint();
00088   
00089   out.set_size(in.aux_u32_a, 1);
00090   
00091   op_randn::direct_randn(out.memptr(), out.n_elem);
00092   }

template<typename eT >
void op_randn::apply ( Mat< eT > &  out,
const Op< Row< eT >, op_randn > &  in 
) [inline, static, inherited]

Definition at line 99 of file op_randn_meat.hpp.

References direct_randn(), Mat< eT >::memptr(), Mat< eT >::n_elem, and Mat< eT >::set_size().

00100   {
00101   arma_extra_debug_sigprint();
00102   
00103   out.set_size(1, in.aux_u32_a);
00104   
00105   op_randn::direct_randn(out.memptr(), out.n_elem);
00106   }

template<typename eT >
void op_randn::apply ( Col< eT > &  out,
const Op< Col< eT >, op_randn > &  in 
) [inline, static, inherited]

Definition at line 113 of file op_randn_meat.hpp.

References direct_randn(), Mat< eT >::memptr(), Mat< eT >::n_elem, and Col< eT >::set_size().

00114   {
00115   arma_extra_debug_sigprint();
00116   
00117   out.set_size(in.aux_u32_a);
00118   
00119   op_randn::direct_randn(out.memptr(), out.n_elem);
00120   }

template<typename eT >
void op_randn::apply ( Row< eT > &  out,
const Op< Row< eT >, op_randn > &  in 
) [inline, static, inherited]

Definition at line 127 of file op_randn_meat.hpp.

References direct_randn(), Mat< eT >::memptr(), Mat< eT >::n_elem, and Row< eT >::set_size().

00128   {
00129   arma_extra_debug_sigprint();
00130   
00131   out.set_size(in.aux_u32_a);
00132   
00133   op_randn::direct_randn(out.memptr(), out.n_elem);
00134   }