Go to the previous, next chapter.

Vector Operations --- Vector.h

This file defines all operations concerning real vectors and introduces the new data type VECTOR.

Data Type: VECTOR Variable [(Dimension)]
Declares Variable as real vector. The optional parameter Dimension denotes the initial dimension of the vector. If Dimension is missing, no memory is allocated for the vector elements (this will be done after the vector is resized or after the first assignment to the vector).

The basic operations +, -, *, and /, the unary operators + and - as well as +=, -=, *=, and /= are defined for real vectors. Comparisons of real vectors are possible with ==, !=, <, <=, >, and >=. All comparisons are performed componentwise and the result of a vector comparison is true, if it is true for all components. Otherwise the result is FALSE.

If i is an INT expression and v a vector, v(i) denotes the i-th element of the vector.

Additionally, the following functions are provided:

Function: INT Dimension (VECTOR v)
Returns the current dimension of v.

Function: void Resize (VECTOR v, INT i)
Discards the old elements of v and resizes v to contain i elements.

Function: void MakeTemporary (VECTOR v)
Defines v to be a temporary variable. This is only important when the improved memory management is used. The MakeTemporary should be used for any vector variable which is returned as a result of a function. For example:

VECTOR Zeros (INT n)
// Returns a vector of dimension n with zeros as elements
{
  VECTOR t(n);

MakeTemporary (t); Clear (t); return t; }

Caution: If a temporary variable is used on the right-hand part of an assignment, it may loose its contents after the assignment.

See section Configuration, for more information.

Function: void MakePermanent (VECTOR v)
Changes the temporary variable v into a permanent one.

See section Configuration, for details.

Function: void Clear (VECTOR v)
Initializes all elements of v with 0.

Function: void Initialize (VECTOR v, REAL r)
Initializes all elements of v with r.

Function: REAL Sqr (VECTOR v)
Returns the scalar product of v with itself, i.e. a faster form of v*v.

Function: REAL Norm (VECTOR v)
Returns the 2-Norm of v.

Function: REAL Max (VECTOR v)
Returns the maximum of all elements of v.

Function: REAL Min (VECTOR v)
Returns the minimum of all elements of v.