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
7f5a22c4
Commit
7f5a22c4
authored
Nov 04, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gave rand a constructor that takes a seed value.
parent
1b1cf754
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
11 deletions
+38
-11
rand_kernel_1.h
dlib/rand/rand_kernel_1.h
+25
-11
rand_kernel_abstract.h
dlib/rand/rand_kernel_abstract.h
+13
-0
No files found.
dlib/rand/rand_kernel_1.h
View file @
7f5a22c4
...
@@ -36,18 +36,15 @@ namespace dlib
...
@@ -36,18 +36,15 @@ namespace dlib
rand
(
rand
(
)
)
{
{
// prime the generator a bit
init
();
for
(
int
i
=
0
;
i
<
10000
;
++
i
)
}
mt
();
max_val
=
0xFFFFFF
;
max_val
*=
0x1000000
;
max_val
+=
0xFFFFFF
;
max_val
+=
0
.
01
;
has_gaussian
=
false
;
rand
(
next_gaussian
=
0
;
const
std
::
string
&
seed_value
)
{
init
();
set_seed
(
seed_value
);
}
}
virtual
~
rand
(
virtual
~
rand
(
...
@@ -234,6 +231,23 @@ namespace dlib
...
@@ -234,6 +231,23 @@ namespace dlib
);
);
private
:
private
:
void
init
()
{
// prime the generator a bit
for
(
int
i
=
0
;
i
<
10000
;
++
i
)
mt
();
max_val
=
0xFFFFFF
;
max_val
*=
0x1000000
;
max_val
+=
0xFFFFFF
;
max_val
+=
0
.
01
;
has_gaussian
=
false
;
next_gaussian
=
0
;
}
mt19937
mt
;
mt19937
mt
;
std
::
string
seed
;
std
::
string
seed
;
...
...
dlib/rand/rand_kernel_abstract.h
View file @
7f5a22c4
...
@@ -34,6 +34,19 @@ namespace dlib
...
@@ -34,6 +34,19 @@ namespace dlib
- std::bad_alloc
- std::bad_alloc
!*/
!*/
rand
(
const
std
::
string
&
seed_value
);
/*!
ensures
- #*this is properly initialized
- #get_seed() == seed_value
- This version of the constructor is equivalent to using
the default constructor and then calling set_seed(seed_value)
throws
- std::bad_alloc
!*/
virtual
~
rand
(
virtual
~
rand
(
);
);
/*!
/*!
...
...
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