The two matrix classes RWGenMat<double> and DoubleSymMat return a regular C++ reference to a double, that is, a double&. For other matrix types, this is not always possible. For example, an element in class BandMat outside the band is defined to be 0; therefore, it is illegal to use an element like an lvalue. In class SkewMat, the elements below the main diagonal are not stored explicitly, but calculated as the negative of the element diagonally across the main diagonal. If you access one of these elements, you can't simply return a reference since there is no double type in memory to access.
Obviously, for types other than GenMat and SymMat, something must be done besides returning a simple reference to a memory location. In these cases, operator()(int,int) returns an instance of a helper class. This class provides the indirection needed so that the subscripting operator works correctly on both the right and left sides of the equal sign. The helper class contains a reference to a double, information on how that reference is to be modified, and whether or not it can be used as an lvalue. There are several different helper classes for the various matrix types:
RODoubleRef handles the case of potentially read-only access to data. It is used by the BandMat, SymBandMat, UpperTriMat, LowerTriMat, and TriDiagMat classes, which all contain elements that are explicitly defined as 0 and can not be changed. If an element defined to be 0 is accessed, the RODoubleRef is constructed with a reference to a static variable initialized to 0, and information that the reference is read-only.
NGDoubleRef handles the case of a reference to an element that may have to be negated. It is used by the SkewMat matrix classes.
CJDComplexRef is used by the HermMat classes to reference data that may need to be conjugated.
ROCJDComplexRef handles a reference to a datum that may be read-only, or may need to be conjugated. It is used by the HermBandMat classes. Elements outside the band are defined as 0. Accessing these elements returns an ROCJDComplexRef initialized with a static variable initialized to 0, and information that the reference is read-only.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.