tArray
Members
- tGrid * g
-
Pointer to the grid owning the array, if applicable.
- tArray* main
-
If this array is a sub-array of a larger array, this pointer should point to the main array.
- double* a
-
Pointer to the (flat) array containing the actual data.
- double* d
-
Pointer to the array on a device (i.e. GPU), if applicable.
- int n0, n1, n2, n3
-
Dimensions of the array.
- int n
-
Total number of data points.
Relevant functions
Algebra
- void array_copy(tArray * w, tArray * u)
-
Copy tArray: w ← u
- void array_copy_part2d(tArray * w, tArray * u, int i0, int j0)
-
Perform a partial copy of submatrix of u into w. The submatrix begins at indices i0 and j0 and has dimensions of w; Exits with error if that range leaves u.
- void array_add(tArray * w, double a, tArray * u, double b, tArray * v)
-
Add tArrays pointwise: w ← a*u + b*v
- void array_addto(tArray * w, double a, tArray * u)
-
Add tArrays pointwise: w ← w + a*u
array_copy , array_add and array_addto assume that all tArrays involved have the same dimensions, and do not check.
|
- void array_scale(tArray * w, const double c)
-
Scale tArray pointwise: w ← c*w
- void array_mult2d(tArray * C, tArray * A, tArray * B)
-
Matrix multiplication on 2d tArrays: Cm*n ← Am*k Bk*n
Exits with error if dimensions don’t match. - void array_transpose2d(tArray * At, tArray * A)
-
Transpose Matrix: At ← AT Exits with error if dimensions don’t match.
Allocation and Deallocation
- tArray array_alloc_double(tG g, int n, double* data)
-
Allocates a 1d array for storing double values and initializes it data pointed to by data. If data is
NULL
, the array is initialized with zeroes. - tArray array_alloc_int(tG g, int n, int* data)
-
Allocates a 1d array for storing int values and initializes it data pointed to by data. If data is
NULL
, the array is initialized with zeroes. - tArray array_append_double(tG g, tArray * a, int n, double* data)
-
Resizes an existing 1d array a and append n double elements. If a is
NULL
, a new array will be created. If data isNULL
, the new elements are initialized with zeroes. - tArray array_append_int(tG g, tArray* a, int n, int* data)
-
Resizes an existing 1d array a and append n int elements. If a is
NULL
, a new array will be created. If data isNULL
, the new elements are initialized with zeroes. - tArray array_alloc2d(tG g, int n0, int n1, double* data)
-
Allocated a 2d n0*n1 array holding data. If data is
NULL
, a double array of the specified dimensions is created and initialized with zeroes. - tArray array_alloc2d_append(tG g, tArray* a, int n0, int n1, double* data)
-
Extends a 2d array by n0 and n1, respectively. If data is
NULL
, the new entries are initialized with 0.
data is appended directly onto a.data, which is probably not what you want when extending an array in the n1-dimension. Realistically this is only useful when extending in the n0-dimension. |
- tArray array_alloc(tArray a)
-
Allocates a new tArray using parameters of an existing tArray. data of the returned array is initialized to zeroes. The returned array will be a main array (not a sub-array), even if a is a sub-array.
- tArray array_clone(tArray a)
-
Allocates a new tArray as a complete copy of a, including the data stored in a.
- tArray array_free(tArray a)
-
Deallocates a, freeing its a.data. Cannot be used on sub-arrays.
- tArray array_sub_create2d(tArray u,int n0,int n1,int offset)
-
Returns a sub-array of u with dimensions n0, n1. The sub-array begins at offset, which is counted as the
"flat"
index used to access u.data. A sub-array does not have its own data, but instead points to a location in its main-array’s data.
Misc
- double array_ptr(tArray a, int i)
-
Returns a pointer to the i'th column of a.data. Assumes a is storing double values.
- double array_norm(tArray* a, int i)
-
Returns the norm of the i'th column of a.data.
- void array_subset4d(tArray * w, tArray * u, int n, int* ind)
-
Performs a partial copy of only a subset of all variables in u into w. n is the number of variables to be copied, and ind is an array of their indices. Exits with error if w doesn’t have enough space for n variables.
- tArray array_get_sub(tArray main, int nmodule)
-
Returns sub-array for module with index nmodule of tArray* main. Relies on main.g begin properly set to the correct grid.