Functionreads a vector in ASCII format from a stream
Syntax C/C++#include <VFstd.h>
void VF_read( fVector X, ui size, FILE *stream );
C++ VecObj#include <OptiVec.h>
void vector<T>::read( FILE *stream );
Pascal/Delphiuses VFstd;
procedure VF_read( X:fVector; size:UIntSize; var Stream:Text );
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_read( fVector d_X, ui size, FILE *stream );
int cudaVF_read_buf( fVector d_X, ui size, FILE *stream, fVector h_Wk );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_read( X:fVector; size:UIntSize; var Stream:FILE ): IntBool;
function cudaVF_read_buf( X:fVector; size:UIntSize; var Stream:FILE; h_Wk:fVector ): IntBool;
Descriptionsize elements are read in ASCII format (up to 80 characters) from stream and stored in X. Normally, this function will be used to import vectors from a program which cannot store numbers in machine format. It can also be used to retrieve vectors previously stored by VF_write. For storing and retrieving intermediate results, however, the function pair VF_store / VF_recall is to be preferred over VF_write / VF_read (see VF_write).

Complex versions:
Real und imaginary parts (cartesian complex) or the Mag and Arg parts (polar complex) 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 (cartesian) or the Arg part (polar) 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.

Whole-number versions except VQI_read:
By default, the numbers to be read are interpreted as decimal numbers. You may use V_setRadix to define any radix between 2 and 36.

GCC Windows specific:In principle, the Windows port of GCC supports the 80-bit floating point type long double. However, the I/O routines rely on the runtime libraries of Visual C++, where 80-bit reals have disappeared a long time ago. This means that VE_read, VCE_read, and VPE_read work only with double precision and, more importantly, within double range. Input numbers outside double range are treated as ±DBL_MAX.
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,
- no function V_setRadix

Error handlingC/C++:
Real, complex and quad versions:
Overflowing numbers are silently truncated to ±HUGE_VAL.
Whole-number versions except VQI_read:
As long as the numbers can be represented as long or unsigned long, overflowing bits are ignored in the 16-bit versions. Numbers beyond the long range yield −1 (signed types) or +HUGE_VAL (unsigned types).
Overflowing numbers or numbers otherwise not conforming to the format requirements lead to an I/O error.

CUDA versions only: cudaV?_read_buf takes a host vector h_Wk as additional argument. The latter serves as buffer memory and needs to be (at least) of the same size as X. By avoiding the need of cudaV?_read to allocate its own buffer memory, cudaV?_read_buf is slightly faster.

Return valuenone
See alsoVF_nread,   VF_write,   VF_store,   VF_recall,   strtod,   strtol

VectorLib Table of Contents  OptiVec home