class SGFVector_d : public HCL_Vector_d

SGFVector is an out-of-core vector class, implementing sampled functions on a uniform rectilinear grid as HCL_Vectors

Inheritance:


Public

Constructors and destructor
SGFVector_d ()
Default constructor
SGFVector_d ( const SGFVector_d & S )
Copy constructor - disabled
SGFVector_d ( char * fname, int Save = 0 )
Usual constructor for old data
SGFVector_d ( const SGFSpace_d & s, char * fname = NULL, int Save = 1)
Usual constructor for new data
~SGFVector_d ()
Destructor
Header and data access methods
int NumRecs ()
returns number of records in data set
int BufLen ()
returns length in words of data buffer
int GetHdrInt (char * name)
Return integer header word by keyword
double GetHdrReal (char * name)
Return real (FLOAT or DOUBLE) header word by keyword
char* GetHdrString (char * name)
Return header string by keyword
double* Data ()
Return pointer to data buffer
Record access methods.
int Next ()
Standard iterator
void Rewind ()
Reposition at beginning of data set
void Seek ( int irec, int load=1 )
Reposition at record irec
void Get ()
Read current record into data buffer
void Put ()
Write data buffer on current record
Write method
virtual ostream& Write ( ostream & str )
Prints SGFSpace header table and name of binary data file

Inherited from HCL_Vector_d:

Public Methods

virtual ostream& Write(ostream &)

Public

Vector operations (z is *this, which is C++-ese for the instance of the class invoking the method)

virtual void Copy( const HCL_Vector_d & x )
z <-- x
virtual void Neg()
z <-- -z
virtual void Mul( const double & a )
z <-- a*z
virtual void Add( const HCL_Vector_d & x )
z <-- z + x
virtual void Mul( const double & a, const HCL_Vector_d & x )
z <-- a*x
virtual void Add( const HCL_Vector_d & x, const HCL_Vector_d & y )
z <-- x + y
virtual void Sub( const HCL_Vector_d & x )
z <-- z - x
virtual void Sub(const HCL_Vector_d & x, const HCL_Vector_d & y )
z <-- x - y
virtual void ScaleAdd(const double & a, const HCL_Vector_d & x )
z <-- a*z + x
virtual void AddScale(const double & a, const HCL_Vector_d & x )
z <-- z + a*x
virtual void AddScale(const double & a, const HCL_Vector_d & x, const HCL_Vector_d & y )
z <-- x + a*y
virtual double Inner( const HCL_Vector_d & x )
Inner product of z with x.
virtual double Norm()
Norm of z.
virtual double Norm2()
Norm squared of z.
virtual HCL_VectorSpace_d& Space()
Returns a reference to the space of which z is a member
virtual void Zero()
z <-- 0
virtual void Random()
Returns a "random" vector

Inherited from HCL_Base:

Public Methods

int Count()
void DecCount()
void IncCount()

Private Fields

int ReferenceCount

Documentation

SGFVector is an out-of-core vector class, implementing sampled functions on a uniform rectilinear grid as HCL_Vectors. SGF stands for Sampled Grid Function. It designates an out-of-core data structure for arbitrary (< 10) dimensional regularly sampled real single and double precision hypercubical data, plus auxiliary scalar data (integer, single or double precision floating point, or string) describing the grid geometry and other information necessary to properly interpret the data. Many natural data types in science and engineering fit this description. Other types of data do not conform to the SGF design, for example because the data sampling is geometrically irregular. Such data and associated processing tasks are beyond the scope of SGF.

From the user point of view, SGF is in fact identical to the Stanford Exploration Project's ``classic'' (pre-1996) disk data storage format, with a few restrictions and extensions noted below.

The SGFSpace class implements the vector spaces in which SGFVectors live. Grid and scalar attribute specification is proper to SGFSpace, and the user should consult the documentation on that class for details. Every SGFVector knows what space it belongs to (as does every HCL_Vector), and in particular has access to all of the dimensional and auxiliary information proper to the space. The SGFVector class provides convenient access functions, described below, which return values of these parameters by keyword (the keywords are described in the SGFSpace documentation).

