PetaVision  Alpha
GapLayer.cpp
1 /*
2  * GapLayer.cpp
3  *
4  * Created on: May 11, 2011
5  * Author: garkenyon
6  */
7 
8 #include "GapLayer.hpp"
9 #include "HyPerLayer.hpp"
10 
11 // GapLayer can be used to implement gap junctions
12 namespace PV {
13 GapLayer::GapLayer() { initialize_base(); }
14 
15 GapLayer::GapLayer(const char *name, HyPerCol *hc) {
16  initialize_base();
17  initialize(name, hc);
18 }
19 
20 GapLayer::~GapLayer() {}
21 
22 int GapLayer::initialize_base() {
23  ampSpikelet = 50;
24  return PV_SUCCESS;
25 }
26 
27 int GapLayer::initialize(const char *name, HyPerCol *hc) {
28  int status_init = CloneVLayer::initialize(name, hc);
29  assert(originalLayerName != NULL);
30 
31  return status_init;
32 }
33 
34 int GapLayer::ioParamsFillGroup(enum ParamsIOFlag ioFlag) {
35  int status = CloneVLayer::ioParamsFillGroup(ioFlag);
36  ioParam_ampSpikelet(ioFlag);
37  return status;
38 }
39 
40 void GapLayer::ioParam_ampSpikelet(enum ParamsIOFlag ioFlag) {
41  parent->parameters()->ioParamValue(ioFlag, name, "ampSpikelet", &ampSpikelet, ampSpikelet);
42 }
43 
44 Response::Status
45 GapLayer::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
46  return CloneVLayer::communicateInitInfo(message);
47  // Handled by CloneVLayer
48 }
49 
50 Response::Status GapLayer::allocateDataStructures() {
51  return CloneVLayer::allocateDataStructures();
52 }
53 
54 Response::Status GapLayer::updateState(double timef, double dt) {
55  int status;
56  updateState(
57  timef,
58  dt,
59  getLayerLoc(),
60  getCLayer()->activity->data,
61  getV(),
62  originalLayer->getCLayer()->activity->data);
63  return Response::SUCCESS;
64 }
65 
66 void GapLayer::updateState(
67  double timef,
68  double dt,
69  const PVLayerLoc *loc,
70  float *A,
71  float *V,
72  float *checkActive) {
73  int nx = loc->nx;
74  int ny = loc->ny;
75  int nf = loc->nf;
76  int num_neurons = nx * ny * nf;
77  int nbatch = loc->nbatch;
78  // No need to update V since GapLayer is a CloneVLayer.
79  setActivity_GapLayer(
80  nbatch,
81  num_neurons,
82  A,
83  V,
84  nx,
85  ny,
86  nf,
87  loc->halo.lt,
88  loc->halo.rt,
89  loc->halo.dn,
90  loc->halo.up,
91  originalLayer->getLayerLoc()->halo.lt,
92  originalLayer->getLayerLoc()->halo.rt,
93  originalLayer->getLayerLoc()->halo.dn,
94  originalLayer->getLayerLoc()->halo.up,
95  checkActive,
96  ampSpikelet);
97 }
98 
99 int GapLayer::setActivity() {
100  const PVLayerLoc *loc = getLayerLoc();
101  return setActivity_GapLayer(
102  loc->nbatch,
103  getNumNeurons(),
104  getCLayer()->activity->data,
105  getV(),
106  loc->nx,
107  loc->ny,
108  loc->nf,
109  loc->halo.lt,
110  loc->halo.rt,
111  loc->halo.dn,
112  loc->halo.up,
113  originalLayer->getLayerLoc()->halo.lt,
114  originalLayer->getLayerLoc()->halo.rt,
115  originalLayer->getLayerLoc()->halo.dn,
116  originalLayer->getLayerLoc()->halo.up,
117  getCLayer()->activity->data,
118  ampSpikelet);
119 }
120 
121 } // end namespace PV
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
Definition: CloneVLayer.cpp:34
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
Definition: GapLayer.cpp:34