| 1 | #ifndef _melder_tensorio_h_ |
| 2 | #define _melder_tensorio_h_ |
| 3 | /* melder_tensorio.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2020 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /* Declaring 192 functions. */ |
| 22 | #define FUNCTION(T,storage) \ |
| 23 | void vector_writeText_##storage (const constvector<T>& vec, MelderFile file, conststring32 name); \ |
| 24 | void vector_writeBinary_##storage (const constvector<T>& vec, FILE *f); \ |
| 25 | autovector<T> vector_readText_##storage (integer size, MelderReadText text, const char *name); \ |
| 26 | autovector<T> vector_readBinary_##storage (integer size, FILE *f); \ |
| 27 | void matrix_writeText_##storage (const constmatrix<T>& mat, MelderFile file, conststring32 name); \ |
| 28 | void matrix_writeBinary_##storage (const constmatrix<T>& mat, FILE *f); \ |
| 29 | automatrix<T> matrix_readText_##storage (integer nrow, integer ncol, MelderReadText text, const char *name); \ |
| 30 | automatrix<T> matrix_readBinary_##storage (integer nrow, integer ncol, FILE *f); \ |
| 31 | void tensor3_writeText_##storage (const consttensor3<T>& mat, MelderFile file, conststring32 name); \ |
| 32 | void tensor3_writeBinary_##storage (const consttensor3<T>& mat, FILE *f); \ |
| 33 | autotensor3<T> tensor3_readText_##storage (integer ndim1, integer ndim2, integer ndim3, MelderReadText text, const char *name); \ |
| 34 | autotensor3<T> tensor3_readBinary_##storage (integer ndim1, integer ndim2, integer ndim3, FILE *f); |
| 35 | |
| 36 | FUNCTION (signed char, i8) |
| 37 | FUNCTION (int, i16) |
| 38 | FUNCTION (long, i32) |
| 39 | FUNCTION (integer, integer32BE) |
| 40 | FUNCTION (integer, integer16BE) |
| 41 | FUNCTION (unsigned char, u8) |
| 42 | FUNCTION (unsigned int, u16) |
| 43 | FUNCTION (unsigned long, u32) |
| 44 | FUNCTION (double, r32) |
| 45 | FUNCTION (double, r64) |
| 46 | FUNCTION (dcomplex, c64) |
| 47 | FUNCTION (dcomplex, c128) |
| 48 | FUNCTION (bool, eb) |
| 49 | #undef FUNCTION |
| 50 | |
| 51 | /* |
| 52 | void vector_writeBinary_r64 (constvector <double> const& vec, FILE *f); // etc |
| 53 | write the vector elements as machine-independent binary data to the stream f. |
| 54 | Throw an error message if anything went wrong. |
| 55 | autovector <double> vector_readText_r64 (integer nrow, MelderReadText text, const char *name); // etc |
| 56 | create and read a vector as text. |
| 57 | Throw an error message if anything went wrong. |
| 58 | Every element is supposed to be on the beginning of a line. |
| 59 | autovector <double> vector_readBinary_r64 (integer nrow, FILE *f); // etc |
| 60 | create and read a vector as machine-independent binary data from the stream f. |
| 61 | Throw an error message if anything went wrong. |
| 62 | void vector_writeText_r64 (constvector <double> const& vec, MelderFile file, conststring32 name); // etc |
| 63 | write the vector elements as text to the open file, |
| 64 | each element on its own line, preceded by "name [index]: ". |
| 65 | Throw an error message if anything went wrong. |
| 66 | void matrix_writeText_r64 (constmatrix <double> const& mat, MelderFile file, conststring32 name); // etc |
| 67 | write the matrix elements as text to the open file. |
| 68 | Throw an error message if anything went wrong. |
| 69 | void matrix_writeBinary_r64 (constmatrix <double> const& mat, FILE *f); // etc |
| 70 | write the matrix elements as machine-independent binary data to the stream f. |
| 71 | Throw an error message if anything went wrong. |
| 72 | automatrix <double> matrix_readText_r64 (integer nrow, integer ncol, MelderReadText text, const char *name); // etc |
| 73 | create and read a matrix as text. |
| 74 | Throw an error message if anything went wrong. |
| 75 | automatrix <double> matrix_readBinary_r64 (integer nrow, integer ncol, FILE *f); // etc |
| 76 | create and read a matrix as machine-independent binary data from the stream f. |
| 77 | Throw an error message if anything went wrong. |
| 78 | */ |
| 79 | |
| 80 | /* End of file melder_tensorio.h */ |
| 81 | #endif |