classes Fourier get median setrand abs hist min sin add histogram min_ind size addrand ind mul smhist append index play sort apply indgen play_remove sortindex at indvwhere plot spikebin buffer_size indwhere ploterr sqrt c inf pow stderr cl insrt printf stdev contains integral psth sub copy interpolate rebin sum deriv label record sumgauss div line reduce sumsq dot log remove tanh eq log10 resample to_python fill mag resize trigavg fit mark reverse var floor max rotate vread fread max_ind scale vwrite from_double mean scanf where from_python meansqerr scantil x fwrite medfltr set

This class was implemented by

--------------------------- Zach Mainen Computational Neurobiology Laboratory Salk Institute 10010 N. Torrey Pines Rd. La Jolla, CA 92037 zach@salk.edu ----------------------------

`obj` = new Vector()

`obj` = new Vector(`size`)

`obj` = new Vector(`size`, `init`)

`double x[]`

variable. Individual elements of this array can
be manipulated with the normal `.x[``index`]

notation.
Most of the Vector functions apply their operations to each element of the
x array thus avoiding the often tedious scaffolding required by an otherwise
un-encapsulated double array.
A vector can be created with length `size` and with each element set
to the value of `init.`

Vector methods that modify the elements are generally of the form

obj = vsrcdest.method(...)in which the values of vsrcdest on entry to the method are used as source values by the method to compute values which replace the old values in vsrcdest and the original vsrcdest object reference is the return value of the method. For example, v1 = v2 + v3 would be written,

v1 = v2.add(v3)However, this results in two, often serious, side effects. First, the v2 elements are changed and so the original values are lost. Furthermore v1 at the end is a reference to the same Vector object pointed to by v2. That is, if you subsequently change the elements of v2, the elements of v1 will change as well since v1 and v2 are in fact labels for the same object.

When these side effects need to be avoided, one uses the Vector.c function which returns a reference to a completely new Vector which is an identical copy. ie.

v1 = v2.c.add(v3)leaves v2 unchanged, and v1 points to a completely new Vector. One can build up elaborate vector expressions in this manner, ie v1 = v2*s2 + v3*s3 + v4*s4could be written

v1 = v2.c.mul(s2).add(v3.c.mul(s3)).add(v4.c.mul(s4))but if the expressions get too complex it is probably clearer to employ temporary objects to break the process into several separate expressions.

will create a vector with 20 indices, each having the value of 5.`objref vec`

`vec = new Vector(20,5)`

will create a vector with 1 index which has value of 0. It is seldom necessary to specify a size for a new vector since most operations, if necessary, increase or decrease the number of available elements as needed.`objref vec1`

`vec1 = new Vector()`

Vector

`vec.x[``index`]

`vec.x[``index`]

notation.
Vector indices range from 0 to Vector.size()-1.
This
notation is superior to the older `vec.get()`

and `vec.set()`

notations for
three reasons:
- It performs the roles of both
`vec.get`

and`vec.set`

with a syntax that is consistent with the normal syntax for a`double`

array inside of an object. - It can be viewed by a field editor (since it can appear on the left hand side of an assignment statement).
- You can take its address for functions which require that kind of argument.

`print vec.x[0]`

prints the value of the 0th (first) element.
`vec.x[i] = 3`

sets the i'th element to 3.

Note, however, that there is a potential difficulty with the xpvalue field editor since, if vec is ever resized, then the pointer will be invalid. In this case, the field editor will display the string, "Free'd".xpanel("show a field editor") xvalue("vec.x[3]") xpvalue("last element", &vec.x[vec.size() - 1]) xpanel()

`vec.x[-1]`

returns the value of the first element of the vector, just as
would `vec.x[0]`

.
`vec.x(`

returns the value of index `i`)`i` just as does `vec.x[`

.
`i`]

Vector

`size = vec.size()`

`vec.size() - 1`

. Most explicit for loops over a vector can take the form:
Note: There is a distinction between the size of a vector and the amount of memory allocated to hold the vector. Generally, memory is only freed and reallocated if the size needed is greater than the memory storage previously allocated to the vector. Thus the memory used by vectors tends to grow but not shrink. To reduce the memory used by a vector, one can explicitly call buffer_size .for i=0, vec.size()-1 {... vec.x[i] ...}

Vector

`obj = vsrcdest.resize(``new_size`)

