Patterns in static

Apophenia

Modules | Functions
Printing to the screen or a text file

Modules

 Assorted printing functions
 

Functions

void apop_model_print (apop_model *print_me, FILE *ap)
 
void apop_data_show (const apop_data *in)
 
apop_dataapop_data_summarize (apop_data *indata)
 

Detailed Description

Most functions print only to the screen, but the matrix and vector printing functions will let you print to a text file as well. The presumption is that statistic estimates are for your own consumption, while you are printing a matrix for import into another program.

Function Documentation

void apop_data_show ( const apop_data in)

This function prettyprints the apop_data set to a screen.

This takes a lot of machinery. I write every last element to a text array, then measure column widths, then print to screen with padding to guarantee that everything lines up. There's no way to have the first element of a column line up with the last unless you interrogate the width of every element in the column, so printing columns really can't be a one-pass process.

So, I produce an apop_data set with no numeric elements and a text element to be filled with the input data set, and then print that. That means that I'll be using (more than) twice the memory to print this. If this is a problem, you can use Assorted printing functions to dump your data to a text file, and view the text file, or print subsets.

For more machine-readable printing, see apop_data_print.

apop_data* apop_data_summarize ( apop_data indata)

Put summary information about the columns of a table (mean, std dev, variance, min, median, max) in a table.

Parameters
indataThe table to be summarized. An apop_data structure.
Returns
An apop_data structure with one row for each column in the original table, and a column for each summary statistic. May have a weights element.
Exceptions
out->error='a'Allocation error.
  • This function gives more columns than you probably want; use apop_data_prune_columns to pick the ones you want to see.
    Todo:
    We should probably let this summarize rows as well.
void apop_model_print ( apop_model print_me,
FILE *  ap 
)

Print the results of an estimation for a human to look over.

Parameters
print_meThe model whose information should be displayed
apThe output stream. If NULL, use stdout. If you'd like something else, use fopen. E.g.:
1 FILE *out =fopen("outfile.txt", "w"); //or "a" to append.
2 apop_model_print(the_model, out);
3 fclose(out); //optional in most cases.
  • The default prints the name, parameters, info, &c. but I check a vtable for alternate methods you define; see Registering new methods in vtables for details. The typedef new functions must conform to and the hash used for lookups are:
1 typedef void (*apop_model_print_type)(apop_model *params, FILE *out);
2 #define apop_model_print_hash(m1) ((m1)->log_likelihood ? (size_t)(m1)->log_likelihood : \
3  (m1)->p ? (size_t)(m1)->p*33 : \
4  (m1)->estimate ? (size_t)(m1)->estimate*33*33 : \
5  (m1)->draw ? (size_t)(m1)->draw*33*27 : \
6  (m1)->cdf ? (size_t)(m1)->cdf*27*27 : 27)
  • All output should fprintf to the input FILE* handle. Apophenia's output routines also accept a file handle; e.g., if the file handle is named out, then if the thismodel print method uses apop_data_print to print the parameters, it must do so via a form like apop_data_print(thismodel->parameters, .output_pipe=ap).
  • Your print method can use both by masking itself for a second:
    1 void print_method(apop_model *in, FILE* ap){
    2  void *temp = in->estimate;
    3  in->estimate = NULL;
    4  apop_model_print(in, ap);
    5  in->estimate = temp;
    6 
    7  printf("Additional info:\n");
    8  ...
    9 }
  • Print methods are intended for human consumption and are subject to change.

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