mirror of https://github.com/davisking/dlib.git
Added gaussian_randm()
This commit is contained in:
parent
3dfe0feaee
commit
04089ee638
|
@ -16,7 +16,7 @@
|
|||
#include "matrix_expressions.h"
|
||||
#include "matrix_math_functions.h"
|
||||
#include "matrix_op.h"
|
||||
#include "../general_hash/murmur_hash3.h"
|
||||
#include "../general_hash/random_hashing.h"
|
||||
|
||||
|
||||
namespace dlib
|
||||
|
@ -2064,6 +2064,43 @@ namespace dlib
|
|||
return matrix_op<op>(op());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
struct op_gaussian_randm : does_not_alias
|
||||
{
|
||||
op_gaussian_randm (
|
||||
long nr_,
|
||||
long nc_,
|
||||
unsigned long seed_
|
||||
) :_nr(nr_), _nc(nc_), seed(seed_){}
|
||||
|
||||
const long _nr;
|
||||
const long _nc;
|
||||
const unsigned long seed;
|
||||
|
||||
const static long cost = 100;
|
||||
const static long NR = 0;
|
||||
const static long NC = 0;
|
||||
typedef default_memory_manager mem_manager_type;
|
||||
typedef row_major_layout layout_type;
|
||||
typedef double type;
|
||||
typedef double const_ret_type;
|
||||
const_ret_type apply ( long r, long c) const { return gaussian_random_hash(r,c,seed); }
|
||||
|
||||
long nr() const { return _nr; }
|
||||
long nc() const { return _nc; }
|
||||
};
|
||||
|
||||
inline const matrix_op<op_gaussian_randm> gaussian_randm (
|
||||
long nr,
|
||||
long nc,
|
||||
unsigned long seed = 0
|
||||
)
|
||||
{
|
||||
typedef op_gaussian_randm op;
|
||||
return matrix_op<op>(op(nr,nc,seed));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <typename M>
|
||||
|
|
|
@ -1618,6 +1618,33 @@ namespace dlib
|
|||
- M(i,j) == a random number such that 0 <= M(i,j) < 1
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
inline const matrix_exp gaussian_randm (
|
||||
long nr,
|
||||
long nc,
|
||||
unsigned long seed = 0
|
||||
);
|
||||
/*!
|
||||
requires
|
||||
- nr >= 0
|
||||
- nc >= 0
|
||||
ensures
|
||||
- returns a matrix with its values filled with 0 mean unit variance Gaussian
|
||||
random numbers.
|
||||
- Each setting of the seed results in a different random matrix.
|
||||
- The returned matrix is lazily evaluated using the expression templates
|
||||
technique. This means that the returned matrix doesn't take up any memory
|
||||
and is only an expression template. The values themselves are computed on
|
||||
demand using the gaussian_random_hash() routine.
|
||||
- returns a matrix M such that
|
||||
- M::type == double
|
||||
- M.nr() == nr
|
||||
- M.nc() == nc
|
||||
- for all valid i, j:
|
||||
- M(i,j) == gaussian_random_hash(i,j,seed)
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Pixel and Image Utilities
|
||||
|
|
Loading…
Reference in New Issue