cta_vector.h File Reference

Interface description of the default COSTA vector componennt. For user implementation see cta_usr_vector.h. More...

#include "cta_system.h"
#include "cta_handles.h"
#include "cta_datatypes.h"
#include "cta_functions.h"

Go to the source code of this file.

Defines

#define I_CTA_VECTOR_CREATE_SIZE   ( 1)
#define I_CTA_VECTOR_CREATE_INIT   ( 2)
#define I_CTA_VECTOR_GETVALS   ( 3)
#define I_CTA_VECTOR_SETVALS   ( 4)
#define I_CTA_VECTOR_SETCONST   ( 5)
#define I_CTA_VECTOR_SCAL   ( 6)
#define I_CTA_VECTOR_COPY   ( 7)
#define I_CTA_VECTOR_AXPY   ( 8)
#define I_CTA_VECTOR_DOT   ( 9)
#define I_CTA_VECTOR_NRM2   (10)
#define I_CTA_VECTOR_AMAX   (11)
#define I_CTA_VECTOR_GETMAXLEN   (12)
#define I_CTA_VECTOR_FREE   (13)
#define I_CTA_VECTOR_GETVAL   (14)
#define I_CTA_VECTOR_SETVAL   (15)
#define I_CTA_VECTOR_EXPORT   (16)
#define I_CTA_VECTOR_PRINT_TABLE   (17)
#define I_CTA_VECTOR_APPENDVAL   (18)
#define I_CTA_VECTOR_ELMDIV   (19)
#define I_CTA_VECTOR_IMPORT   (20)
#define I_CTA_VECTOR_ELMPROD   (21)
#define I_CTA_VECTOR_ELMSQRT   (22)
#define I_CTA_VECTOR_NUMFUNC   (23)

Typedefs

typedef CTA_Handle CTA_Vector
typedef CTA_Handle CTA_VecClass

Functions

CTAEXPORT int CTA_Vector_DefineClass (const char *name, const CTA_Func h_func[I_CTA_VECTOR_NUMFUNC], CTA_VecClass *hveccl)
 Create a new class (=implementation) of a COSTA vector component.
CTAEXPORT int CTA_Vector_Duplicate (CTA_Vector hvector1, CTA_Vector *hvector2)
 Duplicate a vector object.
CTAEXPORT int CTA_Vector_Create (CTA_VecClass hveccl, const int n, CTA_Datatype datatype, CTA_Handle userdata, CTA_Vector *hvector)
 Create a new vector.
CTAEXPORT int CTA_Vector_GetSize (CTA_Vector hvec, int *n)
 Get size of vector.
CTAEXPORT int CTA_Vector_GetVal (CTA_Vector hvec, int i, void *vals, CTA_Datatype datatype)
 Get a copy of a single element in the vector.
CTAEXPORT int CTA_Vector_GetVals (CTA_Vector hvec, void *vals, int n, CTA_Datatype datatype)
 Get a copy of all elements in the vector.
CTAEXPORT int CTA_Vector_SetVal (CTA_Vector hvec, int i, void *val, CTA_Datatype datatype)
 Set a copy of an element in the vector.
CTAEXPORT int CTA_Vector_AppendVal (CTA_Vector hvec, const void *val, CTA_Datatype datatype)
 Append a copy of an element to a vector.
CTAEXPORT int CTA_Vector_SetVals (CTA_Vector hvec, void *vals, int n, CTA_Datatype datatype)
 Set all elementes in the vector.
CTAEXPORT int CTA_Vector_Scal (CTA_Vector hvec, double alpha)
 Scale a vector.
CTAEXPORT int CTA_Vector_Copy (CTA_Vector hvec_x, CTA_Vector hvec_y)
 Copy a vector.
CTAEXPORT int CTA_Vector_Axpy (CTA_Vector hvec_y, double alpha, CTA_Vector hvec_x)
 Operation axpy for two vectors x and y.
CTAEXPORT int CTA_Vector_Dot (CTA_Vector hvec_x, CTA_Vector hvec_y, double *dotprod)
 Dot product operation of two vectors.
