Patterns in static

Apophenia

Functions
Set/get/point to the data element at the given point

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)
 

Detailed Description

First, some examples:

apop_data *d = apop_data_alloc(10, 10, 10);
apop_name_add(d->names, "Zeroth row", 'r');
apop_name_add(d->names, "Zeroth col", 'c');
apop_data_set(d, 8, 0, 27);
assert(apop_data_get(d, 8, .colname="Zeroth") == 27);
double *x = apop_data_ptr(d, .col=7, .rowname="Zeroth");
*x = 270;
assert(apop_data_get(d, 0, 7) == 270);
//apop_data set holding a scalar:
apop_data_set(s, .val=12);
assert(apop_data_get(s) == 12);
//apop_data set holding a vector:
for (int i=0; i< 12; i++) apop_data_set(s, i, .val=i*10);
assert(apop_data_get(s,3) == 30);

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:

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.

Function Documentation

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.

Parameters
dataThe data set. Must not be NULL.
rowThe row number of the desired element. If rowname==NULL, default is zero.
colThe column number of the desired element. -1 indicates the vector. If colname==NULL, default is zero.
rownameThe row name of the desired element. If NULL, use the row number.
colnameThe column name of the desired element. If NULL, use the column number.
pageThe case-insensitive name of the page on which the element is found. If NULL, use first page.
Returns
The value at the given location.
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.

  • If a NULL vector or matrix (as the case may be), stop (unless apop_opts.stop_on_warning='n', then return NULL).
  • If the row/column you requested is outside the bounds of the matrix (or the name isn't found), always return NULL.
  • See the set/get page for details.
Parameters
dataThe data set. Must not be NULL.
rowThe row number of the desired element. If rowname==NULL, default is zero.
colThe column number of the desired element. -1 indicates the vector. If colname==NULL, default is zero.
rownameThe row name of the desired element. If NULL, use the row number.
colnameThe column name of the desired element. If NULL, use the column number.
pageThe case-insensitive name of the page on which the element is found. If NULL, use first page.
Returns
A pointer to the element.
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:

1  apop_data_set(d, 3, 8, 5);
2  apop_data_set(d, .row = 3, .col=8, .val=5);
3  apop_data_set(d, .row = 3, .colname="Column 8", .val=5);
4 //but:
5  apop_data_set(d, .row = 3, .colname="Column 8", 5); //invalid---the value doesn't follow the colname.
Returns
0=OK, -1=error (couldn't find row/column name, or you asked for a location outside the vector/matrix bounds).
  • The error codes for out-of-bounds errors are thread-safe iff you are have a C11-compliant compiler (thanks to the _Thread_local keyword) or a version of GCC with the __thread extension enabled.

See the set/get page for details.

Parameters
dataThe data set. Must not be NULL.
rowThe row number of the desired element. If rowname==NULL, default is zero.
colThe column number of the desired element. -1 indicates the vector. If colname==NULL, default is zero.
rownameThe row name of the desired element. If NULL, use the row number.
colnameThe column name of the desired element. If NULL, use the column number.
pageThe case-insensitive name of the page on which the element is found. If NULL, use first page.
valThe value to give the point.
Returns
The value at the given location.

Autogenerated by doxygen on Sun Oct 26 2014 (Debian 0.999b+ds3-2).