MF_read MD_read ME_read
MCF_read MCD_read MCE_read
MI_readMBI_readMSI_readMLI_readMQI_read
MU_readMUB_readMUS_readMUL_readMUQ_read
Functionread a matrix in ASCII format from a stream
Syntax C/C++#include <MFstd.h>
void MF_read( fMatrix MA, ui ht, ui len, FILE *stream );
C++ MatObj#include <OptiVec.h>
void matrix<T>::read( FILE *stream );
Pascal/Delphiuses MFstd;
{Delphi version:}
  procedure MF_read( MA:fMatrix; ht, len:UIntSize; var Stream:TextFile );
{Turbo Pascal version:}
  procedure MF_read( MA:fMatrix; ht, len:UIntSize; var Stream:Text );
DescriptionThe matrix MA of ht*len elements is read in ASCII format from stream. Normally, this function will be used to import matrices from a program which cannot store numbers in machine format. It can also be used to retrieve matrices previously stored by MF_write. For storing and retrieving intermediate results, however, the function pair MF_store / MF_recall is to be preferred over MF_write / MF_read (see MF_write).

Cartesian complex versions:
Real und imaginary parts may, but need not, be enclosed in braces { } or brackets ( ). However, you must be consequent: Either all or no element may be written with braces or brackets.
A komma may (but need not) separate the two parts. The imaginary part must always be explicitly specified, even if it is zero.
Examples for legal formats are:
0.3 0.5    (neither braces nor separating komma)
0.3, 0.5    (no braces; separating komma)
{0.3 0.5}    (braces; no separating komma)
(0.3, 0.5)    (brackets and separating komma)

C/C++ specific: The entries to be read must be separated by whitespace (' ', '\n', or '\t'). Additionally, one (!) "non-whitespace" character is tolerated after each entry, if it follows directly after the last digit. After it, there must be one or more whitespace characters.
Pascal/Delphi specific: The entries to be read must be separated by whitespace (' ', #13, or #9).

Whereas the C/C++ version of these functions follows the conventions of the C functions strtod, strtol, etc., the Pascal/Delphi version has to follow the rules applying to the Pascal/Delphi function Read. This makes the Pascal/Delphi version much less flexible than the C version:
- no separation characters allowed other than ' ' and #9,
- no automatic truncation of overflowing numbers

Error handlingC/C++:
Overflowing numbers are silently truncated to ±HUGE_VAL.
Pascal/Delphi:
Overflowing numbers or numbers otherwise not conforming to the format requirements lead to an I/O error.
See alsoMF_write,   VF_nread,   MF_store,   MF_recall,   chapter 14

MatrixLib Table of Contents  OptiVec home