cta_array.h File Reference

Interface description of array component. More...

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

Go to the source code of this file.

Typedefs

typedef CTA_Handle CTA_Array

Functions

CTAEXPORT int CTA_Array_Free (CTA_Array *h)
 Free Array instance.
CTAEXPORT int CTA_Array_CreateAsDoubles (double *values, int nDimensions, int *dimensions, CTA_Array *h)
 Create a new Array instance and fill with given values.
CTAEXPORT int CTA_Array_getNumberOfDimensions (CTA_Array h)
 Get number of dimensions, eg 1 for a vector and 2 for a matrix.
CTAEXPORT int CTA_Array_getnDimensions (CTA_Array h, int *nDimensions)
 Get the sizes of the individual dimensions.
CTAEXPORT int CTA_Array_getDimensions (CTA_Array h, int *dimensions)
 Get the size of the array for each dimension. The length of the return value equals the number of dimensions.
CTAEXPORT int CTA_Array_length (CTA_Array h)
 Total number of elements in an array. This is equal to the product of the values returned by getDimension and is thus just for c.
CTAEXPORT int CTA_Array_getValuesAsDoubles (CTA_Array h, double *values)
 Get all values of an array. The values are guaranteed be a copy if copyValues==true or may be a reference if copyValues==false. Note that the values are never guaranteed to be a reference and can not be used to change the array.
CTAEXPORT int CTA_Array_getValuesAsDoubles_indexrange (CTA_Array h, int firstIndex, int lastIndex, double *values)
 Get a part of the values from the array. Eg let a=[[1,2,3][4,5,6]] then getValuesAsDoubles(1,2) returns [2,3] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.
CTAEXPORT int CTA_Array_getValueAsDoubles_index (CTA_Array h, int index, double *value)
 Get a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then getValueAsDouble(5) returns 6 Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.
CTAEXPORT int CTA_Array_getValueAsDouble_indices (CTA_Array h, int nIndices, int *indices, double *value)
 Get a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then getValueAsDouble([1,2]) returns 6 Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.
CTAEXPORT int CTA_Array_setValuesAsDoubles (CTA_Array h, double *values, int length)
 Set the values of this array.
CTAEXPORT int CTA_Array_setValueAsDouble_indices (CTA_Array h, int nIndices, int *indices, double value)
 Set a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then setValueAsDouble([1,2],60.) results in a=[[1,2,3][4,5,60.]] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.
CTAEXPORT int CTA_Array_setValuesAsDoubles_indexrange (CTA_Array h, int firstIndex, int lastIndex, double *values)
 Set part of the values of this array. Let a=[[1,2,3][4,5,6]] then setValuesAsDoubles(1,2,[20,30]) will result in a=[[1,20,30][4,5,6]] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.
CTAEXPORT int CTA_Array_setValueAsDouble_index (CTA_Array h, int index, double value)
 Get a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then setValueAsDouble(5,60.) results in a=[[1,2,3][4,5,60.]] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.
CTAEXPORT int CTA_Array_setConstant (CTA_Array h, double value)
 Set whole vector equal to a constant value. Note: This method can only be used if all elements of the vector have the same data type.
CTAEXPORT int CTA_Array_axpyOnValues (CTA_Array h, double alpha, double *axpyValues)
 Perform a values += alpha * axpyValues operation on each value in this array.
CTAEXPORT int CTA_Array_multiplyValues (CTA_Array h, double *multiplicationFactors)
 Multiply each value in this array with the corresponding multiplication factor.
CTAEXPORT int CTA_Array_reshape (CTA_Array h, int nDimensions, int *dimensions)
 Change the dimensions of an array. The new array should have the same length.
CTAEXPORT int CTA_Array_getSlice (CTA_Array h, int dimension, int index, CTA_Array *h_out)
 Get part of the array by selection of a subset in one dimension. Eg. a=[[1,2,3],[4,5,6]] a.getSlice(0,0) returns [1,2,3] Note that the number of dimensions IS reduced by one.
