JWS C Library
C language utility library
matblock_io.c File Reference

Definitions for I/O operations on a Matblock container. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include <assert.h>
#include <ctype.h>
#include "jwsc/base/error.h"
#include "jwsc/base/file_io.h"
#include "jwsc/math/complex.h"
#include "jwsc/matblock/matblock.h"
#include "jwsc/matblock/matblock_io.h"
Include dependency graph for matblock_io.c:

Go to the source code of this file.

Functions

read_matblock_with_header

Reads a matblock with a header from a file.

Errorread_matblock_with_header_u32 (Matblock_u32 **m_out, const char *fname)
 Reads a 32-bit unsigned integer matblock.
Errorread_matblock_with_header_i32 (Matblock_i32 **m_out, const char *fname)
 Reads a 32-bit signed integer matblock.
Errorread_matblock_with_header_i64 (Matblock_i64 **m_out, const char *fname)
 Reads a 64-bit signed integer matblock.
Errorread_matblock_with_header_f (Matblock_f **m_out, const char *fname)
 Reads a single precision floating point matblock.
Errorread_matblock_with_header_d (Matblock_d **m_out, const char *fname)
 Reads a double precision floating point matblock.
Errorread_matblock_with_header_cf (Matblock_cf **m_out, const char *fname)
 Reads a single precision complex floating point matblock.
Errorread_matblock_with_header_cd (Matblock_cd **m_out, const char *fname)
 Reads a double precision complex floating point matblock.
read_matblock_with_header_fp

Reads a matblock with a header from an opened file.

Errorread_matblock_with_header_fp_u32 (Matblock_u32 **m_out, FILE *fp)
 Reads a 32-bit unsigned integer matblock.
Errorread_matblock_with_header_fp_i32 (Matblock_i32 **m_out, FILE *fp)
 Reads a 32-bit signed integer matblock.
Errorread_matblock_with_header_fp_i64 (Matblock_i64 **m_out, FILE *fp)
 Reads a 64-bit signed integer matblock.
Errorread_matblock_with_header_fp_f (Matblock_f **m_out, FILE *fp)
 Reads a single precision floating point matblock.
Errorread_matblock_with_header_fp_d (Matblock_d **m_out, FILE *fp)
 Reads a double precision floating point matblock.
Errorread_matblock_with_header_fp_cf (Matblock_cf **m_out, FILE *fp)
 Reads a single precision complex floating point matblock.
Errorread_matblock_with_header_fp_cd (Matblock_cd **m_out, FILE *fp)
 Reads a double precision complex floating point matblock.
write_matblock_with_header

Writes a matblock with a header to a file.

Errorwrite_matblock_with_header_u32 (const Matblock_u32 *m, const char *fname)
 Writes a 32-bit unsigned integer matblock.
Errorwrite_matblock_with_header_i32 (const Matblock_i32 *m, const char *fname)
 Writes a 32-bit signed integer matblock.
Errorwrite_matblock_with_header_i64 (const Matblock_i64 *m, const char *fname)
 Writes a 64-bit signed integer matblock.
Errorwrite_matblock_with_header_f (const Matblock_f *m, const char *fname)
 Writes a single precision floating point matblock.
Errorwrite_matblock_with_header_d (const Matblock_d *m, const char *fname)
 Writes a double precision floating point matblock.
Errorwrite_matblock_with_header_cf (const Matblock_cf *m, const char *fname)
 Writes a single precision complex floating point matblock.
Errorwrite_matblock_with_header_cd (const Matblock_cd *m, const char *fname)
 Writes a double precision complex floating point matblock.
write_matblock_with_header_fp

Writes a matblock with a header to an opened file.

Errorwrite_matblock_with_header_fp_u32 (const Matblock_u32 *m, FILE *fp)
 Writes a 32-bit unsigned integer matblock.
Errorwrite_matblock_with_header_fp_i32 (const Matblock_i32 *m, FILE *fp)
 Writes a 32-bit signed integer matblock.
Errorwrite_matblock_with_header_fp_i64 (const Matblock_i64 *m, FILE *fp)
 Writes a 64-bit signed integer matblock.
Errorwrite_matblock_with_header_fp_f (const Matblock_f *m, FILE *fp)
 Writes a single precision floating point matblock.
Errorwrite_matblock_with_header_fp_d (const Matblock_d *m, FILE *fp)
 Writes a double precision floating point matblock.
Errorwrite_matblock_with_header_fp_cf (const Matblock_cf *m, FILE *fp)
 Writes a single precision complex floating point matblock.
Errorwrite_matblock_with_header_fp_cd (const Matblock_cd *m, FILE *fp)
 Writes a double precision complex floating point matblock.

Detailed Description

Definitions for I/O operations on a Matblock container.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file matblock_io.c.


Function Documentation

Error* read_matblock_with_header_u32 ( Matblock_u32 **  m_out,
const char *  fname 
)

Reads a 32-bit unsigned integer matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 94 of file matblock_io.c.

Error* read_matblock_with_header_i32 ( Matblock_i32 **  m_out,
const char *  fname 
)

Reads a 32-bit signed integer matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 144 of file matblock_io.c.

Error* read_matblock_with_header_i64 ( Matblock_i64 **  m_out,
const char *  fname 
)

Reads a 64-bit signed integer matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 194 of file matblock_io.c.

Error* read_matblock_with_header_f ( Matblock_f **  m_out,
const char *  fname 
)

Reads a single precision floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 244 of file matblock_io.c.

Error* read_matblock_with_header_d ( Matblock_d **  m_out,
const char *  fname 
)

