Detailed Description

These functions permit matrices to be initialized in a variety of ways and provide matrix display, conversion to string for I/O, and conversion to binary format for efficient interprocess communication and across networks.

This function can return an error matrix of type ml_bad_string_format if the provided string is not a properly formatted matrix.

Parameters:

s

Character string used to build the matrix.

ml_matrix::ml_matrix

(

void *

bf

)

[inherited]

Constructs a matrix from a binary format as created by ml_matrix::to_binary(). By far the most efficient way to send matrix data over a network or transfer between applications is using the binary format, though it is possible to also use the string format as well.

This function can return an error matrix of type ml_invalid_buffer if the provided binary buffer does not contain a valid binary-format buffer.

Parameters:

bf

Binary string used to build the matrix.

ml_matrix::ml_matrix

(

FILE *

f,

int *

linenum = NULL

)

[inherited]

Constructs a matrix from a string format as used in MATLAB or created by ml_matrix::to_string(). The string is read from the provided file.

This function can return an error matrix of type ml_bad_file_pointer if the provided file is NULL, or of type ml_bad_string_format if the file does not contain a valid string-format matrix.

Parameters:

f

The file used to read the matrix from.

linenum

A pointer to an int giving the current line number within the file. The number will be incremented each time a newline character is encountered.

char * ml_matrix::to_string

(

int

human_readable = 0

)

[inherited]

Returns a character string representation of the matrix

Parameters:

human_readable

if nonzero, includes spaces and newlines to make the matrix easy for a human reader to view. If zero, removes extraneous spaces and newlines to represent the matrix in a more compact, one-line representation that is easier to parse. Note that the matrix constructor can read either version.

Returns:

String representation of the matrix in "MATLAB readable" format

void ml_matrix::display

(

char *

s = NULL

)

[inherited]

Display function. Formats the matrix in a human readable fashion and prints to standard out.

void * ml_matrix::to_binary

(

unsigned int *

size = NULL

)

const [inherited]

Creates binary representation of matrix for efficient transfer. This function allocates memory that must be freed by the caller.

Parameters:

size

Pointer to an integer in which to place the size of the allocated buffer or NULL if the caller is not interested in the size.