Skip to content

Commit

Permalink
Mark mir.random.variable & mir.random.ndvariable opCall as const when…
Browse files Browse the repository at this point in the history
… possible (#105)

* Mark mir.random.variable opCall `const` when appropriate

All except: Bernoulli2Variable, LogNormalVariable, NormalVariable, &
StudentTVariable. Also affected the `min` and `max` properties of some
variables.

* Mark DirichletVariable & SimplexVariable opCall as `const`

This commit does not do this for MultivariateNormalVariable or for
SphereVariable opCall because future optimizations might make them
non-const.
  • Loading branch information
n8sh authored and 9il committed Oct 31, 2018
1 parent 85b8ccb commit d6fdafb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
8 changes: 4 additions & 4 deletions source/mir/random/ndvariable.d
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct SimplexVariable(T)

///
pragma(inline, false)
void opCall(G)(scope ref G gen, scope T[] result)
void opCall(G)(scope ref G gen, scope T[] result) const
if (isSaturatedRandomEngine!G)
{
import mir.ndslice.sorting : sort;
Expand All @@ -153,7 +153,7 @@ struct SimplexVariable(T)
result[1 .. $].retro[] = result.diff.retro;
}
/// ditto
void opCall(G)(scope G* gen, scope T[] result)
void opCall(G)(scope G* gen, scope T[] result) const
if (isSaturatedRandomEngine!G)
{
pragma(inline, true);
Expand Down Expand Up @@ -230,7 +230,7 @@ struct DirichletVariable(T)

///
pragma(inline, false)
void opCall(G)(scope ref G gen, scope T[] result)
void opCall(G)(scope ref G gen, scope T[] result) const
if (isSaturatedRandomEngine!G)
{
assert(result.length == alpha.length);
Expand All @@ -240,7 +240,7 @@ struct DirichletVariable(T)
result[] /= summator;
}
/// ditto
void opCall(G)(scope G* gen, scope T[] result)
void opCall(G)(scope G* gen, scope T[] result) const
if (isSaturatedRandomEngine!G)
{
pragma(inline, true);
Expand Down
Loading

0 comments on commit d6fdafb

Please sign in to comment.