NAP
randomfillpolicy.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // External includes
8 #include <nap/resource.h>
9 
10 // Local Includes
11 #include "fillpolicy.h"
12 
13 namespace nap
14 {
26  template<typename T>
27  class RandomFillPolicy : public FillPolicy<T>
28  {
29  RTTI_ENABLE(FillPolicy<T>)
30  public:
36  virtual void fill(uint numElements, T* data) const override;
37 
38  T mLowerBound = T();
39  T mUpperBound = T();
40  };
41 
42 
44  // TypedRandomFillPolicyNumeric type definitions
46 
54 
55 
57  // Template definitions
59 
60  template<typename T>
61  void RandomFillPolicy<T>::fill(uint numElements, T* data) const
62  {
63  for (uint i = 0; i < numElements; i++)
64  {
65  *data = math::random(mLowerBound, mUpperBound);
66  ++data;
67  }
68  }
69 }
nap::uint
unsigned int uint
Definition: numeric.h:23
nap::RandomFillPolicy::fill
virtual void fill(uint numElements, T *data) const override
Definition: randomfillpolicy.h:61
nap::RandomFillPolicy::mLowerBound
T mLowerBound
Property 'LowerBound' The lower bound of the uniform random sample.
Definition: randomfillpolicy.h:38
nap
Definition: templateapp.h:17
nap::RandomFillPolicy::mUpperBound
T mUpperBound
Property 'UpperBound' The upper bound of the uniform random sample.
Definition: randomfillpolicy.h:39
nap::RandomFillPolicy
Definition: randomfillpolicy.h:27
nap::math::random
T random(T min, T max)
nap::FillPolicy
Definition: fillpolicy.h:47