Warning: Any function that resizes the vector to a larger size than its available space will make existing pointers to the elements invalid (see note in size ). For example, resizing vectors that have been plotted will remove that vector from the plot list. Other functions may not be so forgiving and result in a memory error (segmentation violation or unhandled exception).

appends 10 elements, each having a value of 0, toobjref vec vec = new Vector(20,5) vec.resize(30)

`vec`

.
removes the last 20 elements from the`vec.resize(10)`

`vec`

.The values of the first
10 elements are unchanged.

Vector

`space = vsrc.buffer_size()`

`space = vsrc.buffer_size(request)`

With an argument, frees the old memory space and allocates new memory space for the vector, copying old element values to the new elements. If the request is less than the size, the size is truncated to the request. For vectors that grow continuously, it may be more efficient to allocate enough space at the outset, or else occasionally change the buffer_size by larger chunks. It is not necessary to worry about the efficiency of growth during a Vector.record since the space available automatically increases by doubling.

objref y y = new Vector(10) y.size() y.buffer_size() y.resize(5) y.size y.buffer_size() y.buffer_size(100) y.size()

Vector

`x = vec.get(``index`)

`vec.x[]`

notation but is retained for backward
compatibility.

Vector

`obj = vsrcdest.set(``index`,`value`)

`vec.x[``i`] = `expr`

notation but is retained for backward
compatibility.

Vector

`obj = vsrcdest.fill(``value`)

`obj = vsrcdest.fill(``value`, `start`, `end`)

If `start` and
`end` arguments are present, they specify the index range for the assignment.

assigns 9 to vec.x[2] through vec.x[7] (a total of 6 elements)objref vec vec = new Vector(20,5) vec.fill(9,2,7)

Vector

`strdef s`

`s = vec.label()`

`s = vec.label(s)`

objref vec vec = new Vector() print vec.label() vec.label("hello") print vec.label()

Vector

`vdest.record(&``var`)

`vdest.record(&``var`, `Dt`)

`vdest.record(&``var`, `tvec`)

`vdest.record(point_process_object, &varvar, ...)`

Details:
Transfers take place on exit from `finitialize()`

and on exit from `fadvance()`

.
At the end of `finitialize()`

, `v.x[0] = var`

. At the end of `fadvance`

,
`var` will be saved if `t`

(after being incremented by `fadvance`

)
is equal or greater than the associated time of the
next index. The system maintains a set of record vectors and the vector will
be removed from the list if the vector or var is destroyed.
The vector is automatically increased in size by 100 elements at a time
if more space is required, so efficiency will be slightly improved if one
creates vectors with sufficient size to hold the entire stream, and plots will
be more persistent (recall that resizing may cause reallocation of memory
to hold elements and this will make pointers invalid).

The record semantics can be thought of as:

`var(t) -> v.x[index]`

The default relationship between `index`

and
`t`

is `t = index*dt`

.

In the second form, `t = index*Dt`

.

In the third form, `t = tvec.x[index]`

.

For the local variable timestep method, use_local_dt and/or multiple
threads, nthread , it is
often helpful to provide specific information about which cell the
`var` pointer is associated with by inserting as the first arg some POINT_PROCESS
object which is located on the cell. This is necessary if the pointer is not
a RANGE variable and is much more efficient if it is. The fixed step and global
variable time step method do not need or use this information for the
local step method but will use it for multiple threads. It is therefore
a good idea to supply it if possible.

`dt`

is greater than
`Dt`

. Things work best if `Dt`

happens to be a multiple of `dt`

. All combinations
of record ; play ; `Dt =>< dt `

; and tvec sequences
have not been tested.
If one is using the graphical interface generated by "Standard Run Library" to simulate a neuron containing a "terminal" section, Then one can store the time course of the terminal voltage (between runs) with:

Note that the next "run" will overwrite the previous time course stored in the vector. Thus dv should be copied to another vector ( see copy ). To remove dv from the list of record vectors, the easiest method is to destroy the instance withobjref dv dv = new Vector() dv.record(&terminal.v(.5)) init() // or push the "Init and Run" button on the control panel run()

`dv = new Vector()`

Vector

`vsrc.play(&``var`, `Dt`)

`vsrc.play(&``var`, `tvec`)

`vsrc.play("stmt involving $1", optional Dt or tvec arg)`

`vsrc.play(index)`

`vsrc.play(&var or stmt, Dt or Tvec, continuous)`

