Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
04089ee6
Commit
04089ee6
authored
Nov 24, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added gaussian_randm()
parent
3dfe0fea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
1 deletion
+65
-1
matrix_utilities.h
dlib/matrix/matrix_utilities.h
+38
-1
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 @@
...
@@ -16,7 +16,7 @@
#include "matrix_expressions.h"
#include "matrix_expressions.h"
#include "matrix_math_functions.h"
#include "matrix_math_functions.h"
#include "matrix_op.h"
#include "matrix_op.h"
#include "../general_hash/
murmur_hash3
.h"
#include "../general_hash/
random_hashing
.h"
namespace
dlib
namespace
dlib
...
@@ -2064,6 +2064,43 @@ namespace dlib
...
@@ -2064,6 +2064,43 @@ namespace dlib
return
matrix_op
<
op
>
(
op
());
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
>
template
<
typename
M
>
...
...
dlib/matrix/matrix_utilities_abstract.h
View file @
04089ee6
...
@@ -1618,6 +1618,33 @@ namespace dlib
...
@@ -1618,6 +1618,33 @@ namespace dlib
- M(i,j) == a random number such that 0 <= M(i,j) < 1
- 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
// 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