CTAEXPORT int CTA_Array_getSlice_range (CTA_Array h, int dimension, int minIndex, int maxIndex, CTA_Array *h_out)
 Get part of the array by selection of a subset in one dimension. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] a.getSlice(0,0,1) returns [[1,2],[3,4]] Note that the number of dimensions is NOT reduced by one.
CTAEXPORT int CTA_Array_getSliceAsDoubles_range (CTA_Array h, int dimension, int minIndex, int maxIndex, double *values)
 Get part of the array by selection of a subset in one dimension. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] a.getSlice(0,0,1) returns [1,2,3,4].
CTAEXPORT int CTA_Array_setSliceAsDoubles (CTA_Array h, double *slice, int dimension, int index)
 Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([11,12,13],1,1) sets the second column a=[[1,11,3],[4,12,6],[7,13,9]] Note that the dimension of the slice is one smaller than for the array.
CTAEXPORT int CTA_Array_setSliceAsArray (CTA_Array h, CTA_Array slice_h, int dimension, int index)
 Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([11,12,13],1,1) sets the second column a=[[1,11,3],[4,12,6],[7,13,9]] Note that the dimension of the slice is one smaller than for the array.
CTAEXPORT int CTA_Array_setSliceAsArray_range (CTA_Array h, CTA_Array slice_h, int dimension, int minIndex, int maxIndex)
 Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([[11,12,13],[14,15,16]],1,1,2) sets the second and third columns a=[[1,11,14],[4,12,15],[7,13,16]] Note that the dimension of the slice is the same as for the array.
CTAEXPORT int CTA_Array_setSliceAsDoubles_range (CTA_Array h, double *slice, int dimension, int minIndex, int maxIndex)
 Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([11,12,13,14,15,16],1,1,2) sets the second and third columns a=[[1,11,14],[4,12,15],[7,13,16]] Note that the dimension of the slice is the same as for the array.
CTAEXPORT int CTA_Array_valueIndex (CTA_Array h, int nIndices, int *indices, int *index)
 Convert indices in multiple dimensions to position in the one-dimensional array as returned eg by getValuesAsDoubles Eg. a=[[1,2,3],[4,5,6],[7,8,9]] then valueIndex([1,0]) returns 3 which points to the value 4 here.

Detailed Description

Interface description of array component.

An array in OpenDA is an N-dimensional Matrix of values. In a similar wat as in Matlab and Octave a vector is a special case of a Matrix/Array.

Definition in file cta_array.h.


Typedef Documentation

Definition at line 39 of file cta_array.h.


Function Documentation

CTAEXPORT int CTA_Array_axpyOnValues ( CTA_Array  h,
double  alpha,
double *  axpyValues 
)

Perform a values += alpha * axpyValues operation on each value in this array.

Parameters:
h I Array handle
alpha I The alpha in state variable += alpha * vector.
axpyValues I the values for the axpy-operation on all values in this array.
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_CreateAsDoubles ( double *  values,
int  nDimensions,
int *  dimensions,
CTA_Array h 
)

Create a new Array instance and fill with given values.

Parameters:
values I values of new Array
nDimensions I Number of dimensions of new array
dimensions I Number of elements in each dimension
h O Array handle of new instance
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_Free ( CTA_Array h  ) 

Free Array instance.

Parameters:
h IO handle of Array instance CTA_NULL on return
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getDimensions ( CTA_Array  h,
int *  dimensions 
)

Get the size of the array for each dimension. The length of the return value equals the number of dimensions.

Parameters:
h I Array handle
dimensions O size of array, eg [3,4,10]
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getnDimensions ( CTA_Array  h,
int *  nDimensions 
)

Get the sizes of the individual dimensions.

