VThis page describes the BLT vectors, commane-dime, nsionalt arraysthe concept of a vector in generalues.
[[howA doesBLT a vector is a one-diffmernsional fordered set omf reanl anumberray?]]s.
2006-10-30,[Jaf]: I'd rath**Ver think of a list as a vector thcommand of ain array as a vector. [BLT]**
A*** vector has aSyn imoplicit association of its contents to the base vectors, e.g., first number of the vector is the first coordinate that says "how many" of the first vector from the base are within the vector we are looking at. ***
Reading this again I: think I mad'''ve ict more obscure than ite''' w''vecNas.me But I ?vecNan'tme find...? ano?switchers?''
w : '''vector ding,estroy''' if''vecName on?vecName of...?''
you would s: '''vector expr''' ''expression''
f : '''vector hnamels''' ?''p....attern''?
As*** for thDe reprensentation of vectors inside a program, well, either lists or arrays can be used;
I think it depends on what one wants to do with the vector elements. ***
Creates a vector of floating----
**Vpoint values. Each vector is also a Tcl command (''vecName''), winth [BLa T]**
[[ncl array variable accedss dto elements. Vectoris support math expressions and can feed [BLT]] graph, barchart, stripchart elements.
: '''vector create''' ''vecName ?vecName ...? ?switches?'' : Create vectors. ''vecName'' may be ''name'', ''name(size)'', ''name(first:last)''. Returns name(s).
* '''-variable''' ''varName'' : Tcl array variable bound to vector. Empty string = none.
* '''-command''' ''cmdName'' : Tcl command name for vector. Empty string = none.
* '''-watchunset''' ''boolean'' : Destroy vector when its variable is unset.
: '''vector destroy''' ''vecName ?vecName ...?'' : Destroy vectors, their commands and variables.
: '''vector expr''' ''expression'' : Evaluate vector expression, return result as list.
: '''vector names''' ?''pattern''? : List vectors, optionally matching glob ''pattern''.
*** Vector Operations ***
: '''vecName append''' ''item ?item ...?'' : Append vectors or lists of values to end.
: '''vecName binread''' ''channel ?numValues? ?flags?'' : Read binary values from open ''channel''. Flags: '''-swap''', '''-format''' ''fmt''.
: '''vecName clear''' : Clear indices cached in the vector.
: '''vecName delete''' ''index ?index ...?'' : Delete listed indices (or ranges '''first:last''').
: '''vecName dup''' ''destName'' : Copy vector to ''destName''.
: '''vecName expr''' ''expression'' : Evaluate expression, assign result to vector.
: '''vecName length''' ?''newSize''? : Return length, or resize.
: '''vecName merge''' ''vecName ?vecName ...?'' : Merge vectors' values into this one.
: '''vecName normalize''' ?''vecName''? : Scale values to 0..1. Optionally store in ''vecName''.
: '''vecName notify''' ''keyword'' : Control change notification: '''always''', '''never''', '''whenidle''', '''now''', '''cancel''', '''pending'''.
: '''vecName offset''' ?''value''? : Get/set index offset for the vector.
: '''vecName populate''' ''destName ?density?'' : Fill ''destName'' with values interpolated between this vector's points.
: '''vecName random''' ?''seed''? : Fill with random values 0..1.
: '''vecName range''' ''first ?last?'' : Return values from ''first'' to ''last'' as list.
: '''vecName search''' ?'''-value'''? ''value ?value?'' : Return indices where value (or range) found.
: '''vecName seq''' ''start ?finish? ?step?'' : Fill with sequence of values.
: '''vecName set''' ''item'' : Set values from list, vector, or expression result.
: '''vecName sort''' ?'''-reverse'''? ''?vecName ...?'' : Sort ascending; other vectors reordered alike.
: '''vecName split''' ?''vecName ...?'' : Split into vectors (even/odd indices etc.).
: '''vecName variable''' ?''varName''? : Get/set bound array variable.
*** Indexing ***
* '''vecName(3)''' : single element.
* '''vecName(2:5)''' : range.
* '''vecName(min)''', '''vecName(max)''' : index of smallest/largest value.
* '''vecName(end)''' : last element. '''vecName(++end)''' : append new element.
*** Math Functions ***
Usable in [expr] and vector expressions:
* Element-wise: abs acos asin atan ceil cos cosh exp floor log log10 random round sin sinh sqrt tan tanh
* Reduce to scalar: adev kurtosis length max mean median min norm prod q1 q3 sdev skew sum var
* Vector-valued: sort
** Example **
======
vector create x y -variable ""
x seq 0 10 0.5
y expr {sin(x)}
set m [vector expr max(y)]
======
----
**Related pages**
* [Vector or matrix algebra in Tcl]
* [Low-level vector data in Tcl] * [VecTcl]
* [Vkit is a vector engine]
* [vector.tk]
* [Feather VectorObj]
* [vexpr - an expr for vectors] (3d vectors)
* [vector arithmetics]
* [bit vectors]
In [pure-Tcl], lists are most appropriate for representing vectors.
<<categories>> Data Structure | Command