`vsrc.play(&var or stmt, tvec, indices_of_discontinuities_vector)`

`vsrc.play(point_process_object, &``var`, ...)

`vsrc`

vector values are assigned to the "The same vector can be played into different variables.

If the "stmt involving $1" form is used, that statement is executed with the appropriate value of the $1 arg. This is not as efficient as the pointer form but is useful for playing a value into a set of variables as in

forall g_pas = $1

The index form immediately sets the var (or executes the stmt) with the value of vsrc.x[index]

The play semantics can be thought of as
`v.x[index] -> var(t)`

where t(index) is Dt*index or tvec.x[index]
The discrete event delivery system is used to determine the precise
time at which values are copied from vsrc to var. Note that for variable
step methods, unless continuity is specifically requested, the function
is a step function. Also, for the local variable dt method, var MUST be
associated with the cell that contains the currently accessed section
(but see the paragraph below about the use of a point_process_object
inserted as the first arg).

For the fixed step method
transfers take place on entry to `finitialize()`

and on entry to `fadvance()`

.
At the beginning of `finitialize()`

, `var = v.x[0]`

. On `fadvance`

a transfer will
take place if t will be (after the `fadvance`

increment) equal
or greater than the associated time of the next index. For the variable step
methods, transfers take place exactly at the times specified by the Dt
or tvec arguments.

The system maintains a set of play vectors and the vector will be removed
from the list if the vector or var is destroyed.
If the end of the vector is reached, no further transfers are made (`var`

becomes
constant)

Note well: for the fixed step method,
if `fadvance`

exits with time equal to `t`

(ie enters at time t-dt),
then on entry to `fadvance`

,

is set equal to the value of
the vector at the index
appropriate to time t. Execute tests/nrniv/vrecord.hoc to see what this implies
during a simulation. ie the value of var from `var``t-dt`

to t played into by
a vector is equal to the value of the vector at `index(t)`

. If the vector
was meant to serve as a continuous stimulus function, this results in
a first order correct simulation with respect to dt. If a second order correct
simulation is desired, it is necessary (though perhaps not sufficient since
all other equations in the system must also be solved using methods at least
second order correct) to fill the vector with function values at f((i-.5)*dt).

When continuous is 1 then linear interpolation is used to define the values between time points. However, events at each Dt or tvec are still used and that has beneficial performance implications for variable step methods since vsrc is equivalent to a piecewise linear function and variable step methods can excessively reduce dt as one approaches a discontinuity in the first derivative. Note that if there are discontinuities in the function itself, then tvec should have adjacent elements with the same time value. As of version 6.2, when a value is greater than the range of the t vector, linear extrapolation of the last two points is used instead of a constant last value. If a constant outside the range is desired, make sure the last two points have the same y value and have different t values (if the last two values are at the same time, the constant average will be returned). (note: the 6.2 change allows greater variable time step efficiency as one approaches discontinuities.)

The indices_of_discontinuities_vector argument is used to specifying the indices in tvec of the times at which discrete events should be used to notify that a discontinuity in the function, or any derivative of the function, occurs. Presently, linear interpolation is used to determine var(t) in the interval between these discontinuities (instead of cubic spline) so the length of steps used by variable step methods near the breakpoints depends on the details of how the parameter being played into affects the states.

For the local variable timestep method, use_local_dt and/or multiple
threads, nthread , it is
often helpful to provide specific information about which cell the
`var` pointer is associated with by inserting as the first arg some POINT_PROCESS
object which is located on the cell. This is necessary if the pointer is not
a RANGE variable and is much more efficient if it is. The fixed step and global
variable time step method do not need or use this information for the
local step method but will use it for multiple threads. It is therefore
a good idea to supply it if possible.

Vector

`v.play_remove()`

record and play have been implemented by Michael Hines.

Vector

`obj = vsrcdest.indgen()`

`obj = vsrcdest.indgen(``stepsize`)

`obj = vsrcdest.indgen(``start`,`stepsize`)

`obj = vsrcdest.indgen(``start`,`stop`,`stepsize`)

With only `stepsize` passed, the sequence goes from 0 to

*(size-1)
in steps of `stepsize``stepsize.` `Stepsize` does not have to be an integer.

With `start`, `stop` and `stepsize`,
the vector is resized to be 1 + (`stop` - $varstart)/`stepsize` long and the sequence goes from
`start` up to and including `stop` in increments of `stepsize.`

