8 #include "UniformRandomV.hpp" 9 #include "columns/HyPerCol.hpp" 10 #include "columns/Random.hpp" 11 #include "utils/PVLog.hpp" 15 UniformRandomV::UniformRandomV() { initialize_base(); }
17 UniformRandomV::UniformRandomV(
char const *name, HyPerCol *hc) {
22 UniformRandomV::~UniformRandomV() {}
24 int UniformRandomV::initialize_base() {
return PV_SUCCESS; }
26 int UniformRandomV::initialize(
char const *name, HyPerCol *hc) {
27 int status = BaseInitV::initialize(name, hc);
39 parent->parameters()->ioParamValue(ioFlag, name,
"minV", &minV, minV);
43 pvAssert(!parent->parameters()->presentAndNotBeenRead(name,
"minV"));
44 parent->parameters()->ioParamValue(ioFlag, name,
"maxV", &maxV, minV + 1.0f);
47 void UniformRandomV::calcV(
float *V,
PVLayerLoc const *loc) {
51 Random randState{&flatLoc,
false };
52 const int nxny = flatLoc.nx * flatLoc.ny;
53 for (
int b = 0; b < loc->nbatch; b++) {
54 float *VBatch = V + b * loc->nx * loc->ny * loc->nf;
55 #ifdef PV_USE_OPENMP_THREADS 56 #pragma omp parallel for 58 for (
int xy = 0; xy < nxny; xy++) {
59 for (
int f = 0; f < loc->nf; f++) {
60 int index = kIndex(xy, 0, f, nxny, 1, loc->nf);
61 VBatch[index] = randState.uniformRandom(xy, minV, maxV);
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override