Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Klepl Jiří
asgn
Commits
a225d4bd
Commit
a225d4bd
authored
Mar 19, 2020
by
Bednárek David RNDr. Ph.D.
Browse files
well_defined_uniform distribution used in macro
parent
80522e54
Changes
2
Hide whitespace changes
Inline
Side-by-side
asgn/fmwkng.hpp
View file @
a225d4bd
...
...
@@ -4179,6 +4179,24 @@ namespace fmwkng {
};
#pragma endregion
#pragma region random
class
well_defined_uniform
{
public:
well_defined_uniform
(
std
::
size_t
mn
,
std
::
size_t
mx
)
:
mn_
(
mn
),
mod_
(
mx
-
mn
+
1
)
{}
template
<
typename
E
>
std
::
size_t
operator
()(
E
&&
e
)
{
auto
r
=
e
();
return
mn_
+
(
r
%
mod_
);
}
private:
std
::
size_t
mn_
;
std
::
size_t
mod_
;
};
#pragma endregion
}
#endif
asgn/macroasgn.cpp
View file @
a225d4bd
...
...
@@ -15,7 +15,7 @@ namespace macroasgn {
auto
M
=
26
*
exp_length
;
auto
N
=
M
+
26
;
std
::
uniform_int_distribution
<
std
::
size_t
>
char_distro
(
0
,
N
-
1
);
fmwkng
::
well_defined_uniform
char_distro
(
0
,
N
-
1
);
auto
generate_name
=
[
&
char_distro
,
&
engine
,
M
,
exp_length
,
level_count
,
nonlevel_weight
]()
{
...
...
@@ -53,11 +53,11 @@ namespace macroasgn {
}
}
std
::
uniform_int_distribution
<
std
::
size_t
>
space_distro
(
0
,
exp_spaces
);
std
::
uniform_int_distribution
<
std
::
size_t
>
width_distro
(
0
,
exp_width
);
std
::
uniform_int_distribution
<
std
::
size_t
>
level_distro
(
0
,
(
level_count
+
nonlevel_weight
)
*
(
exp_width
+
1
)
-
1
);
std
::
uniform_int_distribution
<
std
::
size_t
>
macro_distro
(
0
,
level_count
+
nonmacro_weight
-
1
);
std
::
uniform_int_distribution
<
std
::
size_t
>
name_distro
(
0
,
name_count
-
1
);
fmwkng
::
well_defined_uniform
space_distro
(
0
,
exp_spaces
);
fmwkng
::
well_defined_uniform
width_distro
(
0
,
exp_width
);
fmwkng
::
well_defined_uniform
level_distro
(
0
,
(
level_count
+
nonlevel_weight
)
*
(
exp_width
+
1
)
-
1
);
fmwkng
::
well_defined_uniform
macro_distro
(
0
,
level_count
+
nonmacro_weight
-
1
);
fmwkng
::
well_defined_uniform
name_distro
(
0
,
name_count
-
1
);
auto
space_gen
=
[
&
space_distro
,
&
engine
](
std
::
string
&
s
)
{
for
(;;)
...
...
Write
Preview
Supports
Markdown
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