<<<<<<<<<<<<<<<<<

dvector(lymb) Math dvector(lymb)

NAME

dvector

SUPERCLASS

object

DESCRIPTION

The dvector class is used in LYMB to represent arrays of double precision numbers. Any numeric argument can be an integer, a floating point number, a double precision number, or a string. If a string is given, it must parse as a numeric value.

INSTANCE VARIABLES

dimension is the number of elements, or components, in a dvector.

from is the starting index in a dvector used for assignment and arithmetic operations.

to is the ending index in a dvector used for assignment and arithmetic operations.

components are components of a dvector.

MESSAGES

dimension= argument Set the dimension of a dvector. If not set, the dvector will resize dynamically to fit the data given.

dimension? Return the dimension of the dvector.

end_of_message Reset "from" and "to" of the instance, i.e., set from=1 and to=dimension. End_of_message cannot be sent from a LYMB script. The parser normally sends this when it sees a ";". C programmers who manipulate dvectors should be aware of this behavior.

= arguments Set the values of components. If more arguments than the current dimeniosn are given, the dvector is resized dynamically. If the number of arguments is less than (to - from + 1), they are reused in a circular fashion. The same applies to messages "+", "-", and "components=".

* arguments Multiply components of an instance by the list of arguments on a component-by-component basis. If the

argument list is shorter that the number of members between from and to, it is reused cyclically. For instance, executing "dvector new: v = (1,2,3) * 2;" would result in v' component values being (2,4,6), not (2,2,3).

/ arguments Divide components of an instance by the list of arguments on a component-by-component basis. If the argument list is shorter that the number of members between from and to, it is reused cyclically.

- arguments Subtract elements of the argument list from the instance members on a component-by-component basis. If the argument list is shorter that the number of members between from and to, it is reused cyclically.

+ arguments Add elements of the argument list to the instance members on a component-by-component basis. If the argument list is shorter that the number of members between from and to, it is reused cyclically.

^ arguments Raise each member by the exponent in the list on a component-by-component basis. If the argument list is shorter that the number of members between from and to, it is reused cyclically.

? Return a pointer to components and dimension of an instance, synonym to "pointer?".

components= arguments Set components of an instance (synonym to "=").

components? Return components of an instance.

@ argument Set "from" and "to" to the argument, valid until the next "end_of_message".

from: argument Set "from" index to the argument, valid until the next "end_of_message".

from? Return "from" index.

to: argument Set "to" index to the argument, valid until the next "end_of_message".

to? Return "to" index.

length? Return the euclidean norm of the dvector. (The dimension? message returns the number of elements in the dvector.)

normalize! Normalizes dvector using the Euclidean norm definition.

normalized? Returns normalized dvector using the Euclidean norm definition. The dvector remains unchanged.

trace? Return the sum of the components.

max? Return the maximum element of the components.

min? Return the minimum element of the components.

swap! Reverse the order of components referenced by the "from" and "to" indices.

pointer=(ptr,count) Set the dvector's value based upon an input pointer and a count.

pointer? Return a pointer to the dvector instance's value.

first_set? Returns the index of first non-zero element of the dvector. From and to bound the search.

last_set? Returns the index of last non-zero element of the dvector. From and to bound the search.

EXAMPLE

dvector new: v1 dimension=10; -- print only four components v1 from:4 to: 7 = (1,2,3,4) print:components; v1 print: components; -- will print all 10 components

SEE ALSO

vector, fvector, ivector


Please send comments and suggestions to
consult@rpi.edu