Indexing and Assigning Elements

The indexing range is pretty simple. Matrix elements are indexed from 1 to c, and from 1 to r. There are some tradeoffs here. I could not figure out how to overload a double bracket operator, [][], so I resorted to a functional approach to indexing. Two index functions were created, one for each side of an equals operator. The little m(i,j) returns a double. The big M(i,j) returns a reference to a VMatrix. Both functions call mindex() and set curvecind. The difference between the two operators is that m(i,j) calls the vdoub member function v() for returning a matrix element. The function M(i,j) calls the vdoub bracket operators. You can think of M(i,j) and m(i,j) as surrogates for vdoub::operator[] and the vdoub function v().

To assign an element to a matrix, use statements like

                MAT1.M(i,j) = MAT2.m(i,j); 
                MAT1.M(i,j) = adouble;
                Matpointer1->M(i,j) = Matpointer2->m(i,j);
                Matpointer1->M(i,j) = another_double;
where MAT1 and MAT2 are virtual matrices, and Matpointers are pointers to virtual matrices. The basic idea at work here is that a virtual matrix is derived from the virtual vector. The vector functions are available to the matrix class, and so assignment of matrix elements works just as in virtual vectors. The only difference is that the index has to be calculated before the vector functions can be called. The code for assigning an element is
   double operator = ( double d ){     // write in a value
     vdoub::operator[](curvecind) = d;
     return d;
   }
The scope resolution operator is required to tell the compiler to use the equals operator from the parent class rather than the VMatrix class.