numeric vector

Purpose: discuss what a numeric vector is and why it is beneficial.

BLT is a general extension with lots of useful things. One of the very interesting constructs is a new data type - a numeric vector. One reads in and creates a vector using a BLT C API. This allows you to bypass the overhead of reading large amounts of data into Tcl strings.

The numeric vector is used by BLT for plotting, and thus one avoids some of the problems in trying to plot large amounts of points onto the Tk canvas widget.


RS: Do I understand right that such a thing is like a list, except limited to numbers, and possibly in length also?

AK: AFAIK no limits in the length, except by memory. Beyond that, yes, like lists restricted to numbers. Which translates into a more efficient representation at C level. The interface is command based (one command per vector), and allows access through an associated array too (via traces talking to the C level).

RWT: BLT's vector also has a lot of very efficient numerical support. There are functions for sorting, sampling, searching. And probably the most powerful feature is the expression function. So you can compute vector expressions including multiple vectors (v1 and v2) and scalars (c):

  blt::vector expr {v1 + cos(v2) * $c}

Note that you can use blt::vectors without Tk.