Op_rand

Classes

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

Functions

template<typename eT >
static void op_rand::direct_rand (eT *x, const u32 n_elem)
 TODO: optionally use the Marsenne-Twister random number generator (see Boost).
template<typename T >
static void op_rand::direct_rand (std::complex< T > *x, const u32 n_elem)
template<typename T1 >
static void op_rand::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_rand > &in)
template<typename eT >
static void op_rand::apply (Cube< eT > &out, const OpCube< Cube< eT >, op_rand > &in)

Function Documentation

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

TODO: optionally use the Marsenne-Twister random number generator (see Boost).

Definition at line 24 of file op_rand_meat.hpp.

References rand().

Referenced by apply().

00025   {
00026   arma_extra_debug_sigprint();
00027   
00028   for(u32 i=0; i<n_elem; ++i)
00029     {
00030     x[i] = eT(std::rand()) / eT(RAND_MAX);
00031     }
00032   
00033   
00034   }

template<typename T >
void op_rand::direct_rand ( std::complex< T > *  x,
const u32  n_elem 
) [inline, static, private, inherited]

Definition at line 41 of file op_rand_meat.hpp.

References rand().

00042   {
00043   arma_extra_debug_sigprint();
00044   
00045   for(u32 i=0; i<n_elem; ++i)
00046     {
00047     const T a = T(std::rand()) / T(RAND_MAX);
00048     const T b = T(std::rand()) / T(RAND_MAX);
00049 
00050     x[i] = std::complex<T>(a,b);
00051     }
00052   
00053   
00054   }

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

Definition at line 61 of file op_rand_meat.hpp.

References Op< T1, op_type >::aux_u32_a, Op< T1, op_type >::aux_u32_b, direct_rand(), Mat< eT >::memptr(), Mat< eT >::n_elem, and Mat< eT >::set_size().

00062   {
00063   arma_extra_debug_sigprint();
00064   
00065   out.set_size(in.aux_u32_a, in.aux_u32_b);
00066   
00067   op_rand::direct_rand(out.memptr(), out.n_elem);
00068   }

template<typename eT >
void op_rand::apply ( Cube< eT > &  out,
const OpCube< Cube< eT >, op_rand > &  in 
) [inline, static, inherited]

Definition at line 75 of file op_rand_meat.hpp.

References direct_rand(), Cube< eT >::memptr(), Cube< eT >::n_elem, and Cube< eT >::set_size().

00076   {
00077   arma_extra_debug_sigprint();
00078   
00079   out.set_size(in.aux_u32_a, in.aux_u32_b, in.aux_u32_c);
00080   
00081   op_rand::direct_rand(out.memptr(), out.n_elem);
00082   }