| Prev | Next | Start of Chapter | End of Chapter | Contents | Index | (17 out of 18)

Vector Function


The Vector Function block lets you use a function or procedure as a block in a NeurOn-Line diagram. The block applies the function or procedure to its input vector and passes the result. Specify the name of the routine in the attribute Arithmetic Function.

If Arithmetic Function is a function that takes a numeric argument, the block applies the function to each element in the input vector and passes a vector of the results. If Arithmetic Function is a procedure, the block applies the procedure to the input vector as a whole and passes the resulting vector.

You can use any:

Using a Built-in G2 Function

You can set the attribute Arithmetic Function to any of these built-in G2 functions:

abs
arctan
ceiling
cos
exp
floor
int
ln
log
random
sin
sqrt
tan



The picture below shows a diagram that applies the function exp to each element of a vector.


Using a User-Defined Function

You can use any user-defined function that accepts one quantitative argument and returns one quantitative value. Set the attribute Arithmetic Function to the name of the function.

The picture below shows a diagram that figures the factorial of every element in a vector.


Using a Procedure

You can use a procedure that accepts a vector as an argument and returns a vector. Use a procedure if you want to operate on a vector as a whole, instead of operating on each element individually.

Set the attribute Arithmetic Function to the name of the procedure. The block passes the procedure's return value as its output value. The input vector and output vector can have different lengths. The vectors that the procedure accepts and returns should be of type vector-path-value, which has the superior class float-array and contains the following two additional attributes.

Attribute Type Description
collection-time
float
The collection-time of the block's input vector.
quality
symbol
The quality of the block's input vector.

This diagram contains a Vector Function block with a procedure that creates a two-element vector containing the minimum and maximum values of the input vector.


This is the definition of the procedure.

Using a Tabular Function

You can use the G2 tabular-function-of-1-arg function that accepts one argument and returns a value. Set the attribute Arithmetic Function to the name of your function. The block passes its input value to the function as an argument and passes the function's return value as its output value. If the function cannot evaluate the input value, NeurOn-Line signals an error. For information on a G2 tabular-function-of-1-arg, see the G2 Reference Manual.

This diagram shows a Vector Function block that uses a tabular-function-of-1-arg.


Configuring

This is the configuration panel for Vector Function.


Attribute Description
Arithmetic Function
The function to apply to each element of the input vector.

See Also

For more information on how to use this block, see the pages below.

Click here for more information...
Basic Block Behavior
Vector Function of Two Arguments

| Prev | Next | Start of Chapter | End of Chapter | Contents | Index | (17 out of 18)

Copyright © 1996, Gensym Corporation, Inc.