STARS-H
Software for Testing Accuracy, Reliability and Scalability of Hierarchical computations
Array

Routines for n-dimensional arrays. More...

Data Structures

struct  array
 N-dimensional array. More...
 

Typedefs

typedef struct array Array
 

Functions

int array_from_buffer (Array **A, int ndim, int *shape, char dtype, char order, void *data)
 Init array from given buffer. More...
 
int array_new (Array **A, int ndim, int *shape, char dtype, char order)
 Init array object and allocate memory for its buffer. More...
 
int array_new_like (Array **A, Array *B)
 Init new array object with the shape, dtype and order of other. More...
 
int array_new_copy (Array **A, Array *B, char order)
 Init new array object as copy of other with given data layout. More...
 
void array_free (Array *A)
 
void array_info (Array *A)
 
void array_print (Array *A)
 
int array_to_matrix (Array *A, char kind)
 
int array_trans_inplace (Array *A)
 Transpose A by changing shape, stride and order. More...
 
int array_dot (Array *A, Array *B, Array **C)
 GEMM for A and B into C. More...
 
int array_SVD (Array *A, Array **U, Array **S, Array **V)
 Compute SVD of a given 2-dimensional A. More...
 
int SVD_get_rank (Array *S, double tol, char type, int *rank)
 Returns rank by given singular values S, tolerance and type of norm. More...
 
int array_scale (Array *A, char kind, Array *S)
 Apply row or column scaling to A. More...
 
int array_diff (Array *A, Array *B, double *result)
 Measure Frobenius error of approximation of A by B. More...
 
int array_norm (Array *A, double *result)
 Measure Frobenius norm of A. More...
 
int array_convert (Array **A, Array *B, char dtype)
 Create A as a copy of B with different data type (precision). More...
 
int array_cholesky (Array *A, char uplo)
 Cholesky factorization for A. More...
 

Detailed Description

Routines for n-dimensional arrays.

Typedef Documentation

◆ Array

typedef struct array Array

Typedef for array

Function Documentation

◆ array_cholesky()

int array_cholesky ( Array A,
char  uplo 
)

Cholesky factorization for A.

Parameters
[in,out]APointer to Array object.
[in]uploStore result in upper or in lower part of A.
Returns
Error code STARSH_ERRNO.

◆ array_convert()

int array_convert ( Array **  A,
Array B,
char  dtype 
)

Create A as a copy of B with different data type (precision).

Parameters
[out]AAddress of pointer to Array object.
[in]BPointer to Array object.
[in]dtypeNew data type (precision).
Returns
Error code STARSH_ERRNO.

◆ array_diff()

int array_diff ( Array A,
Array B,
double *  result 
)

Measure Frobenius error of approximation of A by B.

Parameters
[in]APointer to Array object.
[in]BPointer to Array object.
[out]resultAddress of result.
Returns
Error code STARSH_ERRNO.

◆ array_dot()

int array_dot ( Array A,
Array B,
Array **  C 
)

GEMM for A and B into C.

Multiplication is performed by last dimension of A and first dimension of B. These dimensions, data types and ordering of A and B should be equal.

Parameters
[in]APointer to Array object.
[in]BPointer to Array object.
[out]CAddress of pointer to Array object.
Returns
Error code STARSH_ERRNO.

◆ array_free()

void array_free ( Array A)

Free array object.

◆ array_from_buffer()

int array_from_buffer ( Array **  A,
int  ndim,
int *  shape,
char  dtype,
char  order,
void *  data 
)

Init array from given buffer.

Memory is automatically allocated, do not forget to free it by array_free().

Parameters
[out]AOutput array.
[in]ndimNumber of dimensions of array, ndim > 1.
[in]shapeSize of array in each dimension.
[in]dtypePrecision of array element.
[in]orderFortran (column-major) or C (row-major) order.
[in]dataData buffer.
Returns
Error code STARSH_ERRNO.

◆ array_info()

void array_info ( Array A)

Print all the data from array object A.

◆ array_new()

int array_new ( Array **  A,
int  ndim,
int *  shape,
char  dtype,
char  order 
)

Init array object and allocate memory for its buffer.

Parameters
[out]AAddress of pointer to array object.
[in]ndimNumber of dimensions of array, ndim > 1.
[in]shapeSize of array in each dimension.
[in]dtypePrecision of array element.
[in]orderFortran (column-major) or C (row-major) order.
Returns
Error code STARSH_ERRNO.

◆ array_new_copy()

int array_new_copy ( Array **  A,
Array B,
char  order 
)

Init new array object as copy of other with given data layout.

Parameters
[out]AAddress of pointer to array object.
[in]BOther array object.
[in]orderFortran (column-major) or C (row-major) order.
Returns
Error code STARSH_ERRNO.

◆ array_new_like()

int array_new_like ( Array **  A,
Array B 
)

Init new array object with the shape, dtype and order of other.

Parameters
[out]AAddress of pointer to array object.
[in]BOther array object.
Returns
Error code STARSH_ERRNO.

◆ array_norm()

int array_norm ( Array A,
double *  result 
)

Measure Frobenius norm of A.

Parameters
[in]APointer to Array object.
[out]resultAddress of result.
Returns
Error code STARSH_ERRNO.

◆ array_print()

void array_print ( Array A)

Print array. Different rows of A are printed on different output rows.

◆ array_scale()

int array_scale ( Array A,
char  kind,
Array S 
)

Apply row or column scaling to A.

Parameters
[in,out]APointer to Array object.
[in]kindRow or column scaling.
[in]SScaling factors in Array object.
Returns
Error code STARSH_ERRNO.

◆ array_SVD()

int array_SVD ( Array A,
Array **  U,
Array **  S,
Array **  V 
)

Compute SVD of a given 2-dimensional A.

Parameters
[in]APointer to Array object.
[out]UAddress of pointer to Array object.
[out]SAddress of pointer to Array object.
[out]VAddress of pointer to Array object.
Returns
Error code STARSH_ERRNO.

◆ array_to_matrix()

int array_to_matrix ( Array A,
char  kind 
)

Convert array to 2-dimensional matrix by glueing different dimensions.

Convert N-dimensional A to 2-dimensional A (matrix) by collapsing dimensions. This collapse can be assumed as attempt to look at A as at a matrix with long rows (kind == 'R') or long columns (kind == 'C'). If kind is 'R', dimensions from 1 to the last are collapsed into columns. If kind is 'C', dimensions from 0 to the last minus one are collapsed into rows. Example: A of shape (2,3,4,5) will be collapsed to A of shape (2,60) if kind is 'R' or to A of shape (24,5) if kind is 'C'.

Parameters
[in,out]APointer to Array object.
[in]kindkind of collapse (into long rows or into long columns).
Returns
Error code STARSH_ERRNO.

◆ array_trans_inplace()

int array_trans_inplace ( Array A)

Transpose A by changing shape, stride and order.

Parameters
[in,out]APointer to Array object.
Returns
Error code STARSH_ERRNO.

◆ SVD_get_rank()

int SVD_get_rank ( Array S,
double  tol,
char  type,
int *  rank 
)

Returns rank by given singular values S, tolerance and type of norm.

Parameters
[in]SPointer to Array object.
[in]tolRelative error threshold.
[in]typeFrobenius or spectral norm.
[out]rankAddress of rank.
Returns
Error code STARSH_ERRNO.