CTAEXPORT int CTA_Vector_Nrm2 (CTA_Vector hvec_x, double *norm2)
 Compute 2-norm of vector.
CTAEXPORT int CTA_Vector_Amax (CTA_Vector hvec_x, int *iloc)
 Find index of element in vector with largest absolute value.
CTAEXPORT int CTA_Vector_GetMaxLen (CTA_Vector hvec_x, int *maxlen)
 Find largest length of elements in vector.
CTAEXPORT int CTA_Vector_Export (CTA_Vector hvec, CTA_Handle usrdata)
 Export a vector to file, stdout or pack object.
CTAEXPORT int CTA_Vector_Import (CTA_Vector hvec, CTA_Handle usrdata)
 Import a vector.
CTAEXPORT int CTA_Vector_Print_Table (CTA_Vector *table, int ncolumns, CTA_Vector vformats)
 Print table, each column built up by a vector.
CTAEXPORT int CTA_Vector_Free (CTA_Vector *hvec_x)
 Free the vector object.
CTAEXPORT int CTA_Vector_GetDatatype (CTA_Vector hvec, CTA_Datatype *datatype)
 Get type of vector.
CTAEXPORT int CTA_Vector_SetConstant (CTA_Vector hvec, void *val, CTA_Datatype datatype)
 Set whole vector to one single value.
CTAEXPORT int CTA_Vector_ElmDiv (CTA_Vector hvec_y, CTA_Vector hvec_x)
 Element wise division.
CTAEXPORT int CTA_Vector_ElmProd (CTA_Vector hvec_y, CTA_Vector hvec_x)
 Element wise product.
CTAEXPORT int CTA_Vector_ElmSqrt (CTA_Vector hvec_x)
 Element wise square root.

Detailed Description

Interface description of the default COSTA vector componennt. For user implementation see cta_usr_vector.h.

Basic functions and utilities for vector operations on CTA_VECTOR objects.

Definition in file cta_vector.h.


Define Documentation

#define I_CTA_VECTOR_AMAX   (11)

Definition at line 49 of file cta_vector.h.

#define I_CTA_VECTOR_APPENDVAL   (18)

Definition at line 56 of file cta_vector.h.

#define I_CTA_VECTOR_AXPY   ( 8)

Definition at line 46 of file cta_vector.h.

#define I_CTA_VECTOR_COPY   ( 7)

Definition at line 45 of file cta_vector.h.

#define I_CTA_VECTOR_CREATE_INIT   ( 2)

Definition at line 40 of file cta_vector.h.

#define I_CTA_VECTOR_CREATE_SIZE   ( 1)

Definition at line 39 of file cta_vector.h.

#define I_CTA_VECTOR_DOT   ( 9)

Definition at line 47 of file cta_vector.h.

#define I_CTA_VECTOR_ELMDIV   (19)

Definition at line 57 of file cta_vector.h.

#define I_CTA_VECTOR_ELMPROD   (21)

Definition at line 59 of file cta_vector.h.

#define I_CTA_VECTOR_ELMSQRT   (22)

Definition at line 60 of file cta_vector.h.

#define I_CTA_VECTOR_EXPORT   (16)

Definition at line 54 of file cta_vector.h.

#define I_CTA_VECTOR_FREE   (13)

Definition at line 51 of file cta_vector.h.

#define I_CTA_VECTOR_GETMAXLEN   (12)

Definition at line 50 of file cta_vector.h.

#define I_CTA_VECTOR_GETVAL   (14)

Definition at line 52 of file cta_vector.h.

#define I_CTA_VECTOR_GETVALS   ( 3)

Definition at line 41 of file cta_vector.h.

#define I_CTA_VECTOR_IMPORT   (20)

Definition at line 58 of file cta_vector.h.

#define I_CTA_VECTOR_NRM2   (10)

Definition at line 48 of file cta_vector.h.

#define I_CTA_VECTOR_NUMFUNC   (23)

Definition at line 61 of file cta_vector.h.

#define I_CTA_VECTOR_PRINT_TABLE   (17)

Definition at line 55 of file cta_vector.h.

#define I_CTA_VECTOR_SCAL   ( 6)

Definition at line 44 of file cta_vector.h.

#define I_CTA_VECTOR_SETCONST   ( 5)

Definition at line 43 of file cta_vector.h.

#define I_CTA_VECTOR_SETVAL   (15)

Definition at line 53 of file cta_vector.h.

#define I_CTA_VECTOR_SETVALS   ( 4)

Definition at line 42 of file cta_vector.h.


Typedef Documentation

Definition at line 36 of file cta_vector.h.

Definition at line 35 of file cta_vector.h.


Function Documentation

CTAEXPORT int CTA_Vector_Amax ( CTA_Vector  hvec_x,
int *  iloc 
)

Find index of element in vector with largest absolute value.

Parameters:
hvec_x I handle of vector
iloc O receives index of largest absolute value
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_AppendVal ( CTA_Vector  hvec,
const void *  val,
CTA_Datatype  datatype 
)

Append a copy of an element to a vector.

Note:
The value is copied into the vector, size of vector is increased.
Parameters:
hvec IO handle of vector
val I value that needs to be added to vector
datatype I data type of *val, must be the same as data type of elements in vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Axpy ( CTA_Vector  hvec_y,
double  alpha,
CTA_Vector  hvec_x 
)

Operation axpy for two vectors x and y.

Note:
axpy: y=alpha*x+y
Parameters:
hvec_y IO handle of vector y
alpha I scalar
hvec_x I handle of vector x
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Copy ( CTA_Vector  hvec_x,
CTA_Vector  hvec_y 
)

Copy a vector.

Note:
This function copies the vector content (y=x), but does not make a new vector.
Parameters:
hvec_x I handle of sending vector
hvec_y O handle of receiving vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Create ( CTA_VecClass  hveccl,
const int  n,
CTA_Datatype  datatype,
CTA_Handle  userdata,
CTA_Vector hvector 
)

Create a new vector.

Note:
Parameters:
hveccl I vector class of new vector
n I number of elements
datatype I data type of elements in vector
userdata IO user data for creation (depends on class)
hvector O receives handle of new vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_DefineClass ( const char *  name,
const CTA_Func  h_func[I_CTA_VECTOR_NUMFUNC],
CTA_VecClass hveccl 
)

Create a new class (=implementation) of a COSTA vector component.

Parameters:
name I name of the new vector class
h_func I COSTA function handles for functions that implement class. Missing functions must have value CTA_NULL
hveccl O receives handle of new vector class
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Dot ( CTA_Vector  hvec_x,
CTA_Vector  hvec_y,
double *  dotprod 
)

Dot product operation of two vectors.

Note:
dot: dotprod=x^t*y
Parameters:
hvec_x I handle of vector x
hvec_y I handle of vector y
dotprod O receives dot product
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Duplicate ( CTA_Vector  hvector1,
CTA_Vector hvector2 
)

Duplicate a vector object.

Note:
Only size, data type and type (class) are duplicated, the content is not copied.
Parameters:
hvector1 I handle of vector to be duplicated
hvector2 O receives handle of new duplicate vector, empty before calling
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_ElmDiv ( CTA_Vector  hvec_y,
CTA_Vector  hvec_x 
)

Element wise division.

Note:
y=x./y
Parameters:
hvec_y IO handle of vector y
hvec_x I handle of vector x
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_ElmProd ( CTA_Vector  hvec_y,
CTA_Vector  hvec_x 
)

Element wise product.

Note:
y=x.y
Parameters:
hvec_y IO handle of vector y
hvec_x I handle of vector x
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_ElmSqrt ( CTA_Vector  hvec_x  ) 

Element wise square root.

Note:
y=y.^0.5
Parameters:
hvec_x IO handle of vector y
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Export ( CTA_Vector  hvec,
CTA_Handle  usrdata 
)

Export a vector to file, stdout or pack object.

