Blob Blame Raw
#ifndef SEGMENT_INC_CPP
#define SEGMENT_INC_CPP


#include "layer.inc.cpp"


class Segment: public WeightHolder {
public:
  const int sx, sy, sz;
  
  int effectiveLinks;
  Layout layout;
  NeuronReal *f_values;
  
  Segment(int sx, int sy, int sz, int weightsCount, Weight *weights = nullptr):
    WeightHolder(weightsCount, weights), sx(sx), sy(sy), sz(sz), effectiveLinks(weightsCount), f_values() { }
  
  virtual ~Segment() { }
  
  virtual void clear() { }
  virtual void split(int threadsCount) { }
  
  virtual Quality pass(Barrier &barrier, int x, int y, int z, NeuronReal trainRatio) { return barrier.tid ? Quality() : testPass(x, y, z, trainRatio); }
  virtual Quality testPass(int x, int y, int z, NeuronReal trainRatio) { return Quality::bad(); }
  
  
  inline void check(int x, int y, int z) {
    #ifndef NDEBUG
    Layout l = layout;
    assert(l);
    assert(f_values);
    assert(weights);
    assert(l.x0 <= x && x+sx <= l.x1);
    assert(l.y0 <= y && y+sy <= l.y1);
    assert(l.z0 <= z && z+sz <= l.z1);
    #endif
  }
};


#endif