165 if (D>=2) updateValue<long_t>(
d,
names::rows, new_dims[1]);
168 index new_size = this->depth_;
169 for(
int i=0;i<D;++i) {
170 new_size *= new_dims[i];
173 if (new_size != this->global_size()) {
174 throw BadProperty(
"Total size of layer must be unchanged.");
177 this->dims_ = new_dims;
190 if (D>=2) (*topology_dict)[
names::rows] = dims_[1];
197 lid %= this->global_size()/this->depth_;
199 for(
int i=D-1;i>0;--i) {
200 gridpos[i] = lid % dims_[i];
201 lid = lid / dims_[i];
205 return gridpos_to_position(gridpos);
215 upper_left[1] += ext[1];
218 return upper_left + ext/dims_ * gridpos + ext/dims_ * 0.5;
224 return lid_to_position(this->nodes_[sind]->get_lid());
233 for(
int i=0;i<D;++i) {
234 if (this->periodic_[i]) {
235 pos[i] %= int(dims_[i]);
236 if (pos[i]<0) pos[i] += dims_[i];
240 for(
int i=0;i<D;++i) {
251 std::vector<index> gids;
253 index layer_size = this->global_size()/this->depth_;
255 for(
int d=0;
d<this->depth_;++
d) {
256 gids.push_back(this->gids_[lid +
d*layer_size]);
265 std::vector<Node*>::const_iterator nodes_begin;
266 std::vector<Node*>::const_iterator nodes_end;
269 nodes_begin = this->local_begin(filter.
depth);
270 nodes_end = this->local_end(filter.
depth);
272 nodes_begin = this->local_begin();
273 nodes_end = this->local_end();
276 for(std::vector<Node*>::const_iterator node_it = nodes_begin; node_it != nodes_end; ++node_it) {
290 index lid_end = this->gids_.size();
293 const index nodes_per_layer = this->gids_.size() / this->depth_;
294 i = nodes_per_layer * filter.
depth;
295 lid_end = nodes_per_layer * (filter.
depth+1);
296 if ((i >= this->gids_.size()) or (lid_end > this->gids_.size()))
301 for (
index j=0;j<i;++j)
304 for(; (gi != this->gids_.end()) && (i < lid_end); ++gi, ++i) {
306 if (filter.
select_model() && ((int)this->net_->get_model_id_of_gid(*gi) != filter.
model))
309 *iter++ = std::pair<Position<D>,
index>(lid_to_position(i), *gi);
316 insert_global_positions_(std::inserter(tree, tree.
end()), filter);
322 insert_global_positions_(std::back_inserter(vec), filter);
341 layer_(layer), mask_(&mask), anchor_(anchor), filter_(filter)
350 for(
int i=0;i<D;++i) {
362 ll[1] = layer.
dims_[1] - ur[1];
363 ur[1] = layer.
dims_[1] - tmp;
384 return std::pair<Position<D>,
index>(layer_.gridpos_to_position(node_),
385 layer_.gids_[layer_.gridpos_to_lid(node_) +
depth_*layer_size_]);
391 if (
depth_ == -1)
return *
this;
393 if (not filter_.select_depth()) {
395 if (
depth_ >= layer_.depth_) {
398 if (filter_.select_model() && (layer_.net_->get_model_id_of_gid(layer_.gids_[
depth_*layer_size_]) !=
index(filter_.model)))
408 if (node_ == node_.get_upper_right()) {
415 }
while (not mask_->inside(layer_.gridpos_to_position(node_)-anchor_));
417 if (filter_.select_model() && (layer_.net_->get_model_id_of_gid(layer_.gids_[
depth_*layer_size_]) !=
index(filter_.model)))
430 positions.push_back(*mi);
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
int int_t
Integer number with at least 16 bit.
Definition: nest.h:95
Definition: multirange.h:41
Position< D > lower_left_
lower left corner (minimum coordinates) of layer
Definition: layer.h:393
Definition: lockptrdatum.h:40
Position< D > anchor_
Definition: grid_layer.h:91
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Layer with neurons placed in a grid.
Definition: grid_layer.h:34
const Name layer("layer")
Definition: topology_names.h:82
masked_iterator masked_end()
Definition: grid_layer.h:334
void get_status(DictionaryDatum &) const
Export properties of the layer by setting entries in the status dictionary.
Definition: layer_impl.h:79
An index into a multidimensional array.
Definition: position.h:304
std::pair< Position< D >, index > value_type
Definition: grid_layer.h:39
masked_iterator operator++(int)
Postfix increment operator.
Definition: grid_layer.h:71
std::vector< index > get_nodes(Position< D, int_t > pos)
Returns nodes at a given discrete layerspace position.
Definition: grid_layer.h:249
const Name layers("layers")
Definition: topology_names.h:81
value_type & reference
Definition: grid_layer.h:40
Contains rules for selecting nodes from a layer when connecting.
Definition: selector.h:36
Position< D > get_position(index sind) const
Get position of node.
Definition: grid_layer.h:222
Position< D > extent_
size of layer
Definition: layer.h:394
GridLayer(const GridLayer &l)
Definition: grid_layer.h:101
Position< D > gridpos_to_position(Position< D, int_t > gridpos) const
Definition: grid_layer.h:209
Iterator iterating over the nodes inside a Mask.
Definition: grid_layer.h:46
value_type operator*()
Definition: grid_layer.h:381
std::bitset< D > periodic_
periodic b.c.
Definition: layer.h:395
const value_type & const_reference
Definition: grid_layer.h:41
const Mask< D > * mask_
Definition: grid_layer.h:90
void insert_local_positions_ntree_(Ntree< D, index > &tree, const Selector &filter)
Insert local position info into ntree.
Definition: grid_layer.h:263
index gridpos_to_lid(Position< D, int_t > pos) const
Definition: grid_layer.h:228
Abstract base class for masks with given dimension.
Definition: mask.h:90
A Ntree object represents a subtree or leaf in a Ntree structure.
Definition: ntree.h:49
Position< D > lid_to_position(index lid) const
Get position of node.
Definition: grid_layer.h:195
MultiIndex< D > node_
Definition: grid_layer.h:93
const Name anchor("anchor")
Definition: topology_names.h:50
bool select_depth() const
Definition: selector.h:58
void insert_global_positions_ntree_(Ntree< D, index > &tree, const Selector &filter)
Insert global position info into ntree.
Definition: grid_layer.h:314
Abstract base class for Layer of given dimension (D=2 or 3).
Definition: connection_creator.h:39
Selector filter_
Definition: grid_layer.h:92
void insert_global_positions_vector_(std::vector< std::pair< Position< D >, index > > &vec, const Selector &filter)
Insert global position info into vector.
Definition: grid_layer.h:320
const Name other("other")
Node type.
Definition: nest_names.h:216
iterator insert(Position< D > pos, const T &node)
Traverse quadtree structure from current ntree.
Definition: ntree_impl.h:362
GridLayer()
Definition: grid_layer.h:97
long_t model
The model to select, or -1 if all models are allowed.
Definition: selector.h:69
A box is defined by the lower left corner (minimum coordinates) and the upper right corner (maximum c...
Definition: position.h:289
const Name positions("positions")
Definition: topology_names.h:53
int_t layer_size_
Definition: grid_layer.h:89
void set_status(const DictionaryDatum &d)
Definition: grid_layer.h:161
masked_iterator masked_begin(const Mask< D > &mask, const Position< D > &anchor, const Selector &filter)
Definition: grid_layer.h:327
Position< D, index > dims_
number of nodes in each direction.
Definition: grid_layer.h:145
bool operator==(const masked_iterator &other) const
Iterators are equal if they point to the same node in the same layer.
Definition: grid_layer.h:81
const Name topology("topology")
Definition: topology_names.h:54
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition: exceptions.h:420
Position< D > upper_right
Definition: position.h:297
void get_status(DictionaryDatum &d) const
Definition: grid_layer.h:183
const Name min("min")
Definition: topology_names.h:74
const Name lid("lid")
Definition: topology_names.h:58
Position< D, index > get_dims() const
Definition: grid_layer.h:155
Position< D > key_type
Definition: grid_layer.h:37
const Name columns("columns")
Definition: topology_names.h:43
index mapped_type
Definition: grid_layer.h:38
size_t global_size() const
Returns total number of children.
Definition: subnet.h:276
long_t depth
The depth to select, or -1 if all depths are allowed.
Definition: selector.h:73
masked_iterator(const GridLayer< D > &layer)
Constructor for an invalid iterator.
Definition: grid_layer.h:51
int_t depth_
number of neurons at each position
Definition: layer.h:168
const Name max("max")
Definition: topology_names.h:75
Position< D > lower_left
Definition: position.h:296
const Name mask("mask")
Definition: topology_names.h:57
const Name rows("rows")
Number of rows in a layer or mask.
Definition: topology_names.h:42
void set_status(const DictionaryDatum &)
Change properties of the layer according to the entries in the dictionary.
Definition: layer_impl.h:58
const GridLayer< D > & layer_
Definition: grid_layer.h:88
virtual Box< D > get_bbox() const =0
The whole mask is inside (i.e., false everywhere outside) the bounding box.
Abstract base class for masks with unspecified dimension.
Definition: mask.h:41
int_t depth_
Definition: grid_layer.h:94
bool select_model() const
Definition: selector.h:53
bool operator!=(const masked_iterator &other) const
Definition: grid_layer.h:83
std::vector< std::pair< Position< D >, index > > get_global_positions_vector(Selector filter, const AbstractMask &mask, const Position< D > &anchor, bool allow_oversized)
Definition: grid_layer.h:424
iterator end()
Definition: ntree.h:261
masked_iterator & operator++()
Move the iterator to the next node within the mask.
Definition: grid_layer.h:389
void insert_global_positions_(Ins iter, const Selector &filter)
Definition: grid_layer.h:287