** Next:** Index
**Up:** Manual Pages
** Previous:** RTC(3LAS)

` V_Constr`, ` V_Destr`,
` V_SetName`, ` V_GetName`,
` V_GetDim`,
` V_SetCmp`, ` V_SetAllCmp`, ` V_SetRndCmp`, ` V_GetCmp`,
` V_AddCmp`,
` V__SetCmp`, ` V__GetCmp`, ` V__AddCmp`,
` V_Lock`, ` V_Unlock`
-- type ` Vector`

#include <laspack/vector.h>
typedef double Real;
typedef enum {
Normal,
Tempor
} InstanceType;
void V_Constr(Vector *V, char *Name, size_t Dim, InstanceType Instance,
Boolean OwnData);
void V_Destr(Vector *V);
void V_SetName(Vector *V, char *Name);
char *V_GetName(Vector *V);
size_t V_GetDim(Vector *V);
void V_SetCmp(Vector *V, size_t Ind, Real Val);
void V_SetAllCmp(Vector *V, Real Val);
void V_SetRndCmp(Vector *V, Real Val);
Real V_GetCmp(Vector *V, size_t Ind);
void V_AddCmp(Vector *V, size_t Ind, Real Val);
void V__SetCmp(Vector *V, size_t Ind, Real Val);
Real V__GetCmp(Vector *V, size_t Ind);
void V__AddCmp(Vector *V, size_t Ind, Real Val);
void V_Lock(Vector *V);
void V_Unlock(Vector *V);

######

The procedure ` V_Constr` is the constructor of the type ` Vector`.
It creates and initializes a new variable of this type directed
by the parameter ` V`.
As symbolic name, the string ` Name` is used.
The dimensions of the vector are defined by ` Dim`.
For vectors used in application codes,
one should always use the parameters
` Instance = Normal` and ` OwnData = True`.
In this case, ` V_Constr` allocates memory for vector components.
Other parameter combinations for ` Instance` and ` OwnData`
are intended for internal usage by ` LASPack`
.

######

The procedure ` V_Destr` is the destructor of type ` Vector`.
It releases memory of vector components.

######

The procedure ` V_SetName` resets the symbolic name of the vector.
This can be queried by the procedure ` V_GetName`.

######

The procedure ` V_GetDim` returns the dimension of the vector.

######

The procedure ` V_SetCmp` assigns
the value ` Val` to the vector component with index ` Ind`.
The procedure ` V_SetAllCmp` sets all components to the value ` Val`.
The procedure ` V_SetRndCmp` initialize vector components
to normalized random values ` (0 <= V[i] < 1)`.
As random-number generator, the ANSI C function ` rand` is used.
The starting point can be specified by a call of function ` srand`.

######

The procedure ` V_GetCmp` returns the value of the vector component
with index ` Ind`.

######

The procedure ` V_AddCmp` adds the value ` Val`
to the vector component with index ` Ind`.

######

The procedures ` V__SetCmp`, ` V__GetCmp` and ` V__AddCmp`
have the same functionality as
the routines ` V_SetCmp`, ` V_GetCmp` and ` V_AddCmp`.
They are designed as preprocessing macros and are thus essentially faster.
Because no range check is made they should not be used in the test
phase of application code.

######

In subroutines, the procedure ` V_Lock` should be applied
to all passed parameters of the type ` Vector`.
This ensures that,
if they are of temporary kind,
they are not released within any ` LASPack`
routine
before the procedure is leaved.
This should be carried out by a call of ` V_Unlock`
which have to be called at the end of the procedure.

` vector.h ... ` header file

` vector.c ... ` source file

The vector
` ( 1 2 3 4 5 )^T`
could be generated as follows:

Vector a;
size_t Ind;
...
V_Constr(&a, "a", 5, Normal, True);
for (Ind = 1; Ind <= 5; Ind++)
V_SetCmp(&a, Ind, (double)Ind);
...
V_Destr(&a);

rand(3C), srand(3C),
operats(3LAS), errhandl(3LAS)

** Next:** Index
**Up:** Manual Pages
** Previous:** RTC(3LAS)

Tomas Skalicky (skalicky@msmfs1.mw.tu-dresden.de)