creates a vector with 100 elements going from 0 to 495 in increments of 5.objref vec vec = new Vector(100) vec.indgen(5)

reduces the vector to 6 elements going from 50 to 100 in increments of 10.vec.indgen(50, 100, 10)

expands the vector to 31 elements going from 90 to 990 in increments of 30.vec.indgen(90, 1000, 30)

Vector

`obj = vsrcdest.append(``vec1`, `vec2`, ...)

`vsrcdest`

vector.
turnsobjref vec, vec1, vec2 vec = new Vector (10,4) vec1 = new Vector (10,5) vec2 = new Vector (10,6) vec.append(vec1, vec2, 7, 8, 9)

`vec`

into a 33 element vector, whose first ten elements = 4, whose
second ten elements = 5, whose third ten elements = 6, and whose 31st, 32nd,
and 33rd elements = 7, 8, and 9, respectively.
Remember, index 32 refers to the 33rd element.

Vector

`obj = vsrcdest.insrt(index, ``vec1`, `vec2`, ...)

`obj.insrt(obj.size, ...)`

is equivalent to `obj.append(...)`

Vector

`obj = vsrcdest.remove(index)`

`obj = vsrcdest.remove(start, end)`

Vector

`boolean = vsrc.contains(``value`)

returns a 1, meaning the vector does contain an element whose value is 30.vec = new Vector (10) vec.indgen(5) vec.contains(30)

returns a 0. The vector does not contain an element whose value is 50.vec.contains(50)

Vector

`obj = vdest.copy(``vsrc`)

`obj = vdest.copy(``vsrc`, `dest_start`)

`obj = vdest.copy(``vsrc`, `src_start`, `src_end`)

`obj = vdest.copy(``vsrc`, `dest_start`, `src_start`, `src_end`)

`obj = vdest.copy(``vsrc`, `dest_start`, `src_start`, `src_end`, `dest_inc`, `src_inc`)

`obj = vdest.copy(``vsrc`, `vsrcdestindex`)

`obj = vdest.copy(``vsrc`, `vsrcindex`, `vdestindex`)

`.x[0]`

)
are copied to `.x[``dest_start`]

,
`src.size()-1`

)
If the second (and third) argument is a vector, the elements of that vector are the indices of the vsrc to be copied to the same indices of the vdest. In this case the vdest is not resized and any indices that are out of range of either vsrc or vdest are ignored. This function allows mapping of a subset of a source vector into the subset of a destination vector.

This function can be slightly more efficient than c since if vdest contains enough space, memory will not have to be allocated for it. Also it is convenient for those cases in which vdest is being plotted and therefore reallocation of memory (with consequent removal of vdest from the Graph) is to be explicitly avoided.

execute following example

To merge or shuffle two vectors into a third, use:... v2 = new Vector() v2.copy(v1, 0, 1, -1, 1, 2) v2.printf()

execute following example

... v3 = new Vector() v3.copy(v1, 0, 0, -1, 2, 1) v3.copy(v2, 1, 0, -1, 2, 1) v3.printf

turnsvec = new Vector(100,10) vec1 = new Vector() vec1.indgen(5,105,10) vec.copy(vec1, 50, 3, 6)

`vec`

from a 100 element into a 54 element vector.
The first 50 elements will each have the value 10 and the last four will
have the values 35, 45, 55, and 65 respectively.
produces a 30 element vector cycling three times from 0 to 9. However the self copy may work if the src index is always greater than or equal to the destination index.vec = new Vector(20) vec.indgen() vec.copy(vec, 10)

Vector

`newvec = vsrc.c`

`newvec = vsrc.c(srcstart)`

`newvec = vsrc.c(srcstart, srcend)`

Vector

`newvec = vsrc.cl`

`newvec = vsrc.cl(srcstart)`

`newvec = vsrc.cl(srcstart, srcend)`

Vector

`newvec = vsrc.at()`

`newvec = vsrc.at(``start`)

`newvec = vsrc.at(``start`,`end`)

This function predates the introduction of the vsrc.c, "clone", function which is synonymous but is retained for backward compatibility.

It merely avoids the necessity of a `vdest = new Vector()`

command and
is equivalent to

vdest = new Vector() vdest.copy(vsrc, start, end)

