FunctionStore a vector in binary format into a stream
Syntax C/C++#include <VFstd.h>
int VF_store( FILE *stream, fVector X, ui size );
C++ VecObj#include <OptiVec.h>
int vector<T>::store( FILE *stream );
Pascal/Delphiuses VFstd;
function VF_store( var Stream:FILE; X:fVector; size:UIntSize ): Integer;
CUDA function C/C++#include <cudaVFstd.h>
void cudaVF_store( FILE *stream, fVector d_X, ui size );
void cudaVF_store_buf( FILE *stream, fVector d_X, ui size, fVector h_Wk );
CUDA function Pascal/Delphiuses VFstd;
procedure cudaVF_store( var Stream:FILE; d_X:fVector; size:UIntSize );
procedure cudaVF_store_buf( var Stream:FILE; d_X:fVector; size:UIntSize; h_Wk:fVector );
Descriptionsize elements of X are written to stream in binary format. The stream must be already open for binary write operations.
The VecObj version stores not only the vector elements, but the whole vector object by first storing size. Please note that VF_recall etc. can only read vectors stored with VF_store etc., whereas the VecObj function recall is used to retrieve vector objects stored with the VecObj function store. You can, however, employ the calling sequence
VUI_store( stream, &size, 1 );
VF_store( stream, X, size );   /* C/C++ */

VU_store( stream, @size, 1 );
VF_store( stream, X, size );   (* Pascal/Delphi *)

to make the stored vector X readable as a vector object later.

CUDA versions only: cudaV?_store_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?_store to allocate its own buffer memory, cudaV?_store_buf is slightly faster.

GCC and CLang only: GCC and CLang (including BCC32C) pad the 10-byte data type long double to 12 or 16 bytes in memory (12 byte in 32-bit, 16 byte in 64 bit). In order to maintain compatibility of the generated data files between compilers, the VE_store / VE_recall, VCE_store / VCE_recall, and VPE_store / VPE_recall pairs always use 10-byte storage on disk.

Thread safetyDifferent threads may safely call any functions of the VF_ / MF_store and VF_ / MF_recall families simultaneously, as long as the refer to different streams. If they have to access one and the same stream, however, the user must take appropriate measures (critical sections, mutexes), in order to prevent race conditions.
Error handlingError handling is performed by the C function fwrite or the Delphi function BlockWrite, on which VF_store etc. are based.
Return value0, if successful; otherwise 1. In order to obtain more information, inspect errno (C/C++) or IOResult (Delphi).
See alsoVF_recall,   VF_write,   VF_cprint,   VF_print

VectorLib Table of Contents  OptiVec home