8 #include "InitSpreadOverArborsWeights.hpp" 12 InitSpreadOverArborsWeights::InitSpreadOverArborsWeights(
char const *name, HyPerCol *hc) {
16 InitSpreadOverArborsWeights::InitSpreadOverArborsWeights() {}
18 InitSpreadOverArborsWeights::~InitSpreadOverArborsWeights() {}
20 int InitSpreadOverArborsWeights::initialize(
char const *name, HyPerCol *hc) {
21 int status = InitGauss2DWeights::initialize(name, hc);
27 ioParam_weightInit(ioFlag);
31 void InitSpreadOverArborsWeights::ioParam_weightInit(
enum ParamsIOFlag ioFlag) {
32 parent->parameters()->ioParamValue(ioFlag, name,
"weightInit", &mWeightInit, mWeightInit);
36 calcOtherParams(patchIndex);
38 spreadOverArborsWeights(dataStart, arborId);
41 int InitSpreadOverArborsWeights::spreadOverArborsWeights(
float *dataStart,
int arborId) {
46 int sx = mWeights->
getGeometry()->getPatchStrideX();
47 int sy = mWeights->
getGeometry()->getPatchStrideY();
48 int sf = mWeights->
getGeometry()->getPatchStrideF();
53 for (
int fPost = 0; fPost < nfPatch; fPost++) {
54 float thPost = calcThPost(fPost);
55 if (checkThetaDiff(thPost))
57 for (
int jPost = 0; jPost < nyPatch; jPost++) {
58 float yDelta = calcYDelta(jPost);
59 for (
int iPost = 0; iPost < nxPatch; iPost++) {
60 float xDelta = calcXDelta(iPost);
63 float xp = +xDelta * cosf(thPost) + yDelta * sinf(thPost);
64 float yp = -xDelta * sinf(thPost) + yDelta * cosf(thPost);
67 if (xp * xp + yp * yp < 1e-4f) {
68 weight = mWeightInit / nArbors;
71 float theta2pi = atan2f(yp, xp) / (2 * PI);
72 unsigned int xpraw, ypraw, atanraw;
91 float zone = theta2pi * nArbors;
94 float fracpart = modff(zone, &intpart);
95 assert(intpart >= 0 && intpart < nArbors && fracpart >= 0 && fracpart < 1);
96 if (intpart == arborId) {
97 weight = mWeightInit * (1 - fracpart);
99 else if ((
int)(intpart - arborId + 1) % nArbors == 0) {
100 weight = mWeightInit * fracpart;
104 int index = iPost * sx + jPost * sy + fPost * sf;
105 dataStart[index] = weight;
int getPatchSizeX() const
virtual void calcWeights() override
float * getDataFromDataIndex(int arbor, int dataIndex)
int getPatchSizeY() const
std::shared_ptr< PatchGeometry > getGeometry() const
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
int getPatchSizeF() const