op_rand_meat.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 template<typename eT>
00022 inline
00023 void
00024 op_rand::direct_rand(eT* x, const u32 n_elem)
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 }
00035
00036
00037
00038 template<typename T>
00039 inline
00040 void
00041 op_rand::direct_rand(std::complex<T>* x, const u32 n_elem)
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 }
00055
00056
00057
00058 template<typename T1>
00059 inline
00060 void
00061 op_rand::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_rand>& in)
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 }
00069
00070
00071
00072 template<typename eT>
00073 inline
00074 void
00075 op_rand::apply(Cube<eT>& out, const OpCube<Cube<eT>,op_rand>& in)
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 }
00083
00084
00085
00086