createsobjref vec, vec1 vec = new Vector() vec.indgen(10,50,2) vec1 = vec.at(2, 10)

`vec1`

with 9 elements which correspond to the values at indices
2 - 10 in `vec`

. The contents of `vec1`

would then be, in order: 14, 16, 18,
20, 22, 24, 26, 28, 30.

Vector

`double px[n]`

`obj = vdest.from_double(n, &px)`

Vector

`obj = vdest.where(``vsource`, `opstring`, `value1`)

`obj = vdest.where(``vsource`, `op2string`, `value1`, `value2`)

`obj = vsrcdest.where(``opstring`, `value1`)

`obj = vsrcdest.where(``op2string`, `value1`, `value2`)

`vdest`

is vector consisting of those elements of the given vector, `vsource`

that match the condition opstring.
Opstring is a string matching one of these (all comparisons are with respect to float_epsilon ):

Op2string requires two numbers defining open/closed ranges and matches one of these:`==`

`!=`

`>`

`<`

`>=`

`<=`

`[]`

`[)`

`(]`

`()`

createsvec = new Vector(25) vec1 = new Vector() vec.indgen(10) vec1.where(vec, ">=", 50)

`vec1`

with 20 elements ranging in value from 50 to 240 in
increments of 10.
createsobjref r r = new Random() vec = new Vector(25) vec1 = new Vector() r.uniform(10,20) vec.fill(r) vec1.where(vec, ">", 15)

`vec1`

with random elements gotten from `vec`

which have values
greater than 15. The new elements in vec1 will be ordered
according to the order of their appearance in `vec`

.

Vector

Vector

`i = vsrc.indwhere(``opstring`, `value`)

`i = vsrc.indwhere(``op2string`, `low`, `high`)

`obj = vsrcdest.indvwhere(``opstring`,`value`)

`obj = vsrcdest.indvwhere(``opstring`,`value`)

`obj = vdest.indvwhere(``vsource`,`op2string`,`low`, `high`)

`obj = vdest.indvwhere(``vsource`,`op2string`,`low`, `high`)

`vdest`

is a vector consisting of the indices of those elements of
the source vector that match the condition opstring.

Opstring is a string matching one of these:

Op2string is a string matching one of these:`==`

`!=`

`>`

`<`

`>=`

`<=`

`[]`

`[)`

`(]`

`()`

Comparisons are relative to the float_epsilon global variable.

vs = new Vector() {vs.indgen(0, .9, .1) vs.printf()} print vs.indwhere(">", .3) print "note roundoff error, vs.x[3] - .3 =", vs.x[3] - .3 print vs.indwhere("==", .5) vd = vs.c.indvwhere(vs, "[)", .3, .7) {vd.printf()}

Vector

`n = vsrc.fwrite(``fileobj`)

`n = vsrc.fwrite(``fileobj`, `start`, `end`)

`vec`

to an open `fileobj`

of type File in
machine dependent binary format.
You must keep track of the vector's
size for later reading, so it is recommended that you store the size of the
vector as the first element of the file.
It is almost always better to use vwrite since it stores the size of the vector automatically and is more portable since the corresponding vread will take care of machine dependent binary byte ordering differences.

Return value is the number of items. (0 if error)

fread is used to read a file containing numbers stored by `fwrite`

but
must have the same size.

Vector

`n = vdest.fread(``fileobj`)

`n = vdest.fread(``fileobj`, `n`)

`n = vdest.fread(``fileobj`, `n`, `precision`)

`fwrite.`

If `n`

is present, the vector is resized before reading. Note that
files created with fwrite cannot be fread on a machine with different
byte ordering. E.g. spark and intel cpus have different byte ordering.
It is almost always better to use `vwrite`

in combination with `vread`

.
See vwrite for the meaning of the `precision` argment.

Return value is 1 (no error checking).

Vector

`n = vec.vwrite(``fileobj`)

`n = vec.vwrite(``fileobj`, `precision`)

fileobj

of type
File .
`vwrite()`

is easier to use than `fwrite()`

since it stores the size of the vector and type information
for a more
automated read/write. The file data can also be vread on a machine with
different byte ordering. e.g. you can vwrite with an intel cpu and vread
on a sparc.
Precision formats 1 and 2 employ a simple automatic
compression which is uncompressed automatically by vread. Formats 3 and 4
remain uncompressed.
Default precision is 4 (double) because this is the usual type used for numbers in oc and therefore requires no conversion or compression

