Skip to content

Commit

Permalink
Moved all external "C" functions to Utilities.Auxiliary
Browse files Browse the repository at this point in the history
Replaceable Seeds should now be standard conform for extending
  • Loading branch information
akloeckner committed Jun 25, 2014
1 parent db11763 commit cd0e498
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Noise/PRNG.mo
Expand Up @@ -144,7 +144,7 @@ public
parameter Boolean useGlobalSeed = true
"Combine local seed value with global seed" annotation(choices(checkBox=true),Dialog(group = "Initialization"));
final parameter Integer seed=if useGlobalSeed then
Noise.Utilities.Seedings.combineSeedLCG(localSeed, globalSeed.seed)
Noise.Utilities.Auxiliary.combineSeedLCG(localSeed, globalSeed.seed)
else localSeed;
initial equation
if useSampleBasedMethods then
Expand Down
6 changes: 5 additions & 1 deletion Noise/Seed/Seed_Real.mo
@@ -1,7 +1,11 @@
within Noise.Seed;
function Seed_Real "Uses the real value for seeding"
extends Utilities.Interfaces.Seed;
external "C" NOISE_SeedReal(local_seed, global_seed, real_seed, n, states);
algorithm
states := Noise.Utilities.Auxiliary.SeedReal(local_seed= local_seed,
global_seed= global_seed,
real_seed= real_seed,
n= n);

annotation (Include = "#include \"ModelicaNoise.c\"", Documentation(revisions="<html>
<p><img src=\"modelica://Noise/Resources/Images/dlr_logo.png\"/> <b>Developed 2014 at the DLR Institute of System Dynamics and Control</b> </p>
Expand Down
17 changes: 17 additions & 0 deletions Noise/Utilities/Auxiliary/SeedReal.mo
@@ -0,0 +1,17 @@
within Noise.Utilities.Auxiliary;
function SeedReal "Uses a real value for initializing an RNG's state vector"

input Integer local_seed "The local seed";
input Integer global_seed "The global seed";
input Real real_seed "The real seed";
input Integer n "The number of initial state values to be generated";
output Integer states[n] "The generated initial states";

external "C" NOISE_SeedReal(local_seed, global_seed, real_seed, n, states);

annotation (Include = "#include \"ModelicaNoise.c\"", Documentation(revisions="<html>
<p><img src=\"modelica://Noise/Resources/Images/dlr_logo.png\"/> <b>Developed 2014 at the DLR Institute of System Dynamics and Control</b> </p>
</html>", info="<html>
<p>This function converts the Real value to Integer values and fills the state vector with them.</p>
</html>"));
end SeedReal;
@@ -1,4 +1,4 @@
within Noise.Utilities.Seedings;
within Noise.Utilities.Auxiliary;
function combineSeedLCG "combines two seed values in an LCG fashion"
extends Interfaces.combineSeed;

Expand Down
2 changes: 2 additions & 0 deletions Noise/Utilities/Auxiliary/package.order
@@ -1 +1,3 @@
shuffleDouble
SeedReal
combineSeedLCG
9 changes: 0 additions & 9 deletions Noise/Utilities/Seedings/package.mo

This file was deleted.

1 change: 0 additions & 1 deletion Noise/Utilities/Seedings/package.order

This file was deleted.

1 change: 0 additions & 1 deletion Noise/Utilities/package.order
Expand Up @@ -4,4 +4,3 @@ Analysis
Auxiliary
Math
Interaction
Seedings

0 comments on commit cd0e498

Please sign in to comment.