Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

gnn_filewriter : File Output Device.
[gnn_output : Writing sets of vectors.]


Detailed Description

The gnn_filewriter : File Output Device. implements a sequential file output device. The output patterns are written to a given file stream.

This is the datatype for a filewriter. It extends the basic gnn_output : Writing sets of vectors. structure to include the additional pointer to the output samples matrix, and a vector view.

A filewriter, when created, opens the given file in ASCII mode. Alternativelly, you can provide an already opened file pointer. After that, it writes the given samples one after another (line per line) to the opened output stream.

By default, vectors are written line-wise, with the format "g\t" to seperate the elements (of the printed vector). A new format string can be given, of course.

Additionally, a prefix and a postfix format string can be used. The are pre- and post-concatenated to the string containing the vector's elements.

As an example, the following output will be produced without pre- and postfix strings:

 12.345   3.45     8
 0.1247   3.387    0.001
 78.56    5        89.23
 12.2356  0.147    0.235

Using the prefix "Pattern d : [" and postfix "]", the same samples will be printed as:

 Pattern 0 : [12.345   3.45     8 ]
 Pattern 1 : [0.1247   3.387    0.001 ]
 Pattern 2 : [78.56    5        89.23 ]
 Pattern 3 : [12.2356  0.147    0.235 ]

Please note that the prefix contains a "d" substring. This is the one and only allowed format command for the prefix, which will be replaced by the number of the output sample to be written.

Typedefs

typedef _gnn_filewriter gnn_filewriter
 The datatype for a filewriter.


Functions

int gnn_filewriter_put (gnn_output *set, size_t k, const gsl_vector *v)
 The "put" function.

void gnn_filewriter_destroy (gnn_output *set)
 The "destroy" function.

gnn_outputgnn_filewriter_new (FILE *fp)
 Builds a new filewriter device.

gnn_outputgnn_filewriter_with_file_new (const char *filename)
 Builds a new filewriter device with a given filename.

int gnn_filewriter_set_format (gnn_output *set, const char *fmt)
 Sets a new print format.

const char * gnn_filewriter_get_format (gnn_output *set)
 Gets the print format.

int gnn_filewriter_set_prefix (gnn_output *set, const char *prefix)
 Sets a new printing prefix.

const char * gnn_filewriter_get_prefix (gnn_output *set)
 Gets the prefix format string.

int gnn_filewriter_set_postfix (gnn_output *set, const char *postfix)
 Sets a new printing postfix.

const char * gnn_filewriter_get_postfix (gnn_output *set)
 Gets the postfix format string.

int gnn_filewriter_owns_file (gnn_output *set)
 Check if it owns the file.


Typedef Documentation

typedef struct _gnn_filewriter gnn_filewriter
 

Definition at line 98 of file gnn_filewriter.c.


Function Documentation

void gnn_filewriter_destroy gnn_output   set [static]
 

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
k  The index of the pattern to be stored.
v  A pointer to the output vector to be stored.
Returns:
Returns 0 if suceeded.

Definition at line 170 of file gnn_filewriter.c.

const char* gnn_filewriter_get_format gnn_output   set
 

This function returns a pointer to the currently used vector elements print format.

Parameters:
fmt  A format string for double precision values.
Returns:
Returns a pointer to a new gnn_filewriter : File Output Device..

Definition at line 339 of file gnn_filewriter.c.

const char* gnn_filewriter_get_postfix gnn_output   set
 

This function returns a pointer to the currently used postfix string.

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
Returns:
Returns a pointer to the postfix or NULL.

Definition at line 443 of file gnn_filewriter.c.

const char* gnn_filewriter_get_prefix gnn_output   set
 

This function returns a pointer to the currently used prefix string.

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
Returns:
Returns a pointer to the prefix or NULL.

Definition at line 391 of file gnn_filewriter.c.

gnn_output* gnn_filewriter_new FILE *    fp
 

This function creates a new gnn_filewriter : File Output Device. device with the given opened file pointer. When destroyed, the stream won't be closed.

Parameters:
fp  A valid and opened file pointer.
Returns:
Returns a pointer to a new gnn_filewriter : File Output Device..

Definition at line 205 of file gnn_filewriter.c.

int gnn_filewriter_owns_file gnn_output   set
 

This function returns 1 if the gnn_filewriter : File Output Device. owns the file.

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
Returns:
Returns 1 if it owns the file or 0 if not.

Definition at line 465 of file gnn_filewriter.c.

int gnn_filewriter_put gnn_output   set,
size_t    k,
const gsl_vector *    v
[static]
 

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
k  The index of the pattern to be stored.
v  A pointer to the output vector to be stored.
Returns:
Returns 0 if suceeded.

Definition at line 132 of file gnn_filewriter.c.

int gnn_filewriter_set_format gnn_output   set,
const char *    fmt
 

This function sets a new print format for the vector elements of the samples. The default is "%g\t", which separates the elements by tabs. The format specifier should contain a valid double-precision specifier, like "%f ", "%e " or "%g " (do not forget to include a separator).

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
fmt  A format string for double precision values.
Returns:
Returns a pointer to a new gnn_filewriter : File Output Device..

Definition at line 308 of file gnn_filewriter.c.

int gnn_filewriter_set_postfix gnn_output   set,
const char *    postfix
 

This function sets a new printing postfix, which will be postpended to every printed output vector. This string can contain at most one integer format specifier, like "N %d :". The placeholder will be filled with the number of the written pattern.

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
prefix  A postfix format string or NULL.
Returns:
Returns 0 if succeeded.

Definition at line 416 of file gnn_filewriter.c.

int gnn_filewriter_set_prefix gnn_output   set,
const char *    prefix
 

This function sets a new printing prefix, which will be prepended to every printed output vector. This string can contain at most one integer format specifier, like "N %d :". The placeholder will be filled with the number of the written pattern.

Parameters:
set  A pointer to a gnn_filewriter : File Output Device..
prefix  A prefix format string or NULL.
Returns:
Returns 0 if succeeded.

Definition at line 364 of file gnn_filewriter.c.

gnn_output* gnn_filewriter_with_file_new const char *    filename
 

This function creates a new gnn_filewriter : File Output Device. device. It opens the file filename for printing. The gnn_filewriter : File Output Device. is the owner of the file and closes it when destroyed.

Parameters:
filename  A string containing the file name for printing.
Returns:
Returns a pointer to a new gnn_filewriter : File Output Device..

Definition at line 262 of file gnn_filewriter.c.


Generated on Sun Jun 13 20:51:43 2004 for libgnn Gradient Retropropagation Machine Library by doxygen1.2.18