Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
04089ee6
Commit
04089ee6
authored
Nov 24, 2012
by
Davis King
Browse files
Added gaussian_randm()
parent
3dfe0fea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
1 deletion
+65
-1
dlib/matrix/matrix_utilities.h
dlib/matrix/matrix_utilities.h
+38
-1
dlib/matrix/matrix_utilities_abstract.h
dlib/matrix/matrix_utilities_abstract.h
+27
-0
No files found.
dlib/matrix/matrix_utilities.h
View file @
04089ee6
...
...
@@ -16,7 +16,7 @@
#include "matrix_expressions.h"
#include "matrix_math_functions.h"
#include "matrix_op.h"
#include "../general_hash/
murmur
_hash
3
.h"
#include "../general_hash/
random
_hash
ing
.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
>
...
...
dlib/matrix/matrix_utilities_abstract.h
View file @
04089ee6
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment