Interface description of the COSTA default tree-vector component. More...
#include "cta_system.h"
#include "cta_datatypes.h"
#include "cta_handles.h"
#include "cta_vector.h"
#include "cta_matrix.h"
#include "cta_metainfo.h"
Go to the source code of this file.
Typedefs | |
typedef CTA_Handle | CTA_TreeVector |
Functions | |
CTAEXPORT int | CTA_TreeVector_Create (const char *name, const char *tag, CTA_TreeVector *treevec) |
Create a tree-vector. | |
CTAEXPORT int | CTA_TreeVector_Duplicate (CTA_TreeVector treevec1, CTA_TreeVector *treevec2) |
Duplicate a tree-vector. | |
CTAEXPORT int | CTA_TreeVector_Conc (CTA_TreeVector treevec1, CTA_TreeVector *treevecs, int ntreevecs) |
Define a tree-vector to be a concatination of other tree-vectors. | |
CTAEXPORT int | CTA_TreeVector_GetSubTreeVec (CTA_TreeVector treevec, const char *tag, CTA_TreeVector *subtreevec) |
Get the handle of a sub-tree-vectors using its tag. | |
CTAEXPORT int | CTA_TreeVector_GetSubTreeVecId (CTA_TreeVector treevec, int index, char tag[CTA_STRLEN_TAG]) |
Get the tag of a sub-tree-vector using its index (starting with 0). | |
CTAEXPORT int | CTA_TreeVector_GetSubTreeVecIndex (CTA_TreeVector treevec, int index, CTA_TreeVector *subtreevec) |
Get the handle of a first-layer sub-tree-vector using its index. | |
CTAEXPORT int | CTA_TreeVector_GetNumSubTree (CTA_TreeVector treevec, int *numSubTrees) |
Get number of sub-treevectors. | |
CTAEXPORT int | CTA_TreeVector_GetTag (CTA_TreeVector treevec, char *tag) |
Get the tag of the tree-vector. | |
CTAEXPORT int | CTA_TreeVector_SetVec (CTA_TreeVector treevec, CTA_Vector hvec) |
Set the values of the tree-vector. | |
CTAEXPORT int | CTA_TreeVector_GetVec (CTA_TreeVector treevec, CTA_Vector hvec) |
Get the values of the tree-vector. | |
CTAEXPORT int | CTA_TreeVector_Axpy (CTA_TreeVector y, double alpha, CTA_TreeVector x) |
Axpy operation between two tree-vectors. | |
CTAEXPORT int | CTA_TreeVector_Dot (CTA_TreeVector treevec1, CTA_TreeVector treevec2, double *dotprod) |
Compute dot product of two tree-vectors. | |
CTAEXPORT int | CTA_TreeVector_Nrm2 (CTA_TreeVector treevec1, double *nrm2) |
Compute the 2-norm of a tree-vector. | |
CTAEXPORT int | CTA_TreeVector_Copy (CTA_TreeVector treevec1, CTA_TreeVector treevec2) |
Copy a tree-vector. | |
CTAEXPORT int | CTA_TreeVector_SetConstant (CTA_TreeVector treevec, void *val, CTA_Datatype datatype) |
Set whole tree-vector equal to a constant value. | |
CTAEXPORT int | CTA_TreeVector_Scal (CTA_TreeVector treevec, double alpha) |
Scale tree-vector. | |
CTAEXPORT int | CTA_TreeVector_SetVals (CTA_TreeVector treevec, void *val, int nval, CTA_Datatype datatype) |
Set all values of the tree-vector. | |
CTAEXPORT int | CTA_TreeVector_GetVals (CTA_TreeVector treevec, void *val, int nval, CTA_Datatype datatype) |
Get all values of the tree-vector. | |
CTAEXPORT int | CTA_TreeVector_SetVal (CTA_TreeVector treevec, int i, void *val, CTA_Datatype datatype) |
Set single value of the tree-vector. | |
CTAEXPORT int | CTA_TreeVector_GetVal (CTA_TreeVector treevec, int i, void *val, CTA_Datatype datatype) |
Get single value of the tree-vector. | |
CTAEXPORT int | CTA_TreeVector_GetSize (CTA_TreeVector treevec, int *n) |
Get size of tree-vector. | |
CTAEXPORT int | CTA_TreeVector_Export (CTA_TreeVector treevec, CTA_Handle usrdata) |
Export tree-vector. | |
CTAEXPORT int | CTA_TreeVector_Import (CTA_TreeVector treevec, CTA_Handle usrdata) |
Import Tree-vector. | |
CTAEXPORT int | CTA_TreeVector_VImport (CTA_TreeVector treevec, CTA_Handle usrdata) |
Import Tree-vector as flat vector. | |
CTAEXPORT int | CTA_TreeVector_Free (CTA_TreeVector *treevec, int recursive) |
Free Tree-vector. | |
CTAEXPORT int | CTA_TreeVector_Info (CTA_TreeVector treevec) |
Print tree-vector information. | |
CTAEXPORT int | CTA_TreeVector_Gemm (CTA_TreeVector *sC, int nc, int transa, int transb, double alpha, CTA_TreeVector *sA, int na, CTA_Matrix mB, double beta) |
Perform the matrix multiplication C:=alpha*op(A)*op(B)+beta*C where op(X)=X, X^T. However C and A are matrices of wich the columns are tree-vectors. | |
CTAEXPORT void | CTAI_XML_WriteTreeVec (CTA_TreeVector treevec, xmlTextWriter *writer) |
Generate XML from one COSTA tree-vector. | |
CTAEXPORT CTA_TreeVector | CTAI_XML_CreateTreeVec (xmlNode *cur_node) |
Create a COSTA tree-vector from XML. | |
CTAEXPORT int | CTA_TreeVector_OpOnLeafs (CTA_TreeVector treevec1, CTA_TreeVector treevec2, CTA_Func op, CTA_Handle arg) |
Perform given operation on all leafs of the treevector. | |
CTAEXPORT int | CTA_TreeVector_ElmDiv (CTA_TreeVector y, CTA_TreeVector x) |
Elementwise division of two vectors. | |
CTAEXPORT int | CTA_TreeVector_ElmProd (CTA_TreeVector y, CTA_TreeVector x) |
Elementwise multiplication of two vectors. | |
CTAEXPORT int | CTA_TreeVector_ElmSqrt (CTA_TreeVector y) |
Elementwise sqare root. | |
CTAEXPORT int | CTA_TreeVector_SetSubTreeNocompute (CTA_TreeVector x, const char *tag) |
Set nocompute flag of a sub-tree vector. | |
CTAEXPORT int | CTA_TreeVector_IncRefCount (CTA_TreeVector treevec) |
Increase the reference count of a treevector and all subtrevectors. | |
CTAEXPORT int | CTA_TreeVector_SetMetainfo (CTA_TreeVector treevec, CTA_Metainfo minfo) |
CTAEXPORT int | CTA_TreeVector_GetMetainfo (CTA_TreeVector treevec, CTA_Metainfo minfo) |
CTAEXPORT int | CTAI_TreeVec_GetVecNumHandles (CTA_TreeVector treevec) |
CTAEXPORT int | CTAI_TreeVec_List (CTA_TreeVector treevec, CTA_Vector taglist, int *indx) |
CTAEXPORT int | CTA_TreeVector_List (CTA_TreeVector treevec, CTA_Vector taglist) |
CTAEXPORT int | CTA_TreeVector_GetVecNumHandles (CTA_TreeVector treevec) |
CTAEXPORT void | CTAI_Treevector_Operation_ScaledRMS (char *tag, CTA_Vector v1, CTA_Vector vscal, CTA_Handle hdum, int *retval) |
CTAEXPORT void | CTAI_Treevector_Operation_Amax (char *tag, CTA_Vector v1, CTA_Vector *v2, CTA_Handle hdum, int *retval) |
CTAEXPORT void | CTAI_Treevector_Operation_PrintEntry (char *tag, CTA_Vector v1, CTA_Vector v2, CTA_Handle hdum, int *retval) |
CTAEXPORT void | CTAI_Treevector_Operation_ScaledSSQ (char *tag, CTA_Vector v1, CTA_Vector vscal, CTA_Handle hdum, int *retval) |
CTAEXPORT void | CTAI_Treevector_Operation_MaxAbs (char *tag, CTA_Vector v1, CTA_Vector, CTA_Handle hdum, int *retval) |
Interface description of the COSTA default tree-vector component.
The tree-vector is an extension of a vector component. A tree-vector either contains a single vector or is a concatenation of a number of tree-vectors, called sub-tree-vectors in this context. The usage of sub-tree-vectors makes is possible to concatenate models or extend models as is done when a deterministic model is extended into a stochastic model. The sub-tree-vectors are also very useful inside the model source code where the whole state of the model is not represented by a single vector. The default tree-vector component uses COSTA vector-components for storing the values.
Each (sub-)tree-vector has a tag. Tree-vectors having the same tag are considered to be the same, meaning they have the same buildup in sub-tree-vectors, length and datatypes.
Definition in file cta_treevector.h.
typedef CTA_Handle CTA_TreeVector |
Type definition of a handle to a COSTA tree-vector instance
Definition at line 50 of file cta_treevector.h.
CTAEXPORT int CTA_TreeVector_Axpy | ( | CTA_TreeVector | y, | |
double | alpha, | |||
CTA_TreeVector | x | |||
) |
Axpy operation between two tree-vectors.
y | IO Tree-vector (y) | |
alpha | I scalar | |
x | I Tree-vector (x) |
CTAEXPORT int CTA_TreeVector_Conc | ( | CTA_TreeVector | treevec1, | |
CTA_TreeVector * | treevecs, | |||
int | ntreevecs | |||
) |
Define a tree-vector to be a concatination of other tree-vectors.
treevec1 | I tree-vector that will be concatenation of the sub-tree-vectors provided in parameter treevecs | |
treevecs | I array of the sub-tree-vectors | |
ntreevecs | I number of sub-tree-vectors in treevecs |
CTAEXPORT int CTA_TreeVector_Copy | ( | CTA_TreeVector | treevec1, | |
CTA_TreeVector | treevec2 | |||
) |
Copy a tree-vector.
treevec1 | I sending tree-vector | |
treevec2 | O receiving tree-vector |
CTAEXPORT int CTA_TreeVector_Create | ( | const char * | name, | |
const char * | tag, | |||
CTA_TreeVector * | treevec | |||
) |
Create a tree-vector.
name | I name of the tree-vector, this is a human readable string used for (debug) output and not by the algorithms itself | |
tag | I tag of this tree-vector | |
treevec | O new tree-vector |
CTAEXPORT int CTA_TreeVector_Dot | ( | CTA_TreeVector | treevec1, | |
CTA_TreeVector | treevec2, | |||
double * | dotprod | |||
) |
Compute dot product of two tree-vectors.
treevec1 | I first tree-vector | |
treevec2 | I second tree-vector | |
dotprod | O receives the dot product |
CTAEXPORT int CTA_TreeVector_Duplicate | ( | CTA_TreeVector | treevec1, | |
CTA_TreeVector * | treevec2 | |||
) |
Duplicate a tree-vector.
treevec1 | I handle of treevector to be duplicated | |
treevec2 | O receives handle to duplicate |
CTAEXPORT int CTA_TreeVector_ElmDiv | ( | CTA_TreeVector | y, | |
CTA_TreeVector | x | |||
) |
Elementwise division of two vectors.
y | I handle of a COSTA tree-vector (y) | |
x | I handle of a COSTA tree-vector (y) |
CTAEXPORT int CTA_TreeVector_ElmProd | ( | CTA_TreeVector | y, | |
CTA_TreeVector | x | |||
) |
Elementwise multiplication of two vectors.
y | I handle of a COSTA tree-vector (y) | |
x | I handle of a COSTA tree-vector (y) |
CTAEXPORT int CTA_TreeVector_ElmSqrt | ( | CTA_TreeVector | y | ) |
Elementwise sqare root.
y | I handle of a COSTA tree-vector (y) |
CTAEXPORT int CTA_TreeVector_Export | ( | CTA_TreeVector | treevec, | |
CTA_Handle | usrdata | |||
) |
Export tree-vector.
Can export tree-vector to file or pack object.
usrdata must contain a handle of the file or pack object to be used.
Dependency: CTA_Vector_Export()
treevec | I Tree-vector | |
usrdata | I export properties |
CTAEXPORT int CTA_TreeVector_Free | ( | CTA_TreeVector * | treevec, | |
int | recursive | |||
) |
Free Tree-vector.
treevec | I handle of tree-vector | |
recursive | I also free all sub-tree-vectors, yes: CTA_TRUE or no: CTA_FALSE |
CTAEXPORT int CTA_TreeVector_Gemm | ( | CTA_TreeVector * | sC, | |
int | nc, | |||
int | transa, | |||
int | transb, | |||
double | alpha, | |||
CTA_TreeVector * | sA, | |||
int | na, | |||
CTA_Matrix | mB, | |||
double | beta | |||
) |
Perform the matrix multiplication C:=alpha*op(A)*op(B)+beta*C where op(X)=X, X^T. However C and A are matrices of wich the columns are tree-vectors.
sC | IO array of tree-vector (matrix C) | |
nc | I number of columns of C (dimension of sC) | |
transa | I transpose flag CTA_TRUE/CTA_FALSE for matrix A (not supported) | |
transb | I transpose flag CTA_TRUE/CTA_FALSE for matrix B | |
alpha | I scalar | |
sA | I handle of matrix A | |
na | I number of columns of A (dimension of sA) | |
mB | I handle of matrix B | |
beta | I scalar |
CTAEXPORT int CTA_TreeVector_GetMetainfo | ( | CTA_TreeVector | treevec, | |
CTA_Metainfo | minfo | |||
) |
CTAEXPORT int CTA_TreeVector_GetNumSubTree | ( | CTA_TreeVector | treevec, | |
int * | numSubTrees | |||
) |
Get number of sub-treevectors.
treevec | I Tree-vector | |
numSubTrees | O Number of sub-treevectors |
CTAEXPORT int CTA_TreeVector_GetSize | ( | CTA_TreeVector | treevec, | |
int * | n | |||
) |
Get size of tree-vector.
treevec | I Tree-vector | |
n | O receives size of tree-vector |
CTAEXPORT int CTA_TreeVector_GetSubTreeVec | ( | CTA_TreeVector | treevec, | |
const char * | tag, | |||
CTA_TreeVector * | subtreevec | |||
) |
Get the handle of a sub-tree-vectors using its tag.
treevec | I Tree-vector | |
tag | I tag of the requested sub-tree-vector | |
subtreevec | O receives handle of the requested sub-tree-vectors, this is by reference, not a copy |
CTAEXPORT int CTA_TreeVector_GetSubTreeVecId | ( | CTA_TreeVector | treevec, | |
int | index, | |||
char | tag[CTA_STRLEN_TAG] | |||
) |
Get the tag of a sub-tree-vector using its index (starting with 0).
treevec | I Tree-vector | |
index | I index of the requested sub-tree-vector | |
tag | O String of standard length containnig the tag |
CTAEXPORT int CTA_TreeVector_GetSubTreeVecIndex | ( | CTA_TreeVector | treevec, | |
int | index, | |||
CTA_TreeVector * | subtreevec | |||
) |
Get the handle of a first-layer sub-tree-vector using its index.
treevec | I Tree-vector | |
index | I index of requested sub-tree-vector. Note that the first sub-tree-vector has index 1. | |
subtreevec | O receives handle of the requested sub-tree-vector, this is by reference, not a copy |
CTAEXPORT int CTA_TreeVector_GetTag | ( | CTA_TreeVector | treevec, | |
char * | tag | |||
) |
Get the tag of the tree-vector.
Note tag should be large enough to hold the result length of CTA_STRLEN_TAG is always save (no internal protection)
treevec | I Tree-vector | |
tag | O receives the tag of the requested sub-tree-vector (see note) |
CTAEXPORT int CTA_TreeVector_GetVal | ( | CTA_TreeVector | treevec, | |
int | i, | |||
void * | val, | |||
CTA_Datatype | datatype | |||
) |
Get single value of the tree-vector.
treevec | I Tree-vector | |
i | I index in value in tree-vector | |
val | O returned value | |
datatype | I data type of *val, must be the same as data type of element in tree-vector |
CTAEXPORT int CTA_TreeVector_GetVals | ( | CTA_TreeVector | treevec, | |
void * | val, | |||
int | nval, | |||
CTA_Datatype | datatype | |||
) |
Get all values of the tree-vector.
treevec | I Tree-vector | |
val | O receives the values | |
nval | I number of elements in val | |
datatype | I data type of *val, must be the same as data type of elements in tree-vector |
CTAEXPORT int CTA_TreeVector_GetVec | ( | CTA_TreeVector | treevec, | |
CTA_Vector | hvec | |||
) |
Get the values of the tree-vector.
treevec | I Tree-vector | |
hvec | O Vector that is receiving the values; must exist before calling |
CTAEXPORT int CTA_TreeVector_GetVecNumHandles | ( | CTA_TreeVector | treevec | ) |
CTAEXPORT int CTA_TreeVector_Import | ( | CTA_TreeVector | treevec, | |
CTA_Handle | usrdata | |||
) |
Import Tree-vector.
Can import tree-vector from file or pack object.
usrdata must contain a handle of the file or pack object to be used.
Dependency: CTA_Vector_Import()
treevec | I Tree-vector | |
usrdata | I import properties |
CTAEXPORT int CTA_TreeVector_IncRefCount | ( | CTA_TreeVector | treevec | ) |
Increase the reference count of a treevector and all subtrevectors.
treevec | I handle of a COSTA tree-vector |
CTAEXPORT int CTA_TreeVector_Info | ( | CTA_TreeVector | treevec | ) |
Print tree-vector information.
Gives following information:
Tree-vector information:
tag: [tag]
nsubtreevecs: [number of sub-tree-vectors]
If nsubtreevecs > 0: recursively prints all sub-tree-vectors Else prints:
leaf: yes
tree-vector size (leaf)
treevec | I tree-vector |
CTAEXPORT int CTA_TreeVector_List | ( | CTA_TreeVector | treevec, | |
CTA_Vector | taglist | |||
) |
CTAEXPORT int CTA_TreeVector_Nrm2 | ( | CTA_TreeVector | treevec1, | |
double * | nrm2 | |||
) |
Compute the 2-norm of a tree-vector.
treevec1 | I Tree-vector | |
nrm2 | O receives the 2-norm |
CTAEXPORT int CTA_TreeVector_OpOnLeafs | ( | CTA_TreeVector | treevec1, | |
CTA_TreeVector | treevec2, | |||
CTA_Func | op, | |||
CTA_Handle | arg | |||
) |
Perform given operation on all leafs of the treevector.
treevec1 | I handle of first COSTA tree-vector | |
treevec2 | I handle of second COSTA tree-vector | |
treevec | I handle of a COSTA tree-vector | |
op | I operation to perform on the leafs | |
arg | I additional argument of operation |
CTAEXPORT int CTA_TreeVector_Scal | ( | CTA_TreeVector | treevec, | |
double | alpha | |||
) |
Scale tree-vector.
treevec | IO handle of tree-vector | |
alpha | I scalar |
CTAEXPORT int CTA_TreeVector_SetConstant | ( | CTA_TreeVector | treevec, | |
void * | val, | |||
CTA_Datatype | datatype | |||
) |
Set whole tree-vector equal to a constant value.
treevec | IO TreeVector | |
val | I value to set | |
datatype | I data type of val, must be same as data type of tree-vector |
CTAEXPORT int CTA_TreeVector_SetMetainfo | ( | CTA_TreeVector | treevec, | |
CTA_Metainfo | minfo | |||
) |
CTAEXPORT int CTA_TreeVector_SetSubTreeNocompute | ( | CTA_TreeVector | x, | |
const char * | tag | |||
) |
Set nocompute flag of a sub-tree vector.
When this flag is set, the values of the sub-treevector will be ignored in all basic vector operations (including asking the total length of the tree-vector). This propertie is used for additionally adding some meta information
x | I handle of a COSTA tree-vector (y) | |
tag | I tag of sub-treevector |
CTAEXPORT int CTA_TreeVector_SetVal | ( | CTA_TreeVector | treevec, | |
int | i, | |||
void * | val, | |||
CTA_Datatype | datatype | |||
) |
Set single value of the tree-vector.
treevec | IO Tree-Vector | |
i | I index of value in tree-vector | |
val | I value to be set | |
datatype | I data type of *val, must be the same as data type of element in tree-vector |
CTAEXPORT int CTA_TreeVector_SetVals | ( | CTA_TreeVector | treevec, | |
void * | val, | |||
int | nval, | |||
CTA_Datatype | datatype | |||
) |
Set all values of the tree-vector.
treevec | IO Tree-vector | |
val | I values to be set | |
nval | I number of elements in val | |
datatype | I data type of *val, must be the same as data type of elements in tree-vector |
CTAEXPORT int CTA_TreeVector_SetVec | ( | CTA_TreeVector | treevec, | |
CTA_Vector | hvec | |||
) |
Set the values of the tree-vector.
treevec | IO TreeVector | |
hvec | I handle of the vector containing new values (see note) |
CTAEXPORT int CTA_TreeVector_VImport | ( | CTA_TreeVector | treevec, | |
CTA_Handle | usrdata | |||
) |
Import Tree-vector as flat vector.
Can import tree-vector from netcdf file.
usrdata must contain a handle of the file .
Dependency: CTA_Vector_VImport()
treevec | I Tree-vector | |
usrdata | I import properties |
CTAEXPORT int CTAI_TreeVec_GetVecNumHandles | ( | CTA_TreeVector | treevec | ) |
CTAEXPORT int CTAI_TreeVec_List | ( | CTA_TreeVector | treevec, | |
CTA_Vector | taglist, | |||
int * | indx | |||
) |
CTAEXPORT void CTAI_Treevector_Operation_Amax | ( | char * | tag, | |
CTA_Vector | v1, | |||
CTA_Vector * | v2, | |||
CTA_Handle | hdum, | |||
int * | retval | |||
) |
CTAEXPORT void CTAI_Treevector_Operation_MaxAbs | ( | char * | tag, | |
CTA_Vector | v1, | |||
CTA_Vector | , | |||
CTA_Handle | hdum, | |||
int * | retval | |||
) |
CTAEXPORT void CTAI_Treevector_Operation_PrintEntry | ( | char * | tag, | |
CTA_Vector | v1, | |||
CTA_Vector | v2, | |||
CTA_Handle | hdum, | |||
int * | retval | |||
) |
CTAEXPORT void CTAI_Treevector_Operation_ScaledRMS | ( | char * | tag, | |
CTA_Vector | v1, | |||
CTA_Vector | vscal, | |||
CTA_Handle | hdum, | |||
int * | retval | |||
) |
CTAEXPORT void CTAI_Treevector_Operation_ScaledSSQ | ( | char * | tag, | |
CTA_Vector | v1, | |||
CTA_Vector | vscal, | |||
CTA_Handle | hdum, | |||
int * | retval | |||
) |
CTAEXPORT CTA_TreeVector CTAI_XML_CreateTreeVec | ( | xmlNode * | cur_node | ) |
Create a COSTA tree-vector from XML.
cur_node | I Current XML node |
CTAEXPORT void CTAI_XML_WriteTreeVec | ( | CTA_TreeVector | treevec, | |
xmlTextWriter * | writer | |||
) |
Generate XML from one COSTA tree-vector.
treevec | I handle of a COSTA tree-vector | |
writer | I the XML text writer |