Reads a double precision floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 294 of file matblock_io.c.

Error* read_matblock_with_header_cf ( Matblock_cf **  m_out,
const char *  fname 
)

Reads a single precision complex floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 344 of file matblock_io.c.

Error* read_matblock_with_header_cd ( Matblock_cd **  m_out,
const char *  fname 
)

Reads a double precision complex floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 394 of file matblock_io.c.

Error* read_matblock_with_header_fp_u32 ( Matblock_u32 **  m_out,
FILE *  fp 
)

Reads a 32-bit unsigned integer matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fpFile to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 456 of file matblock_io.c.

Error* read_matblock_with_header_fp_i32 ( Matblock_i32 **  m_out,
FILE *  fp 
)

Reads a 32-bit signed integer matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fpFile to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 520 of file matblock_io.c.

Error* read_matblock_with_header_fp_i64 ( Matblock_i64 **  m_out,
FILE *  fp 
)

Reads a 64-bit signed integer matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fpFile to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 584 of file matblock_io.c.

Error* read_matblock_with_header_fp_f ( Matblock_f **  m_out,
FILE *  fp 
)

Reads a single precision floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fpFile to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 648 of file matblock_io.c.

Error* read_matblock_with_header_fp_d ( Matblock_d **  m_out,
FILE *  fp 
)

Reads a double precision floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fpFile to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 712 of file matblock_io.c.

Error* read_matblock_with_header_fp_cf ( Matblock_cf **  m_out,
FILE *  fp 
)

Reads a single precision complex floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3
 4 5 6
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fpFile to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 776 of file matblock_io.c.

Error* read_matblock_with_header_fp_cd ( Matblock_cd **  m_out,
FILE *  fp 
)

Reads a double precision complex floating point matblock.

Format of the matblock in the file is expected to a line containing the number of rows and columns followed by sequential lines containing rows of the matblock. Blank lines and lines beginning with '#' prior to the first row of the matblock are skipped. For example,

 # Comment
 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
m_outResult parameter. If *m_out is NULL, a matblock is allocated; otherwise its space is re-used.
fpFile to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL.
  • ERROR_IO Either there was a problem reading the file, or the matblock in the file is not formatted properly.

Definition at line 841 of file matblock_io.c.

Error* write_matblock_with_header_u32 ( const Matblock_u32 m,
const char *  fname 
)

Writes a 32-bit unsigned integer matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 912 of file matblock_io.c.

Error* write_matblock_with_header_i32 ( const Matblock_i32 m,
const char *  fname 
)

Writes a 32-bit signed integer matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 949 of file matblock_io.c.

Error* write_matblock_with_header_i64 ( const Matblock_i64 m,
const char *  fname 
)

Writes a 64-bit signed integer matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 985 of file matblock_io.c.

Error* write_matblock_with_header_f ( const Matblock_f m,
const char *  fname 
)

Writes a single precision floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1022 of file matblock_io.c.

Error* write_matblock_with_header_d ( const Matblock_d m,
const char *  fname 
)

Writes a double precision floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1059 of file matblock_io.c.

Error* write_matblock_with_header_cf ( const Matblock_cf m,
const char *  fname 
)

Writes a single precision complex floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3
 4 5 6
 7 8 9
Parameters:
mMatblock to write.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1096 of file matblock_io.c.

Error* write_matblock_with_header_cd ( const Matblock_cd m,
const char *  fname 
)

Writes a double precision complex floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6
 7 8 9
Parameters:
mMatblock to write.
fnameName of the file to read the matblock from.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1133 of file matblock_io.c.

Error* write_matblock_with_header_fp_u32 ( const Matblock_u32 m,
FILE *  fp 
)

Writes a 32-bit unsigned integer matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fpFile to write the matblock to.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1182 of file matblock_io.c.

Error* write_matblock_with_header_fp_i32 ( const Matblock_i32 m,
FILE *  fp 
)

Writes a 32-bit signed integer matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fpFile to write the matblock to.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1226 of file matblock_io.c.

Error* write_matblock_with_header_fp_i64 ( const Matblock_i64 m,
FILE *  fp 
)

Writes a 64-bit signed integer matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fpFile to write the matblock to.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1270 of file matblock_io.c.

Error* write_matblock_with_header_fp_f ( const Matblock_f m,
FILE *  fp 
)

Writes a single precision floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fpFile to write the matblock to.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1314 of file matblock_io.c.

Error* write_matblock_with_header_fp_d ( const Matblock_d m,
FILE *  fp 
)

Writes a double precision floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3 
 4 5 6 
 7 8 9
Parameters:
mMatblock to write.
fpFile to write the matblock to.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1358 of file matblock_io.c.

Error* write_matblock_with_header_fp_cf ( const Matblock_cf m,
FILE *  fp 
)

Writes a single precision complex floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3
 4 5 6
 7 8 9
Parameters:
mMatblock to write.
fpFile to write the matblock to.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1402 of file matblock_io.c.

Error* write_matblock_with_header_fp_cd ( const Matblock_cd m,
FILE *  fp 
)

Writes a double precision complex floating point matblock.

Format of the matblock written is a line containing the number of elements followed by sequential lines containg rows of the matblock. For example,

 num_mats=3 num_rows=1 num_cols=3
 1 2 3
 4 5 6
 7 8 9
Parameters:
mMatblock to write.
fpFile to write the matblock to.
Returns:
On success, NULL is returned; otherwise an Error is returned.
  • ERROR_IO There was a problem writing to the file.

Definition at line 1447 of file matblock_io.c.