melder_tensorio.h 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _melder_tensorio_h_
  2. #define _melder_tensorio_h_
  3. /* melder_tensorio.h
  4. *
  5. * Copyright (C) 1992-2018 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. /* The following ANSI-C power trick generates the declarations of 88 functions. */
  21. #define FUNCTION(type,storage) \
  22. void NUMvector_writeText_##storage (const type *v, integer lo, integer hi, MelderFile file, conststring32 name); \
  23. void NUMvector_writeBinary_##storage (const type *v, integer lo, integer hi, FILE *f); \
  24. type * NUMvector_readText_##storage (integer lo, integer hi, MelderReadText text, const char *name); \
  25. type * NUMvector_readBinary_##storage (integer lo, integer hi, FILE *f); \
  26. void NUMmatrix_writeText_##storage (type **v, integer r1, integer r2, integer c1, integer c2, MelderFile file, conststring32 name); \
  27. void NUMmatrix_writeBinary_##storage (type **v, integer r1, integer r2, integer c1, integer c2, FILE *f); \
  28. type ** NUMmatrix_readText_##storage (integer r1, integer r2, integer c1, integer c2, MelderReadText text, const char *name); \
  29. type ** NUMmatrix_readBinary_##storage (integer r1, integer r2, integer c1, integer c2, FILE *f);
  30. FUNCTION (signed char, i8)
  31. FUNCTION (int, i16)
  32. FUNCTION (long, i32)
  33. FUNCTION (integer, integer32BE)
  34. FUNCTION (integer, integer16BE)
  35. FUNCTION (unsigned char, u8)
  36. FUNCTION (unsigned int, u16)
  37. FUNCTION (unsigned long, u32)
  38. FUNCTION (double, r32)
  39. FUNCTION (double, r64)
  40. FUNCTION (dcomplex, c64)
  41. FUNCTION (dcomplex, c128)
  42. #undef FUNCTION
  43. /*
  44. void NUMvector_writeBinary_r64 (const double *v, integer lo, integer hi, FILE *f); // etc
  45. write the vector elements v [lo..hi] as machine-independent
  46. binary data to the stream f.
  47. Throw an error message if anything went wrong.
  48. The vectors need not have been created by NUM...vector.
  49. double * NUMvector_readText_r64 (integer lo, integer hi, MelderReadText text, const char *name); // etc
  50. create and read a vector as text.
  51. Throw an error message if anything went wrong.
  52. Every element is supposed to be on the beginning of a line.
  53. double * NUMvector_readBinary_r64 (integer lo, integer hi, FILE *f); // etc
  54. create and read a vector as machine-independent binary data from the stream f.
  55. Throw an error message if anything went wrong.
  56. void NUMvector_writeText_r64 (const double *v, integer lo, integer hi, MelderFile file, conststring32 name); // etc
  57. write the vector elements v [lo..hi] as text to the open file,
  58. each element on its own line, preceded by "name [index]: ".
  59. Throw an error message if anything went wrong.
  60. The vectors need not have been created by NUMvector.
  61. void NUMmatrix_writeText_r64 (double **m, integer r1, integer r2, integer c1, integer c2, MelderFile file, conststring32 name); // etc
  62. write the matrix elements m [r1..r2] [c1..c2] as text to the open file.
  63. Throw an error message if anything went wrong.
  64. The matrices need not have been created by NUMmatrix.
  65. void NUMmatrix_writeBinary_r64 (double **m, integer r1, integer r2, integer c1, integer c2, FILE *f); // etc
  66. write the matrix elements m [r1..r2] [c1..c2] as machine-independent
  67. binary data to the stream f.
  68. Throw an error message if anything went wrong.
  69. The matrices need not have been created by NUMmatrix.
  70. double ** NUMmatrix_readText_r64 (integer r1, integer r2, integer c1, integer c2, MelderReadText text, const char *name); // etc
  71. create and read a matrix as text.
  72. Throw an error message if anything went wrong.
  73. double ** NUMmatrix_readBinary_r64 (integer r1, integer r2, integer c1, integer c2, FILE *f); // etc
  74. create and read a matrix as machine-independent binary data from the stream f.
  75. Throw an error message if anything went wrong.
  76. */
  77. /* End of file melder_tensorio.h */
  78. #endif