Parameters:
h I Array handle
nDimensions O size of array, eg 2 for the array [[3,4,10],[3,4,10]]
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getNumberOfDimensions ( CTA_Array  h  ) 

Get number of dimensions, eg 1 for a vector and 2 for a matrix.

Parameters:
h I Array handle
Returns:
rank of the array
CTAEXPORT int CTA_Array_getSlice ( CTA_Array  h,
int  dimension,
int  index,
CTA_Array h_out 
)

Get part of the array by selection of a subset in one dimension. Eg. a=[[1,2,3],[4,5,6]] a.getSlice(0,0) returns [1,2,3] Note that the number of dimensions IS reduced by one.

Parameters:
h I Array handle
dimension I Dimension to make selection in
index I Element in dimension that is selected
h_out O new Array with selected selection
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getSlice_range ( CTA_Array  h,
int  dimension,
int  minIndex,
int  maxIndex,
CTA_Array h_out 
)

Get part of the array by selection of a subset in one dimension. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] a.getSlice(0,0,1) returns [[1,2],[3,4]] Note that the number of dimensions is NOT reduced by one.

Parameters:
h I Array handle
dimension I Dimension to make selection in
minIndex I start of range to select
maxIndex I end of range to select
h_out O new Array with selected selection
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getSliceAsDoubles_range ( CTA_Array  h,
int  dimension,
int  minIndex,
int  maxIndex,
double *  values 
)

Get part of the array by selection of a subset in one dimension. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] a.getSlice(0,0,1) returns [1,2,3,4].

Parameters:
h I Array handle
dimension I Dimension to make selection in
minIndex I start of range to select
maxIndex I end of range to select
values O selected values
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getValueAsDouble_indices ( CTA_Array  h,
int  nIndices,
int *  indices,
double *  value 
)

Get a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then getValueAsDouble([1,2]) returns 6 Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.

Parameters:
h I Array handle
nIndices I length of array of indices indices
indices I indices of value
value O value from array
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getValueAsDoubles_index ( CTA_Array  h,
int  index,
double *  value 
)

Get a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then getValueAsDouble(5) returns 6 Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.

Parameters:
h I Array handle
index I index specifier
value O double value at the specific indices
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getValuesAsDoubles ( CTA_Array  h,
double *  values 
)

Get all values of an array. The values are guaranteed be a copy if copyValues==true or may be a reference if copyValues==false. Note that the values are never guaranteed to be a reference and can not be used to change the array.

Parameters:
h I Array handle
values O Values from the array
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_getValuesAsDoubles_indexrange ( CTA_Array  h,
int  firstIndex,
int  lastIndex,
double *  values 
)

Get a part of the values from the array. Eg let a=[[1,2,3][4,5,6]] then getValuesAsDoubles(1,2) returns [2,3] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.

Parameters:
h I Array handle
firstIndex I firstIndex of selection
lastIndex I lastIndex of selection
values O Values from the array
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_length ( CTA_Array  h  ) 

Total number of elements in an array. This is equal to the product of the values returned by getDimension and is thus just for c.

Parameters:
h I Array handle
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_multiplyValues ( CTA_Array  h,
double *  multiplicationFactors 
)

Multiply each value in this array with the corresponding multiplication factor.

Parameters:
h I Array handle
multiplicationFactors I the multiplication factors for all array values.
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_reshape ( CTA_Array  h,
int  nDimensions,
int *  dimensions 
)

Change the dimensions of an array. The new array should have the same length.

Parameters:
h I Array handle
nDimensions I length of array dimensions
dimensions I new dimensions of array
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setConstant ( CTA_Array  h,
double  value 
)

Set whole vector equal to a constant value. Note: This method can only be used if all elements of the vector have the same data type.

Parameters:
h I Array handle
value I value to set
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setSliceAsArray ( CTA_Array  h,
CTA_Array  slice_h,
int  dimension,
int  index 
)

Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([11,12,13],1,1) sets the second column a=[[1,11,3],[4,12,6],[7,13,9]] Note that the dimension of the slice is one smaller than for the array.

