M4RI 20200125
io.h File Reference

Input/output routines for matrices. More...

#include <m4ri/m4ri_config.h>
#include <m4ri/mzd.h>

Go to the source code of this file.

Functions

void mzd_fprint_row (FILE *stream, mzd_t const *M, const rci_t i)
 Print row i of M to an output stream.
 
static void mzd_print_row (mzd_t const *M, const rci_t i)
 Print row i of M to stdout.
 
static void mzd_fprint (FILE *stream, mzd_t const *M)
 Print a matrix to an output stream.
 
static void mzd_print (mzd_t const *M)
 Print a matrix to stdout.
 
void mzd_info (const mzd_t *A, int do_rank)
 Print compact information about the matrix to stdout.
 
mzd_tmzd_from_jcf (const char *fn, int verbose)
 Read matrix from ASCII file in JCF format.
 
mzd_tmzd_from_str (rci_t m, rci_t n, const char *str)
 Create matrix from dense ASCII string.
 

Detailed Description

Input/output routines for matrices.

Author
Martin Albrecht marti.nosp@m.nral.nosp@m.brech.nosp@m.t@go.nosp@m.oglem.nosp@m.ail..nosp@m.com

Function Documentation

◆ mzd_fprint()

static void mzd_fprint ( FILE * stream,
mzd_t const * M )
inlinestatic

Print a matrix to an output stream.

The output will contain colons between every 4-th column.

Parameters
streamOutput stream
MMatrix

◆ mzd_fprint_row()

void mzd_fprint_row ( FILE * stream,
mzd_t const * M,
const rci_t i )

Print row i of M to an output stream.

The output will contain colons between every 4-th column.

Parameters
streamOutput stream
MMatrix
iRow to print

◆ mzd_from_jcf()

mzd_t * mzd_from_jcf ( const char * fn,
int verbose )

Read matrix from ASCII file in JCF format.

The format is as follows:

nrows ncols modulus
nonzero_entries_upper_bound
column_index

where a negative column_index indicates a row_index increase by one and a non-zero entry at index -column_index.

Note
the JCF format is one-based in contrast to everything else in this library which is zero-based.

For example, a valid input is:

3 2 2
3

-2
-1
-2

which produces the matrix

[0 1]
[1 0]
[0 1]
Parameters
fnFilename
verbosePrint error message to stdout if != 0

◆ mzd_from_str()

mzd_t * mzd_from_str ( rci_t m,
rci_t n,
const char * str )

Create matrix from dense ASCII string.

The provided string is parsed in row major ordering, i.e. the first entry is writen to A[0,0], the second entry to A[0,1] etc.

For example, calling

mzd_t *A = mzd_from_str(4, 4, "1000010000100001");

would create a 4 x 4 identity matrix.

Parameters
mNumber of rows
nNimber of columns
strString containing ASCII zeros and ones of length m*n

◆ mzd_info()

void mzd_info ( const mzd_t * A,
int do_rank )

Print compact information about the matrix to stdout.

Prints number of rows, number of columns, density (and rank).

Parameters
AMatrix
do_rankAlso display the rank (expensive)

◆ mzd_print()

static void mzd_print ( mzd_t const * M)
inlinestatic

Print a matrix to stdout.

The output will contain colons between every 4-th column.

Parameters
MMatrix

◆ mzd_print_row()

static void mzd_print_row ( mzd_t const * M,
const rci_t i )
inlinestatic

Print row i of M to stdout.

The output will contain colons between every 4-th column.

Parameters
MMatrix
iRow to print