is vector length determined by input file?
Posted: Thu Feb 24, 2011 2:23 pm
In the code below I specify a new vector of length 3. However, when I initialize vector components from a file, the length of the vector becomes determined by the file length. If, for example, a file has 5 numbers (as below), the vector length becomes equal to 5. If a file has 2 numbers in it (not shown), the length becomes equal to 2. I wonder if it always works like this? In other words, is it a part of NEURON implementation that an input file determines the vector length?
Thanks,
Andrey
-----------------------------------------------
load_file("nrngui.hoc")
objref a, f
a = new Vector(3)
f = new File()
f.ropen("test_vector.dat")
a.scanf(f)
f.close()
print "a:"
a.printf()
/* test_vector.dat:
1
2
3
4
5
*/
/* Output:
NEURON -- Release 7.0 (281:80827e3cd201) 2009-01-16
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html
1
1
5
0
a:
1 2 3 4 5
5
*/
Thanks,
Andrey
-----------------------------------------------
load_file("nrngui.hoc")
objref a, f
a = new Vector(3)
f = new File()
f.ropen("test_vector.dat")
a.scanf(f)
f.close()
print "a:"
a.printf()
/* test_vector.dat:
1
2
3
4
5
*/
/* Output:
NEURON -- Release 7.0 (281:80827e3cd201) 2009-01-16
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html
1
1
5
0
a:
1 2 3 4 5
5
*/