37 std::vector<std::pair<Position<D>,
index> > * Layer<D>::cached_vector_ = 0;
40 Selector Layer<D>::cached_selector_;
47 for(
int i=0;i<D;++i) {
49 displ[i] = -0.5*extent_[i] + std::fmod(displ[i]+0.5*extent_[i], extent_[i]);
50 if (displ[i]<-0.5*extent_[i])
51 displ[i] += extent_[i];
63 lower_left_ = center - extent_/2;
67 lower_left_ -= extent_/2;
71 periodic_ = (1<<D) - 1;
86 (*topology_dict)[
names::extent] = std::vector<double_t>(extent_);
87 (*topology_dict)[
names::center] = std::vector<double_t>(lower_left_ + extent_/2);
91 else if (periodic_.count()==D)
103 }
catch (std::bad_cast
e) {
104 throw BadProperty(
"Target layer must have same number of dimensions as source layer.");
113 insert_local_positions_ntree_(*ntree, filter);
121 if ((cached_ntree_layer_ == get_gid()) and (cached_selector_ == filter)) {
122 assert(cached_ntree_.valid());
123 return cached_ntree_;
126 clear_ntree_cache_();
130 return do_get_global_positions_ntree_(filter);
136 clear_ntree_cache_();
137 clear_vector_cache_();
140 for(
int i=0;i<D;++i) {
141 if (not periodic[i]) {
142 extent[i] = extent_[i];
143 lower_left[i] = lower_left_[i];
149 do_get_global_positions_ntree_(filter);
151 cached_ntree_layer_ = -1;
153 return cached_ntree_;
159 if ((cached_vector_layer_ == get_gid()) and (cached_selector_ == filter)) {
162 typename std::insert_iterator<Ntree<D,index> > to = std::inserter(*cached_ntree_, cached_ntree_->end());
164 for(
typename std::vector<std::pair<
Position<D>,
index> >::iterator from=cached_vector_->begin();
165 from != cached_vector_->end(); ++from) {
171 insert_global_positions_ntree_(*cached_ntree_, filter);
175 clear_vector_cache_();
177 cached_ntree_layer_ = get_gid();
178 cached_selector_ = filter;
180 return cached_ntree_;
186 if ((cached_vector_layer_ == get_gid()) and (cached_selector_ == filter)) {
188 return cached_vector_;
191 clear_vector_cache_();
193 cached_vector_ =
new std::vector<std::pair<Position<D>,
index> >;
195 if ((cached_ntree_layer_ == get_gid()) and (cached_selector_ == filter)) {
198 typename std::back_insert_iterator<std::vector<std::pair<Position<D>,index> > > to = std::back_inserter(*cached_vector_);
201 from != cached_ntree_->end(); ++from) {
207 insert_global_positions_vector_(*cached_vector_, filter);
211 clear_ntree_cache_();
213 cached_vector_layer_ = get_gid();
214 cached_selector_ = filter;
216 return cached_vector_;
222 MaskedLayer<D> masked_layer(*
this,filter,mask,
true,allow_oversized);
226 positions.push_back(*iter);
236 std::vector<index> nodes;
238 nodes.push_back(i->second);
246 for(
index i=0;i<nodes_.size();++i) {
247 const index gid = nodes_[i]->get_gid();
249 get_position(i).print(out);
257 std::vector<std::pair<Position<D>,
index> >* src_vec = get_global_positions_vector();
264 std::vector<index> source_array(1);
266 for(
typename std::vector<std::pair<
Position<D>,
index> >::iterator src_iter=src_vec->begin();
267 src_iter != src_vec->end(); ++src_iter) {
269 const index source_gid = src_iter->second;
272 source_array[0] = source_gid;
274 ArrayDatum connectome = net_->get_connections(gcdict);
277 for(
size_t i = 0; i < connectome.
size(); ++i ) {
280 con_id.get_source_gid(),
281 con_id.get_synapse_model_id(),
283 con_id.get_target_thread());
289 Node const *
const target = net_->get_node(target_gid);
293 out << source_gid <<
' ' << target_gid <<
' '
294 << weight <<
' ' <<
delay;
301 for (
int n = 0 ;
n < D ; ++
n )
320 if (not mask_.valid()) {
332 throw BadProperty(
"Grid masks can only be used with grid layers.");
338 if (not allow_oversized) {
339 bool oversize =
false;
344 throw BadProperty(
"Mask size must not exceed layer size; set allow_oversized_mask to override.");
351 lower_left[1] = -upper_right[1];
357 catch (std::bad_cast&)
366 if (not allow_oversized) {
368 bool oversize =
false;
373 throw BadProperty(
"Mask size must not exceed layer size; set allow_oversized_mask to override.");
376 catch (std::bad_cast&)
378 throw BadProperty(
"Mask is incompatible with layer.");
size_t index
Unsigned long type for enumerations.
Definition: nest.h:109
This class is a representation of the dictionary of connection properties given as an argument to the...
Definition: connection_creator.h:65
double_t weight
Weight of a connection.
Definition: nest.h:170
const Name edge_wrap("edge_wrap")
Definition: topology_names.h:49
const Name delay("delay")
Connection parameters.
Definition: nest_names.h:92
Ntree< D, index >::masked_iterator begin(const Position< D > &anchor)
Iterate over nodes inside mask.
Definition: layer.h:506
lockPTR< Ntree< D, index > > get_local_positions_ntree(Selector filter=Selector())
Get positions for local nodes in layer.
Definition: layer_impl.h:109
void set_status(const DictionaryDatum &)
Definition: subnet.cpp:57
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Iterator iterating the nodes in a Quadtree inside a Mask.
Definition: ntree.h:128
Layer with neurons placed in a grid.
Definition: grid_layer.h:34
const Name layer("layer")
Definition: topology_names.h:82
Ntree< D, index >::masked_iterator end()
Definition: layer.h:517
void get_status(DictionaryDatum &) const
Definition: subnet.cpp:63
const Name weight("weight")
Connection parameters.
Definition: nest_names.h:344
void get_status(DictionaryDatum &) const
Export properties of the layer by setting entries in the status dictionary.
Definition: layer_impl.h:79
lockPTR< Ntree< D, index > > do_get_global_positions_ntree_(const Selector &filter)
Definition: layer_impl.h:157
const Name extent("extent")
Definition: topology_names.h:47
const Position< D > & get_extent() const
Definition: layer.h:235
const Name lower_left("lower_left")
Definition: topology_names.h:66
Contains rules for selecting nodes from a layer when connecting.
Definition: selector.h:36
Mask which covers all of space.
Definition: mask.h:141
Position< D, int_t > get_upper_left() const
Definition: grid_mask.h:76
void connect(Layer< D > &source, Layer< D > &target)
Connect two layers.
Definition: connection_creator_impl.h:38
const Name depth("depth")
Definition: topology_names.h:46
Class for applying masks to layers.
Definition: connection_creator.h:42
Position< D, int_t > get_lower_right() const
Definition: grid_mask.h:79
Mask defining a box region.
Definition: mask.h:182
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
A class that associates names and tokens.
Definition: dict.h:45
const Name anchor("anchor")
Definition: topology_names.h:50
void connect(AbstractLayer &target, ConnectionCreator &connector)
Connect this layer to the given target layer.
Definition: layer_impl.h:98
const Name y("y")
Definition: topology_names.h:52
const Name center("center")
Definition: topology_names.h:48
Abstract base class for Layer of given dimension (D=2 or 3).
Definition: connection_creator.h:39
bool getValue< bool >(const Token &t)
Definition: tokenutils.cc:124
Iterator iterating the nodes in a Quadtree.
Definition: ntree.h:64
const Name source("source")
Connection parameters.
Definition: nest_names.h:260
A box is defined by the lower left corner (minimum coordinates) and the upper right corner (maximum c...
Definition: position.h:289
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
const Name positions("positions")
Definition: topology_names.h:53
Abstract base class for Layers of unspecified dimension.
Definition: layer.h:44
virtual Position< D > compute_displacement(const Position< D > &from_pos, const Position< D > &to_pos) const
Returns displacement of a position from another position.
Definition: layer_impl.h:43
void def(DictionaryDatum &d, Name const n, FT const &value)
Define a new dictionary entry from a fundamental type.
Definition: dictutils.h:196
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
size_t size(void) const
Return number of elements in the array.
Definition: tokenarray.h:142
Position< D, index > get_dims() const
Definition: grid_layer.h:155
const Token & get(long i) const
Definition: tokenarray.h:172
double double_t
Double precision floating point numbers.
Definition: nest.h:93
Mask defined in terms of grid points rather than spacial coordinates.
Definition: grid_mask.h:41
void dump_nodes(std::ostream &os) const
Write layer data to stream.
Definition: layer_impl.h:244
void dump_connections(std::ostream &out, const Token &syn_model)
Dumps information about all connections of the given type having their source in the given layer to t...
Definition: layer_impl.h:255
const Name n("n")
Number of synaptic release sites (int >=0) (Tsodyks2_connection)
Definition: nest_names.h:202
long_t delay
Delay of a connection.
Definition: nest.h:178
Definition: booldatum.h:35
Position< D > lower_left
Definition: position.h:296
const Name mask("mask")
Definition: topology_names.h:57
This template is the standard safe-pointer implementation of SYNOD.
Definition: lockptr.h:84
void set_status(const DictionaryDatum &)
Change properties of the layer according to the entries in the dictionary.
Definition: layer_impl.h:58
Base class for all NEST network objects.
Definition: node.h:96
virtual Box< D > get_bbox() const =0
The whole mask is inside (i.e., false everywhere outside) the bounding box.
std::bitset< D > get_periodic_mask() const
Definition: layer.h:247
A type-independent container for C++-types.
Definition: token.h:68
std::vector< std::pair< Position< D >, index > > * get_global_positions_vector(Selector filter=Selector())
Definition: layer_impl.h:184
lockPTR< Ntree< D, index > > get_global_positions_ntree(Selector filter=Selector())
Get positions for all nodes in layer, including nodes on other MPI processes.
Definition: layer_impl.h:119
const Name synapse_model("synapse_model")
Connection parameters.
Definition: nest_names.h:272
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
const Name upper_right("upper_right")
Definition: topology_names.h:67
const double e
Definition: numerics.cpp:62
void check_mask_(Layer< D > &layer, bool allow_oversized)
Will check that the mask can be applied to the layer.
Definition: layer_impl.h:318
std::vector< index > get_global_nodes(const MaskDatum &mask, const std::vector< double_t > &anchor, bool allow_oversized)
Return a vector with the GIDs of the nodes inside the mask.
Definition: layer_impl.h:233