* 1 : char shortest 8 bits * 2 : short 16 bits 3 : float 32 bits 4 : double longest 64 bits 5 : int sizeof(int) bytes

* Warning! these are useful primarily for storage of data: exact values will not necessarily be maintained due to the conversion process

Return value is 1 . Only if the type field is invalid will the return value be 0.

Vector

`n = vec.vread(``fileobj`)

`vwrite()`

.
Size and data type have
been stored by `vwrite()`

to allow correct retrieval syntax, byte ordering, and
decompression (where necessary). The vector is automatically resized.
Return value is 1. (No error checking.)

objref v1, v2, f v1 = new Vector() v1.indgen(20,30,2) v1.printf() f = new File() f.wopen("temp.tmp") v1.vwrite(f) v2 = new Vector() f.ropen("temp.tmp") v2.vread(f) v2.printf()

Vector

`n = vec.printf()`

`n = vec.printf(``format_string`)

`n = vec.printf(``format_string`, `start`, `end`)

`n = vec.printf(``fileobj`)

`n = vec.printf(``fileobj`, `format_string`)

`n = vec.printf(``fileobj`, `format_string`, `start`, `end`)

`fileobj`

is present). `format_string`

for formatting the output of each element.
This string must contain exactly one `%f`

, `%g`

, or `%e`

,
but can also contain additional formatting instructions.
Return value is number of items printed.

prints the numbers 0.0000 through 0.9000 in increments of 0.1. Each number will take up a total of eight spaces, will have four decimal places and will be printed on a new line.vec = new Vector() vec.indgen(0, 1, 0.1) vec.printf("%8.4f\n")

Vector

`n = vec.scanf(``fileobj`)

`n = vec.scanf(``fileobj`, `n`)

`n = vec.scanf(``fileobj`, `c`, `nc`)

`n = vec.scanf(``fileobj`, `n`, `c`, `nc`)

`vec.scanf`

reads until end of file.
If reading
til eof, a number followed
by a newline must be the last string in the file. (no trailing spaces
after the number and no extra newlines).
When reading til EOF, the vector grows approximately by doubling when
its currently allocated space is filled. To avoid the overhead of
memory reallocation when scanning very long vectors (e.g. > 50000 elements)
it is a good idea to presize the vector to a larger value than the
expected number of elements to be scanned.
Note that although the vector is resized to
the actual number of elements scanned, the space allocated to the
vector remains available for growth. See buffer_size .
Read from
column

of `c`

columns when data is in column format. It numbers
the columns beginning from 1.
`nc`

The scan takes place at the current position of the file.

Return value is number of items read.

Vector

`n = vec.scantil(fileobj, sentinel)`

`n = vec.scantil(fileobj, sentinel, c, nc)`

Read from
column

of `c`

columns when data is in column format. It numbers
the columns beginning from 1. The scan stops when the sentinel is found in
any position prior to column c+1 but it is recommended that the sentinel
appear by itself on its own line. The file pointer is left at the
character following the sentinel.
`nc`

The scan takes place at the current position of the file.

Return value is number of items read.

Vector

`obj = vec.plot(``graphobj`)

`obj = vec.plot(``graphobj`, `color`, `brush`)

`obj = vec.plot(``graphobj`, `x_vec`)

`obj = vec.plot(``graphobj`, `x_vec`, `color`, `brush`)

`obj = vec.plot(``graphobj`, `x_increment`)

`obj = vec.plot(``graphobj`, `x_increment`, `color`, `brush`)

`x_vec`

, in which case its values are used for x values, or
a scalar, `x_increment`

, in
which case x is incremented according to this number.
This function plots the
`vec`

values that exist in the vector at the time of graph flushing or window
resizing. The alternative is `vec.line()`

which plots the vector values
that exist at the time of the call to `plot`

. It is therefore possible with
`vec.line()`

to produce multiple plots
on the same graph.

Once a vector is plotted, it is only necessary to call `graphobj.flush()`

in order to display further changes to the vector. In this way it
is possible to produce rather rapid line animation.

If the vector label is not empty it will be used as the label for the line on the Graph.

Resizing a vector that has been plotted will remove it from the Graph.

The number of points plotted is the minimum of vec.size and x_vec.size at the time vec.plot is called. x_vec is assumed to be an unchanging Vector.

