![]() |
|
Functions | |
double * | apop_data_ptr (apop_data *data, int row, int col, const char *rowname, const char *colname, const char *page) |
double | apop_data_get (const apop_data *data, size_t row, int col, const char *rowname, const char *colname, const char *page) |
void | apop_gsl_error_for_set (const char *reason, const char *file, int line, int gsl_errno) |
int | apop_data_set (apop_data *data, size_t row, int col, const double val, const char *colname, const char *rowname, const char *page) |
First, some examples:
A call like apop_data_set(in, row, col, data)
is much like the GSL's gsl_matrix_set(in->matrix, row, col, data)
, but with some differences:
apop_data_get(dataset, 1)
gets item (1, 0) from the matrix element of dataset
. As a do-what-I-mean exception, if there is no matrix element but there is a vector, then this form will get vector element 1. Relying on this DWIM exception is useful iff you can guarantee that a data set will have only a vector or a matrix but not both. Otherwise, be explicit: apop_data_get(dataset, 1, -1)
.The _ptr
functions return a pointer to the given cell. Those functions follow the lead of gsl_vector_ptr
and gsl_matrix_ptr
, and like those functions, return a pointer to the appropriate double
.
double apop_data_get | ( | const apop_data * | data, |
size_t | row, | ||
int | col, | ||
const char * | rowname, | ||
const char * | colname, | ||
const char * | page | ||
) |
Returns the data element at the given point.
In case of error (probably that you asked for a data point out of bounds), returns GSL_NAN
. See the set/get page for details.
data | The data set. Must not be NULL . |
row | The row number of the desired element. If rowname==NULL , default is zero. |
col | The column number of the desired element. -1 indicates the vector. If colname==NULL , default is zero. |
rowname | The row name of the desired element. If NULL , use the row number. |
colname | The column name of the desired element. If NULL , use the column number. |
page | The case-insensitive name of the page on which the element is found. If NULL , use first page. |
double* apop_data_ptr | ( | apop_data * | data, |
int | row, | ||
int | col, | ||
const char * | rowname, | ||
const char * | colname, | ||
const char * | page | ||
) |
Get a pointer to an element of an apop_data set.
NULL
vector or matrix (as the case may be), stop (unless apop_opts.stop_on_warning='n'
, then return NULL
). NULL
. data | The data set. Must not be NULL . |
row | The row number of the desired element. If rowname==NULL , default is zero. |
col | The column number of the desired element. -1 indicates the vector. If colname==NULL , default is zero. |
rowname | The row name of the desired element. If NULL , use the row number. |
colname | The column name of the desired element. If NULL , use the column number. |
page | The case-insensitive name of the page on which the element is found. If NULL , use first page. |
int apop_data_set | ( | apop_data * | data, |
size_t | row, | ||
int | col, | ||
const double | val, | ||
const char * | colname, | ||
const char * | rowname, | ||
const char * | page | ||
) |
Set a data element.
This function uses the Designated initializers syntax, so with names you don't have to worry about element ordering. But the ordering of elements may still be noteworthy. For compatibility with older editions of Apophenia, the order is (row, col, value, rowname, colname), so the following would all set row 3, column 8, of d
to 5:
_Thread_local
keyword) or a version of GCC with the __thread
extension enabled.See the set/get page for details.
data | The data set. Must not be NULL . |
row | The row number of the desired element. If rowname==NULL , default is zero. |
col | The column number of the desired element. -1 indicates the vector. If colname==NULL , default is zero. |
rowname | The row name of the desired element. If NULL , use the row number. |
colname | The column name of the desired element. If NULL , use the column number. |
page | The case-insensitive name of the page on which the element is found. If NULL , use first page. |
val | The value to give the point. |