CTA_DEFAULT_VECTOR supports exporting to:
file (usrdata a handle of COSTA file)
pack object (usrdata a handle of COSTA pack object)

Parameters:
hvec I handle of vector
usrdata I configuration of output
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Free ( CTA_Vector hvec_x  ) 

Free the vector object.

hvec_x=CTA_NULL is allowed

Parameters:
hvec_x IO handle of vector, replaced by CTA_NULL on return
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_GetDatatype ( CTA_Vector  hvec,
CTA_Datatype datatype 
)

Get type of vector.

Parameters:
hvec I handle of vector
datatype O receives data type of vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_GetMaxLen ( CTA_Vector  hvec_x,
int *  maxlen 
)

Find largest length of elements in vector.

Note:
e.g. length of string in a vector of strings
Parameters:
hvec_x I handle of vector
maxlen O receives largest length of elements in vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_GetSize ( CTA_Vector  hvec,
int *  n 
)

Get size of vector.

Parameters:
hvec I handle of vector
n O receives number of elements
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_GetVal ( CTA_Vector  hvec,
int  i,
void *  vals,
CTA_Datatype  datatype 
)

Get a copy of a single element in the vector.

Parameters:
hvec I handle of vector
i I index of element
vals O receives copy of value in vector, must exist before calling
datatype I data type of *vals, must be the same as data type of elements in vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_GetVals ( CTA_Vector  hvec,
void *  vals,
int  n,
CTA_Datatype  datatype 
)

Get a copy of all elements in the vector.

Parameters:
hvec I handle of vector
vals O receives copy of all elements in vector, must exist before calling
n I length of array vals
datatype I data type of *vals, must be the same as data type of elements in vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Import ( CTA_Vector  hvec,
CTA_Handle  usrdata 
)

Import a vector.

Note:
CTA_DEFAULT_VECTOR supports importing from pack object (usrdata[0] a pack handle).
Data type and size of vector can be changed due to this action
Parameters:
hvec I handle of vector
usrdata I configuration of output
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Nrm2 ( CTA_Vector  hvec_x,
double *  norm2 
)

Compute 2-norm of vector.

Note:
2-norm: sqrt(x^t*x)
Parameters:
hvec_x I handle of vector x
norm2 O receives 2-norm
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Print_Table ( CTA_Vector table,
int  ncolumns,
CTA_Vector  vformats 
)

Print table, each column built up by a vector.

Note:
CTA_DEFAULT_VECTOR TODO
Parameters:
table I array of vector handles, these vectors form the table to be filled
ncolumns I number of columns in table (number of vector handles in table)
vformats I handle of vector of string (size ncolumns) containing the formats for printing each column (C-format)
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_Scal ( CTA_Vector  hvec,
double  alpha 
)

Scale a vector.

Note:
scale: x=alpha*x
Parameters:
hvec IO handle of vector
alpha I scalar
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_SetConstant ( CTA_Vector  hvec,
void *  val,
CTA_Datatype  datatype 
)

Set whole vector to one single value.

hvec=CTA_NULL is allowed, function returns error code

Parameters:
hvec IO handle of vector
val I value that must be set
datatype I data type of *val, must be the same as data type of elements in vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_SetVal ( CTA_Vector  hvec,
int  i,
void *  val,
CTA_Datatype  datatype 
)

Set a copy of an element in the vector.

Note:
The value is copied in the vector.
Parameters:
hvec IO handle of vector
i I index of element
val I new value that is copied into element at given index
datatype I data type of *val, must be the same as data type of elements in vector
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Vector_SetVals ( CTA_Vector  hvec,
void *  vals,
int  n,
CTA_Datatype  datatype 
)

Set all elementes in the vector.

Note:
The values are copied in the vector.
Parameters:
hvec IO handle of vector
vals I values that need to be copied to vector
n I number of elements in vals
datatype I data type of *vals, must be the same as data type of elements in vector
Returns:
error status: CTA_OK if successful

Generated on 4 Mar 2014 for OpenDA by  doxygen 1.6.1