objref vec, g g = new Graph() g.size(0,10,-1,1) vec = new Vector() vec.indgen(0,10, .1) vec.apply("sin") vec.plot(g, .1) xpanel("") xbutton("run", "for i=0,vec.size()-1 { vec.rotate(1) g.flush() doNotify()}") xpanel()

Vector

`obj = vec.line(``graphobj`)

`obj = vec.line(``graphobj`, `color`, `brush`)

`obj = vec.line(``graphobj`, `x_vec`)

`obj = vec.line(``graphobj`, `x_vec`, `color`, `brush`)

`obj = vec.line(``graphobj`, `x_increment`)

`obj = vec.line(``graphobj`, `x_increment`, `color`, `brush`)

`.plot()`

except the vector
is The line on a graph is given the label if the label is not empty.

The number of point plotted is the minimum of vec.size and x_vec.size .

objref vec, g g = new Graph() g.size(0,10,-1,1) vec = new Vector() vec.indgen(0,10, .1) vec.apply("sin") for i=0,3 { vec.line(g, .1) vec.rotate(10) }

Vector

`obj = vec.ploterr(``graphobj`, `x_vec`, `err_vec`)

`obj = vec.ploterr(``graphobj`, `x_vec`, `err_vec`, `size`)

`obj = vec.ploterr(``graphobj`, `x_vec`, `err_vec`, `size`, `color`, `brush`)

`vec.line()`

, but plots error bars with size +/- the elements
of vector
`size` sets the width of the seraphs on the error bars to a number
of printer dots.

`brush` sets the width of the plot line. 0=invisible,
1=minimum width, 2=1point, etc.

creates a graph which has x values of 0 through 100 in increments of 10 and y values of 0 through 200 in increments of 20. At each point graphed, vertical error bars are also drawn which are the +/- the length of the square root of the values 0 through 100 in increments of 10. Each error bar has seraphs which are ten printer points wide. The graph is also marked with filled circles 5 printers points in diameter.objref vec, xvec, errvec objref g g = new Graph() g.size(0,100, 0,250) vec = new Vector() xvec = new Vector() errvec = new Vector() vec.indgen(0,200,20) xvec.indgen(0,100,10) errvec.copy(xvec) errvec.apply("sqrt") vec.ploterr(g, xvec, errvec, 10) vec.mark(g, xvec, "O", 5)

Vector

`obj = vec.mark(``graphobj`, `x_vector`)

`obj = vec.mark(``graphobj`, `x_vector`, "`style`")

`obj = vec.mark(``graphobj`, `x_vector`, "`style`", `size`)

`obj = vec.mark(``graphobj`, `x_vector`, "`style`", `size`, `color`, `brush`)

`obj = vec.mark(``graphobj`, `x_increment`)

`obj = vec.mark(``graphobj`, `x_increment`, "`style`", `size`, `color`, `brush`)

`vec.line`

, but instead of connecting by lines, it make marks,
centered at the indicated position, which do not change size when
window is zoomed or resized. The style is a single character
`|,-,+,o,O,t,T,s,S`

where `o,t,s`

stand for circle, triangle, square
and capitalized means filled. Default size is 12 points.

Vector

`newvect` = vsrc.histogram(`low`, `high`, `width`)

`vsrc`

.
Bins run from

to `low`

in divisions of `high`

. Data outside
the range is not binned.
`width`

This function returns a vector that contains the counts in each bin, so while it is
necessary to declare an object reference (`objref newvect`

), it is not necessary
to execute `newvect = new Vector()`

.

The first element of `newvect`

is 0 (`newvect.x[0] = 0`

).
For `ii > 0`

, `newvect.x[ii]`

equals the number of
items
in `vsrc`

whose values lie in the half open interval
`[a,b)`

where `b = low + ii*width`

and `a = b - width`

.
In other words, `newvect.x[ii]`

is the number of items in
`vsrc`

that fall in the bin just below the boundary `b`

.

creates a histogram of the occurrences of random numbers ranging from 0 to 10 in divisions of 0.1.objref interval, hist, rand rand = new Random() rand.negexp(1) interval = new Vector(100) interval.setrand(rand) // random intervals hist = interval.histogram(0, 10, .1) // and for a manhattan style plot ... objref g, v2, v3 g = new Graph() g.size(0,10,0,30) // create an index vector with 0,0, 1,1, 2,2, 3,3, ... v2 = new Vector(2*hist.size()) v2.indgen(.5) v2.apply("int") // v3 = new Vector(1) v3.index(hist, v2) v3.rotate(-1) // so different y's within each pair v3.x[0] = 0 v3.plot(g, v2)

