class HCL_VectorSpace_d : public HCL_Base

HCL_VectorSpace_d is the base class for all vector spaces in HCL

Inheritance:


Public Methods

HCL_VectorSpace_d (const HCL_VectorSpace_d & x)
Constructs identical copy
virtual int operator == (const HCL_VectorSpace_d &) const
Returns nonzero if spaces are identical
virtual int operator != (const HCL_VectorSpace_d & x) const
Returns nonzero if spaces differ
virtual HCL_Vector_d* Member () const
Returns address of dynamically allocated (and uninitialized) vector in this space
virtual HCL_VectorSpace_d* Replicate () const
Returns address of independent, identical copy of this vector space
virtual int Dim () const
Returns the dimension of the vector space
int Test ( int display = 0, double tol = 100 ) const
Test routine, useful for implementors of new vector classes to check for coding errors

Inherited from HCL_Base:

Public Methods

void IncCount() const
void DecCount() const
int Count() const
virtual ostream& Write(ostream &) const

Documentation

HCL_VectorSpace_d is the base class for all vector spaces in HCL. (In HCL, "vector space" is synonomous with "Hilbert space".) The purpose of a vector space in HCL is two-fold.

A HCL_VectorSpace_d returns its dimension via the Dim method.

For implementors: This class also provides a Test method, which performs a series of tests to check that the algebraic operations are implemented consistently in the corresponding HCL_Vector_d class. For example, Test verifies that addition is commutative, that the two versions of Add produce consistent results, and so on. This method is intended to be useful for implementors of new vector classes. The concrete vector classes provided with HCL have already passed.

All of the methods in this class are pure virtual, with the sole exception of operator !=.

HCL_VectorSpace_d(const HCL_VectorSpace_d & x)
Constructs identical copy. For implementors: A copy constructor provides a simple means to implement Replicate in a concrete class derived from HCL_VectorSpace_d.

virtual int operator == (const HCL_VectorSpace_d &) const
Returns nonzero if spaces are identical. For implementors: This comparitor must be implemented for each concrete derived class. It should begin by comparing the addresses of the two spaces. If these are the same, no further work is required, and the operator returns a nonzero. Otherwise, it is necessary to compare the data defining the spaces. To access this data, it is necessary to cast the comparison space (i.e. the argument of operator ==) to the type of this. To do this safely, each vector space class should declare a static char (named Type, for example) in private data, and implement void * GetType(). GetType should return the address of the static char, cast to void *:

 
     void * MyVectorSpace::GetType() const {
       return (void *)&Type;
     }
     

Since GetType is declared public and pure virtual in the base class, its value is available to other vector spaces before the cast. The return values of GetType should be compared for the two spaces; if they are the same, then the second space is an object of the same class as the first. The cast can then be done safely, and then the characteristic information about the spaces can be compared. See the comparitor for HCL_RnSpace_d for a simple example. [This primitive runtime type check, the only runtime type check built into HCL, will become obsolete in a future version incorporating the ISO standard dynamic cast.]

virtual int operator != (const HCL_VectorSpace_d & x) const
Returns nonzero if spaces differ. For implementors: This comparitor is implemented in this base class, and need not be overridden.

virtual HCL_Vector_d* Member() const
Returns address of dynamically allocated (and uninitialized) vector in this space. This method constructs a vector belonging to this vector space and returns a pointer to it. Note that the calling routine is responsible for deleting the vector when it is no longer needed. Member is used to create temporary vectors "abstractly", i.e. without knowing the exact type of the vector desired. See the documentation for this class (above).

virtual HCL_VectorSpace_d* Replicate() const
Returns address of independent, identical copy of this vector space. This method constructs a copy of this vector space and returns a pointer to it. For implementors: For concrete child classes of HCL_VectorSpace_d having a copy constructor, Replicate can just be implemented to call the copy constructor and return the the result:
 
       MyVectorSpace::Replicate() { 
         return new MyVectorSpace( *this ); 
       } 
       

virtual int Dim() const
Returns the dimension of the vector space

int Test( int display = 0, double tol = 100 ) const
Test routine, useful for implementors of new vector classes to check for coding errors. This routine checks that the axioms of a vector space hold (up to round-off errors) for random vectors. The return value is the number of errors detected. The first input is a display flag; if it is zero, no results are displayed; if it is 1, the number of errors detected is displayed; if it is greater than 1, the result of each individual test is displayed. The second input sets the tolerance for the floating-point tests; an error is reported if two results which ought to be equal differ by a relative amount greater than tol times machine epsilon.


Direct child classes:
HCL_ProductSpace_d
SGFSpace_d
HCL_RnSpace_d

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