Change dimensions

next - skip - up - start

The following operations change the dimensions of a matrix. The values of the elements are lost.

    A.ReDimension(nrows,ncols);     // for type Matrix or nricMatrix
    A.ReDimension(n);               // for all other types, except Band
    A.ReDimension(n,lower,upper);   // for BandMatrix
    A.ReDimension(n,lower);         // for LowerBandMatrix
    A.ReDimension(n,upper);         // for UpperBandMatrix
    A.ReDimension(n,lower);         // for SymmetricBandMatrix
Use A.CleanUp() to set the dimensions of A to zero and release all the heap memory.

Remember that ReDimension destroys values. If you want to ReDimension, but keep the values in the bit that is left use something like

   ColumnVector V(100);
   ...                            // load values
   V = V.Rows(1,50);              // to get first 50 values.
If you want to extend a matrix or vector use something like
   ColumnVector V(50);
   ...                            // load values
   { V.Release(); ColumnVector X=V; V.ReDimension(100); V.Rows(1,50)=X; }
                                  // V now length 100