Patterns in static

Apophenia

conversions.h File Reference

Go to the source code of this file.

Defines

Functions


Detailed Description

Convenience functions to convert among vectors (gsl_vector), matrices (gsl_matrix), arrays (double **), and database tables


Define Documentation

#define apop_data_fill ( in,
...   )     apop_data_fill_base((in), (double []) {__VA_ARGS__})

Fill a pre-allocated data set with values.

For example:

#include <apop.h>

int main(){
  apop_data *a =apop_data_alloc(2,2,2);
  double    eight   = 8.0;
    apop_data_fill(a, 8, 2.2, eight/2,
                      0, 6.0, eight);
    apop_data_show(a);
}

Warning: I need as many arguments as the size of the data set, and can't count them for you. Too many will be ignored; too few will produce unpredictable results, which may include padding your matrix with garbage or a simple segfault.

I assume that vector->size==matrix->size1; otherwise I just use matrix->size1.

Parameters:
in An apop_data set (that you have already allocated).
... A series of at least as many floating-point values as there are blanks in the data set.
Returns:
A pointer to the same data set that was input.
#define apop_matrix_fill ( in,
...   )     apop_matrix_fill_base((in), (double []) {__VA_ARGS__})

Fill a pre-allocated gsl_matrix with values.

The values should be in row-major order (i.e., list the entire first row, followed by the second row, et cetera). If your data is column-major, then try calling gsl_matrix_transpose after this function.

See apop_data_alloc for a relevant example. See also apop_vector_alloc.

I need as many arguments as the size of the matrix. Too many will be ignored; too few will produce unpredictable results, which may include padding your matrix with garbage or a simple segfault.

Parameters:
in A gsl_matrix (that you have already allocated).
... A series of exactly as many floating-point values as there are blanks in the matrix.
Returns:
A pointer to the same matrix that was input.
#define apop_vector_fill ( in,
...   )     apop_vector_fill_base((in), (double []) {__VA_ARGS__})

Fill a pre-allocated gsl_vector with values.

See apop_data_alloc for a relevant example. See also apop_matrix_alloc.

Warning: I need as many arguments as the size of the vector, and can't count them for you. Too many will be ignored; too few will produce unpredictable results, which may include padding your vector with garbage or a simple segfault.

Parameters:
in A gsl_vector (that you have already allocated).
... A series of exactly as many values as there are spaces in the vector.
Returns:
A pointer to the same vector that was input.

Function Documentation

void apop_crosstab_to_db ( apop_data in,
char *  tabname,
char *  row_col_name,
char *  col_col_name,
char *  data_col_name 
)

See apop_db_to_crosstab for the storyline; this is the complement.

apop_data* apop_db_to_crosstab ( char *  tabname,
char *  r1,
char *  r2,
char *  datacol 
)

Give the name of a table in the database, and names of three of its columns: the x-dimension, the y-dimension, and the data. the output is a 2D matrix with rows indexed by r1 and cols by r2.

Parameters:
tabname The database table I'm querying. Anything that will work inside a from clause is OK, such as a subquery in parens.
r1 The column of the data set that will indicate the rows of the output crosstab
r2 The column of the data set that will indicate the columns of the output crosstab
datacol The column of the data set holding the data for the cells of the crosstab

SourceForge.net Logo

Autogenerated by doxygen on 23 Nov 2009.