Vector

`obj = vdest.hist(``vsrc`, `low`, `size`, `width`)

`low`

to `low` + `size` * `width`

in divisions of `width`

.
Data outside
the range is not binned.

Vector

`newvect = vsrc.sumgauss(``low`, `high`, `width`, `var`)

`newvect = vsrc.sumgauss(``low`, `high`, `width`, `var`, `weight_vec`)

`histogram`

of not imposing arbitrary bins. `low`

and `high`

set the range of the curve.
`width`

determines the granularity of the
curve. `var`

sets the variance of the gaussians.
The optional argument `weight_vec`

is a vector which should be the same
size as `vec`

and is used to scale or weight the gaussians (default is
for them all to have areas of 1 unit).

This function returns a vector, so while it is
necessary to declare a vector object (`objref `

), it is not necessary
to declare `vectobj`

as a `vectobj``new Vector()`

.

To plot, use `v.indgen(`

for the x-vector argument.
`low`,`high`,`width`)

objref r, data, hist, x, g r = new Random() r.normal(1, 2) data = new Vector(100) data.setrand(r) hist = data.sumgauss(-4, 6, .5, 1) x = new Vector(hist.size()) x.indgen(-4, 6, .5) g = new Graph() g.size(-4, 6, 0, 30) hist.plot(g, x)

Vector

`obj = vdest.smhist(``vsrc`, `start`, `size`, `step`, `var`)

`obj = vdest.smhist(``vsrc`, `start`, `size`, `step`, `var`, `weight_vec`)

`varstart`

and has `varsize`

values in increments of size `varstep`

.
`varvar`

sets the variance of the gaussians.
The optional argument `weight_vec`

is a vector which should be the same size as `vsrc`

and is used to scale or
weight the number of data points at a particular value.

Vector

`newvect = vsrc.ind(``vindex`)

`vsrc`

whose indices are given
by the elements of `vindex`

.

createsobjref vec, vec1, vec2 vec = new Vector(100) vec2 = new Vector() vec.indgen(5) vec2.indgen(49, 59, 1) vec1 = vec.ind(vec2)

`vec1`

to contain the fiftieth through the sixtieth elements of `vec2`

which would have the values 245 through 295 in increments of 5.

Vector

`obj = vsrcdest.addrand(``randobj`)

`obj = vsrcdest.addrand(``randobj`, `start`, `end`)

`randobj`

.
objref vec, g, r vec = new Vector(50) g = new Graph() g.size(0,50,0,100) r = new Random() r.poisson(.2) vec.plot(g) proc race() {local i vec.fill(0) for i=1,300 { vec.addrand(r) g.flush() doNotify() } } race()

Vector

`obj = vdest.setrand(``randobj`)

`obj = vdest.setrand(``randobj`, `start`, `end`)

`randobj`

.

Vector

`obj = vdest.sin(``freq`, `phase`)

`obj = vdest.sin(``freq`, `phase`, `dt`)

`vec`

with frequency `freq`

hz, phase
`phase`

in radians. `dt`

is assumed to be 1 msec unless specified.

Vector

`obj = vsrcdest.apply("``func`")

`obj = vsrcdest.apply("``func`", `start`, `end`)

applies the sin function to the first ten elements of the vectorvec.apply("sin", 0, 9)

`vec`

.

Vector

`x = vsrc.reduce("``func`")

`x = vsrc.reduce("``func`", `base`)

`x = vsrc.reduce("``func`", `base`, `start`, `end`)

`base`

to initialize the value x.
Note that the function name must be in quotes and that the parentheses
are omitted.
returns the value 320.objref vec vec = new Vector() vec.indgen(0, 10, 2) func sq(){ return $1*$1 } vec.reduce("sq", 100)

100 + 0*0 + 2*2 + 4*4 + 6*6 + 8*8 + 10*10 = 320

Vector

`vec.floor()`

Vector

`pythonlist = vec.to_python()`

`pythonlist = vec.to_python(pythonlist)`

`numpyarray = vec.to_python(numpyarray)`

Vector

`vec = vec.from_python(pythonlist)`

`vec = vec.from_python(numpyarray)`