The functions marray_f work with elements of type double.
There are other versions of the form marray_TYPE_f where TYPE is any of:
Allocation
marray * marray_alloc (const unsigned int rank, const size_t * dimension); ¶Allocate memory for a marray of rank rank and dimensions given in dimension (an array of size rank), and return a pointer to its position in memory.
marray * marray_calloc (const unsigned int rank, const size_t * dimension); ¶Allocate memory for a marray of rank rank and dimensions given in dimension (an array of size rank), set all its elements to 0 and return a pointer to its position in memory.
marray * marray_copy (marray * t); ¶Create a copy of marray t and return a pointer to its position in memory.
void marray_free (marray * t); ¶Release the memory used by marray t.
Conversion
gsl_matrix * marray_2matrix (marray * t); ¶Convert a rank 2 marray to a gsl_matrix.
gsl_vector * marray_2vector (marray * t); ¶Convert a rank 1 marray to a gsl_vector.
Get/Set elements
double marray_get (const marray * t, const size_t * indices); ¶t[indices]
void marray_set (marray * t, const size_t * indices, const double x); ¶t[indices] = x
Access pointer
double * marray_ptr (marray * t, const size_t * indices); ¶&t[indices]
const double * marray_const_ptr (const marray * t, const size_t * indices); ¶&t[indices] (const pointer)
Set to a value
void marray_set_zero (marray * t); ¶t = 0
void marray_set_all (marray * t, double x); ¶t = x
IO
int marray_fread (FILE * stream, marray * t); ¶Read binary representation of marray from stream and save it in t.
int marray_fwrite (FILE * stream, const marray * t); ¶Write binary representation of marray t to stream.
int marray_fscanf (FILE * stream, marray * t); ¶Read text representation of marray from stream and save it in t.
int marray_fprintf (FILE * stream, const marray * t, const char * format); ¶Write text representation of marray t to stream, using format format for its elements.
Copy
int marray_memcpy (marray * dest, const marray * src); ¶dest = src
int marray_swap (marray * t1, marray * t2); ¶t1, t2 = t2, t1
Maxima
double marray_max (const marray * t); ¶Maximum element of marray t.
double marray_min (const marray * t); ¶Minimum element of marray t.
void marray_minmax (const marray * t, double * min_out, double * max_out); ¶Copy the minimum and maximum elements of t in min_out and max_out respectively.
void marray_max_index (const marray * t, size_t * indices); ¶Get the indices of the maximum element of t.
void marray_min_index (const marray * t, size_t * indices); ¶Get the indices of the minimum element of t.
void marray_minmax_index (const marray * t, size_t * imin, size_t * imax); ¶Get the indices of the minimum and maximum elements of t.
Properties
int marray_isnull (const marray * t); ¶t == 0
Operations
int marray_add (marray * a, const marray * b); ¶a += b
int marray_sub (marray * a, const marray * b); ¶a -= b
int marray_mul_elements (marray * a, const marray * b); ¶a .*= b
int marray_div_elements (marray * a, const marray * b); ¶a ./= b
int marray_scale (marray * a, const double x); ¶a *= x
int marray_add_constant (marray * a, const double x); ¶a += x