Sample data of an SGFVector is stored in a (native) binary data file, designated by the in keyword in the SGFSpace parameter table. The storage order is as indicated by the ordering of directions in the SGFSpace: the first direction has the fastest index, followed by the second, etc. For example if the first direction represents time, the second a space coordinate, then the fastest index is time.

SGFVector is designed to realize as HCL_Vectors data sets too large to store conveniently (or at all) in-core. Accordingly only a portion of the data resides in-core at any time during the life of an SGFVector object. This portion is called a record and has a dimension specified by the rd keyword. In other words, if rd = k, then the j-th record consists of the samples (j-1)*n1*n2*...*nk+1,..., j*n1*n2*...*nk. It is accessed through the Data() method, which returns a float or double pointer to the data buffer holding the current in-core record.

SGFVector has two constructors, one for ``old'' vectors based on preexisting data files, the other for ``new'' data for which no data file need exist. The old data constructor automatically reads the first record from disk, so the first record is accessible via Data() with no further effort on the user's part. The new data constructor presumes that the data is either nonexistent or out-of-date, so does not populate the data buffer on construction.

Next() and Rewind() will typically be the only i/o functions needed in most programs using SGFVector. The Next() method advances to the next record, and returns 1 if the current record is not the last, else 0. Next() writes the current record but does not read next record for new data sets, but has the opposite behaviour for old data sets. The Rewind() method repositions the SGFVector at its first record; if that record is old (i.e. has already been initialized), then Rewind() reads it into the data buffer.

Thus data which your program treats as either read-only or write-only is implicitly handled correctly by a loop of the form


MyVector.Rewind();
do {
  float * mydata = MyVector.Data();
  ...
} while (MyVector.Next())

These methods, and all of the arithmetic methods required by the HCL_Vector class, depend on the basic i/o methods Seek(int,int), Get() and Put(), which the user will seldom need to use directly. In the present version, if you need to read and write data, you must use these lower level methods.

Notes:

Constructors and destructor

SGFVector_d()
Default constructor

SGFVector_d( const SGFVector_d & S )
Copy constructor - disabled

SGFVector_d( char * fname, int Save = 0 )
Usual constructor for old data. String fname must be name of existing SGFSpace header file, with in keyword pointing to binardy data file. Save parameter indicates whether current record is to be written to disk on destruction (default = 0).

SGFVector_d( const SGFSpace_d & s, char * fname = NULL, int Save = 1)
Usual constructor for new data. Constructs vector in space given by first arguement. If string fname given, opens data file on that name for write, otherwise opens a temporary file which will disappear from file system on destruction of the object. Save parameter indicates whether current record is to be written to disk on destruction (default = 1).

~SGFVector_d()
Destructor

Header and data access methods

int NumRecs()
returns number of records in data set

int BufLen()
returns length in words of data buffer

int GetHdrInt(char * name)
Return integer header word by keyword

double GetHdrReal(char * name)
Return real (FLOAT or DOUBLE) header word by keyword

char* GetHdrString(char * name)
Return header string by keyword

double* Data()
Return pointer to data buffer

Record access methods.
These methods treat the data buffer as a window on the data stored in the file - so the programmer must beware of the immediate consequences of altering the data buffer. All except Seek() write the data buffer out as their first step.

int Next()
Standard iterator. Calls Put() (for new vectors), pages forward to next record, calls Get() (for old vectors). Returns 1 if current record is NOT last (i.e. if there is more data to be read), 0 if it is.

void Rewind()
Reposition at beginning of data set. Rewind file to start, call Get() (for old records).

void Seek( int irec, int load=1 )
Reposition at record irec. Seek to corresponding position on disk, call Get() (for old records); does NOT write current contents, so "safe" repositioning method. load indicates whether record should be loaded, if it is initialized; with load=0, the file is positioned and the current record index is reset, but no i/o at all is performed

void Get()
Read current record into data buffer. Error condition if record is flagged as new, ie. not initialized.

void Put()
Write data buffer on current record. Flags record as old, ie. already initialized.

Write method

virtual ostream& Write( ostream & str )
Prints SGFSpace header table and name of binary data file


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de