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

fvector(lymb) Math fvector(lymb)

NAME

fvector

SUPERCLASS

object

DESCRIPTION

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

INSTANCE VARIABLES

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

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

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

components are components of a fvector.

MESSAGES

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

dimension? Return the dimension of the fvector.

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 fvectors should be aware of this behavior.

= arguments Set the values of components. If more arguments than the current dimeniosn are given, the fvector 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 "fvector 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 fvector. (The dimension? message returns the number of elements in the fvector.)

normalize! Normalizes fvector using the Euclidean norm definition.

normalized? Returns normalized fvector using the Euclidean norm definition. The fvector 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 fvector's value based upon an input pointer and a count.

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

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

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

EXAMPLE

fvector 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, dvector


Please send comments and suggestions to
consult@rpi.edu