Array(API)

From EosPedia
Revision as of 03:04, 5 September 2014 by Kinoshita (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

General/Array is Object to express array. It can express general array (multiple dimension array).

constant

ARRAY_MAX_DIMENSION: 5 (Maximum dimension of array)
ARRAY_MIN_DIMENSION: 1 (Minimum dimension of array)
ARRAY_SEPARATOR " \t\n," (Separator of array)

struct

 typedef unsigned long arrayParaTypeInteger;
 typedef float         arrayParaTypeReal;
 
 typedef struct Array {
     arrayParaTypeInteger dim;
     arrayParaTypeInteger n[ARRAY_MAX_DIMENSION];
     arrayParaTypeReal*   A;
 } Array;


dim: dimension of array (2D: Matrix, 1D: Vector.)
n: Number of elements at each dimension
A: Linear vector which stores elements

API

Initialize

extern void arrayInit(Array* a, char* message);

Free

extern void arrayFree(Array* a, char* message);

Output format details

extern void arrayFormatInfoPrint(FILE* fpt, int mode);

File Read

extern void arrayReadFromFile(FILE* fpt, Array* a, char* message);

File Write

extern void arrayWriteToFile(FILE* fpt, Array* a, char* message);

Principal Component Analysis

extern void arrayPCA(Array* u, Array* C, Array* lambda, Array* X, Array* ave, int mode);
Input Description
X Coordinates information in Contour level(number of components * number of elements)


Output Description
u Eigenvector of coordinates information(number of components * number of components)
C Covariance of coordinates information(number of components * number of components)
lambda Eigenvalue of coordinates information(number of components)
ave Average coordinates of each component(number of components)


Get and Set array element

Get or set value of each element by the following function. Caution that type is not automatically converted, since set by #define .

Get

arrayDataGet1(a, i0)
arrayDataGet2(a, i0, i1)
arrayDataGet3(a, i0, i1, i2)
arrayDataGet4(a, i0, i1, i2, i3)
arrayDataGet5(a, i0, i1, i2, i3, i4)

Set

arrayDataSet1(a, i0, data)
arrayDataSet2(a, i0, i1, data)
arrayDataSet3(a, i0, i1, i2, data)
arrayDataSet4(a, i0, i1, i2, i3, data)
arrayDataSet5(a, i0, i1, i2, i3, i4, data)