Parameters:
h I Array handle
slice_h I Values to set
dimension I Dimension that is replaced
index I Index of selected dimension to replace
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setSliceAsArray_range ( CTA_Array  h,
CTA_Array  slice_h,
int  dimension,
int  minIndex,
int  maxIndex 
)

Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([[11,12,13],[14,15,16]],1,1,2) sets the second and third columns a=[[1,11,14],[4,12,15],[7,13,16]] Note that the dimension of the slice is the same as for the array.

Parameters:
h I Array handle
slice_h I Values to set
dimension I Dimension that is replaced
minIndex I Start of range in Dimension to be replaced
maxIndex I End of range in Dimension to be replaced
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setSliceAsDoubles ( CTA_Array  h,
double *  slice,
int  dimension,
int  index 
)

Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([11,12,13],1,1) sets the second column a=[[1,11,3],[4,12,6],[7,13,9]] Note that the dimension of the slice is one smaller than for the array.

Parameters:
h I Array handle
slice I Values to set
dimension I Dimension that is replaced
index I Index of selected dimension to replace
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setSliceAsDoubles_range ( CTA_Array  h,
double *  slice,
int  dimension,
int  minIndex,
int  maxIndex 
)

Set the values of a part of an array. Eg. a=[[1,2,3],[4,5,6],[7,8,9]] and a.setSlice([11,12,13,14,15,16],1,1,2) sets the second and third columns a=[[1,11,14],[4,12,15],[7,13,16]] Note that the dimension of the slice is the same as for the array.

Parameters:
h I Array handle
slice I Values to set
dimension I Dimension that is replaced
minIndex I Start of range in Dimension to be replaced
maxIndex I End of range in Dimension to be replaced
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setValueAsDouble_index ( CTA_Array  h,
int  index,
double  value 
)

Get a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then setValueAsDouble(5,60.) results in a=[[1,2,3][4,5,60.]] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.

Parameters:
h I Array handle
index I index specifier
value I value that will replace the selected number
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setValueAsDouble_indices ( CTA_Array  h,
int  nIndices,
int *  indices,
double  value 
)

Set a value from an array for specific indices. Eg let a=[[1,2,3][4,5,6]] then setValueAsDouble([1,2],60.) results in a=[[1,2,3][4,5,60.]] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.

Parameters:
h I Array handle
nIndices I length of array indices
indices I index specifier
value I values at the specific indices
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setValuesAsDoubles ( CTA_Array  h,
double *  values,
int  length 
)

Set the values of this array.

Parameters:
h I Array handle
values I the values as an array of doubles
length I length of array values
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_setValuesAsDoubles_indexrange ( CTA_Array  h,
int  firstIndex,
int  lastIndex,
double *  values 
)

Set part of the values of this array. Let a=[[1,2,3][4,5,6]] then setValuesAsDoubles(1,2,[20,30]) will result in a=[[1,20,30][4,5,6]] Note that negative values are allowed to denote counting from the end, is -1 denotes the last value.

Parameters:
h I Array handle
firstIndex I specifies the start of the selection
lastIndex I specifies the end of the selection
values I that will replace the selected range of numbers
Returns:
error status: CTA_OK if successful
CTAEXPORT int CTA_Array_valueIndex ( CTA_Array  h,
int  nIndices,
int *  indices,
int *  index 
)

Convert indices in multiple dimensions to position in the one-dimensional array as returned eg by getValuesAsDoubles Eg. a=[[1,2,3],[4,5,6],[7,8,9]] then valueIndex([1,0]) returns 3 which points to the value 4 here.

Parameters:
h I Array handle
nIndices I length of indices
indices I indices of element
index O position of element
Returns:
error status: CTA_OK if successful

Generated on 4 Mar 2014 for OpenDA by  doxygen 1.6.1