Matrix Entry Helper Classes
The two matrix classes
RWGenMat<double> and
RWSymMat<double> 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
RWBandMat<T> outside the band is defined to be 0; therefore, it is illegal to use an element like an lvalue. In class
RWSkewMat<T>, 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 not simply return a reference since there is no double type in memory to access.
Obviously, for types other than
RWGenMat<T> and
RWSymMat<T>, 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:
RWRORef<T> handles the case of potentially read-only access to data. It is used by the
RWBandMat<T>,
RWSymBandMat<T>,
RWUpperTriMat<T>,
RWLowerTriMat<T>, and
RWTriDiagMat<T> 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
RWRORef<T> is constructed with a reference to a static variable initialized to 0, and information that the reference is read-only.
RWNGRef<T> handles the case of a reference to an element that may have to be negated. It is used by the
RWSkewMat<T> matrix class.
RWCJRef <T> is used by the
RWHermMat<T> classes to reference data that may need to be conjugated.
RWROCJRef<T> handles a reference to a datum that may be read-only, or may need to be conjugated. It is used by the
RWHermBandMat<T> classes. Elements outside the band are defined as 0. Accessing these elements returns an
RWROCJRef<T> initialized with a static variable initialized to 0, and information that the reference is read-only.