90 if(this->global_size()/this->depth_ != pos.
size()) {
91 std::stringstream expected;
92 std::stringstream got;
93 expected <<
"position array with length " << this->global_size()/this->depth_;
94 got <<
"position array with length" << pos.
size();
99 positions_.reserve(this->local_size());
101 const index nodes_per_depth = this->global_size()/this->depth_;
102 const index first_lid = this->nodes_[0]->get_lid();
104 for(vector<Node*>::iterator i = this->local_begin(); i != this->local_end(); ++i) {
109 if ( ((*i)->get_lid() != first_lid) &&
110 ((*i)->get_lid() % nodes_per_depth == first_lid ) ) {
115 getValue<std::vector<double_t> >(pos[(*i)->get_lid() % nodes_per_depth]);
117 if (not ((point >= this->lower_left_) and (point < this->lower_left_+this->extent_)))
118 throw BadProperty(
"Node position outside of layer");
120 positions_.push_back(point);
135 for(
typename std::vector<
Position<D> >::const_iterator it = positions_.begin();
136 it != positions_.end(); ++it) {
137 points.push_back(it->getToken());
148 return positions_[sind % positions_.size()];
155 assert(this->nodes_.size() >= positions_.size());
158 std::vector<double_t> local_gid_pos;
159 std::vector<Node*>::const_iterator nodes_begin;
160 std::vector<Node*>::const_iterator nodes_end;
165 local_gid_pos.reserve((D+1)*(this->nodes_.size()/this->depth_ + 1));
166 nodes_begin = this->local_begin(filter.
depth);
167 nodes_end = this->local_end(filter.
depth);
169 local_gid_pos.reserve((D+1)*this->nodes_.size());
170 nodes_begin = this->local_begin();
171 nodes_end = this->local_end();
174 for(std::vector<Node*>::const_iterator node_it = nodes_begin; node_it != nodes_end; ++node_it) {
180 local_gid_pos.push_back((*node_it)->get_gid());
183 local_gid_pos.push_back(positions_[(*node_it)->get_subnet_index() % positions_.size()][j]);
187 std::vector<double_t> global_gid_pos;
188 std::vector<int> displacements;
196 pos_end = pos_ptr + global_gid_pos.size()/(D+1);
199 std::sort(pos_ptr, pos_end);
200 pos_end = std::unique(pos_ptr, pos_end);
203 for(;pos_ptr < pos_end; pos_ptr++) {
213 communicate_positions_(std::inserter(tree, tree.
end()), filter);
220 assert(this->nodes_.size() >= positions_.size());
222 std::vector<Node*>::const_iterator nodes_begin;
223 std::vector<Node*>::const_iterator nodes_end;
228 nodes_begin = this->local_begin(filter.
depth);
229 nodes_end = this->local_end(filter.
depth);
231 nodes_begin = this->local_begin();
232 nodes_end = this->local_end();
235 for(std::vector<Node*>::const_iterator node_it = nodes_begin; node_it != nodes_end; ++node_it) {
240 tree.
insert(std::pair<
Position<D>,
index>(positions_[(*node_it)->get_subnet_index() % positions_.size()],(*node_it)->get_gid()));
249 return a.second <
b.second;
256 communicate_positions_(std::back_inserter(vec), filter);
259 std::sort(vec.begin(),vec.end(),gid_less<D>);
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
bool operator<(const NodePositionData &other) const
Definition: free_layer.h:70
Position< D > get_position(index sind) const
Get position of node.
Definition: free_layer.h:144
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Exception to be thrown if a given SLI type does not match the expected type.
Definition: sliexceptions.h:147
void get_status(DictionaryDatum &) const
Export properties of the layer by setting entries in the status dictionary.
Definition: layer_impl.h:79
std::vector< Position< D > > positions_
Vector of positions. Should match node vector in Subnet.
Definition: free_layer.h:63
bool operator==(const NodePositionData &other) const
Definition: free_layer.h:72
Contains rules for selecting nodes from a layer when connecting.
Definition: selector.h:36
Definition: tokenarray.h:62
const Name points("points")
Definition: topology_names.h:55
const Name a("a")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:41
void get_status(DictionaryDatum &) const
Definition: free_layer.h:128
index get_gid() const
Definition: free_layer.h:68
A Ntree object represents a subtree or leaf in a Ntree structure.
Definition: ntree.h:49
bool select_depth() const
Definition: selector.h:58
static void communicate(std::vector< uint_t > &send_buffer, std::vector< uint_t > &recv_buffer, std::vector< int > &displacements)
communicate (on-grid) if compiled without MPI
Definition: communicator.cpp:239
Abstract base class for Layer of given dimension (D=2 or 3).
Definition: connection_creator.h:39
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
long_t model
The model to select, or -1 if all models are allowed.
Definition: selector.h:69
const Name positions("positions")
Definition: topology_names.h:53
void set_status(const DictionaryDatum &)
Definition: free_layer.h:83
double_t pos_[D]
Definition: free_layer.h:77
Layer with free positioning of neurons, positions specified by user.
Definition: free_layer.h:41
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
size_t size(void) const
Return number of elements in the array.
Definition: tokenarray.h:142
void insert_local_positions_ntree_(Ntree< D, index > &tree, const Selector &filter)
Insert local position info into ntree.
Definition: free_layer.h:218
void insert_global_positions_vector_(std::vector< std::pair< Position< D >, index > > &vec, const Selector &filter)
Insert global position info into vector.
Definition: free_layer.h:253
double double_t
Double precision floating point numbers.
Definition: nest.h:93
long_t depth
The depth to select, or -1 if all depths are allowed.
Definition: selector.h:73
const Name b("b")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:58
void insert_global_positions_ntree_(Ntree< D, index > &tree, const Selector &filter)
Insert global position info into ntree.
Definition: free_layer.h:210
This class is used when communicating positions across MPI procs.
Definition: free_layer.h:66
double_t gid_
Definition: free_layer.h:76
void set_status(const DictionaryDatum &)
Change properties of the layer according to the entries in the dictionary.
Definition: layer_impl.h:58
void communicate_positions_(Ins iter, const Selector &filter)
Communicate positions across MPI processes.
Definition: free_layer.h:153
static bool gid_less(const std::pair< Position< D >, index > &a, const std::pair< Position< D >, index > &b)
Definition: free_layer.h:247
bool select_model() const
Definition: selector.h:53
iterator end()
Definition: ntree.h:261
Position< D > get_position() const
Definition: free_layer.h:69