PetaVision  Alpha
InitSmartWeights.cpp
1 /*
2  * InitSmartWeights.cpp
3  *
4  * Created on: Aug 8, 2011
5  * Author: kpeterson
6  */
7 
8 #include "InitSmartWeights.hpp"
9 
10 namespace PV {
11 
12 InitSmartWeights::InitSmartWeights(char const *name, HyPerCol *hc) : InitWeights() {
13  InitSmartWeights::initialize(name, hc);
14 }
15 
16 InitSmartWeights::InitSmartWeights() {}
17 
18 InitSmartWeights::~InitSmartWeights() {}
19 
20 int InitSmartWeights::initialize(char const *name, HyPerCol *hc) {
21  int status = InitWeights::initialize(name, hc);
22  return status;
23 }
24 
25 void InitSmartWeights::calcWeights(int patchIndex, int arborId) {
26  float *dataStart = mWeights->getDataFromDataIndex(arborId, patchIndex);
27  smartWeights(dataStart, patchIndex);
28 }
29 
30 void InitSmartWeights::smartWeights(float *dataStart, int k) {
31  int const nfp = mWeights->getPatchSizeF();
32  int const nyp = mWeights->getPatchSizeY();
33  int const nxp = mWeights->getPatchSizeX();
34 
35  int const sxp = mWeights->getGeometry()->getPatchStrideX();
36  int const syp = mWeights->getGeometry()->getPatchStrideY();
37  int const sfp = mWeights->getGeometry()->getPatchStrideF();
38 
39  // loop over all post-synaptic cells in patch
40  for (int y = 0; y < nyp; y++) {
41  for (int x = 0; x < nxp; x++) {
42  for (int f = 0; f < nfp; f++) {
43  dataStart[x * sxp + y * syp + f * sfp] = dataIndexToUnitCellIndex(k);
44  }
45  }
46  }
47 }
48 
49 } /* namespace PV */
int getPatchSizeX() const
Definition: Weights.hpp:219
float * getDataFromDataIndex(int arbor, int dataIndex)
Definition: Weights.cpp:200
int getPatchSizeY() const
Definition: Weights.hpp:222
std::shared_ptr< PatchGeometry > getGeometry() const
Definition: Weights.hpp:148
virtual void calcWeights()
int getPatchSizeF() const
Definition: Weights.hpp:225