/* * test_distance.sli * * This file is part of NEST. * * Copyright (C) 2004 The NEST Initiative * * NEST is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * NEST is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NEST. If not, see <http://www.gnu.org/licenses/>. * */ % simple tests for distance calculations /unittest (8831) require unittest using topology using % fixed grid, distance from node { ResetKernel % nodes at [-1,0,1]x[-1,0,1] /l << /elements /iaf_neuron /rows 3 /columns 3 /extent [3. 3.] >> CreateLayer def % nodes placed downward columnwise [ 2 3 4 5 6 7 8 9 10 ] { 2 exch Distance } Map [0. 1. 2. % first column 1. 2. sqrt 5. sqrt % second column 2. 5. sqrt 8. sqrt] % third column eq } assert_or_die % fixed grid with periodic BC, distance from node { ResetKernel % nodes at [-1,0,1]x[-1,0,1] /l << /elements /iaf_neuron /rows 3 /columns 3 /extent [3. 3.] /edge_wrap true >> CreateLayer def % nodes placed downward columnwise [ 2 3 4 5 6 7 8 9 10 ] { 2 exch Distance } Map [0. 1. 1. % first column 1. 2. sqrt 2. sqrt % second column 1. 2. sqrt 2. sqrt] % third column eq } assert_or_die % fixed grid, distance from location { ResetKernel % nodes at [-1,0,1]x[-1,0,1] /l << /elements /iaf_neuron /rows 3 /columns 3 /extent [3. 3.] >> CreateLayer def % nodes placed downward columnwise [ 2 3 4 5 6 7 8 9 10 ] { [0. 0.] exch Distance } Map [2. sqrt 1. 2. sqrt % first column 1. 0. 1. % second column 2. sqrt 1. 2. sqrt ] % third column eq } assert_or_die % fixed grid with periodic BC, distance from location { ResetKernel % nodes at [-1,0,1]x[-1,0,1] /l << /elements /iaf_neuron /rows 3 /columns 3 /extent [3. 3.] /edge_wrap true >> CreateLayer def % nodes placed downward columnwise [ 2 3 4 5 6 7 8 9 10 ] { [1. 0.] exch Distance } Map [2. sqrt 1. 2. sqrt % first column 2. sqrt 1. 2. sqrt % second column 1. 0. 1. ] % third column eq } assert_or_die % free grid, distance from node { ResetKernel /l << /elements /iaf_neuron /positions [ [-0.75 0.5] [0.75 0.] ] /extent [2. 2.] >> CreateLayer def % nodes placed downward columnwise [ 2 3 ] { 2 exch Distance } Map [0. 1.5 sqr 0.5 sqr add sqrt ] eq } assert_or_die % free grid, periodic bc, distance from node { ResetKernel /l << /elements /iaf_neuron /positions [ [-0.75 0.5] [0.75 0.] ] /extent [2. 2.] /edge_wrap true >> CreateLayer def % nodes placed downward columnwise [ 2 3 ] { 2 exch Distance } Map [0. 0.5 sqr 0.5 sqr add sqrt ] eq } assert_or_die endusing endusing