The Functions

There are five classes of functions in this package: display control, IO, subsetting and concatenation, elementwise operations, and math functions. Their prototypes are contained below:
typedef enum boolean { FFALSE, TTRUE } boolean;

int Setwid( int w );                      // set display width
int Setdec( int d );                      // set decimals
int Getwid( void  );                      // report display width
int Getdec( void  );                      // report decimals

////////////////////////// io

VMatrix& Reada( char *fid);               // read ascii file
VMatrix& Readb( char *fid);               // read binary file
void Writea( char *fid, VMatrix &mat);    // write ascii file
//void VMatrix::Writeb( char *fid, VMatrix &mat)   // write binary file

//////////// sorting and subsetting

VMatrix& MSort( VMatrix &a, int col, int order=0);
VMatrix& Submat( VMatrix &a, int r, int c, int lr=1, int lc=1);
VMatrix& Ch( VMatrix &a, VMatrix &b );
VMatrix& Cv( VMatrix &a, VMatrix &b );

/////////////// Specially patterned matrices

VMatrix& Tran(VMatrix &ROp );
VMatrix& Mexp(VMatrix &ROp );
VMatrix& Mabs(VMatrix &ROp );
VMatrix& Mlog(VMatrix &ROp );
VMatrix& Msqrt(VMatrix &ROp );
double Trace(VMatrix &ROp );
VMatrix& Ident(int n );
VMatrix& Helm( int n );
VMatrix& Fill(int r, int c, double d );
VMatrix& Index( int lower, int upper, int step = 1);

//////////////// Inversions and decompositions

VMatrix& Sweep( int k1, int k2, VMatrix& ROp); /* sweep out a row */
VMatrix& Inv( VMatrix &ROp ); /*matrix inversion using sweep */
VMatrix& Kron( VMatrix &a, VMatrix &b );
double Det( VMatrix &ROp );
VMatrix& Cholesky(VMatrix& ROp);
void QR( VMatrix& ROp, VMatrix& Q, VMatrix& R, boolean makeq = TTRUE);
int Svd( VMatrix &A, VMatrix &U, VMatrix &S, VMatrix &V,
          boolean makeu = TTRUE, boolean makev = TTRUE);
VMatrix& Ginv( VMatrix& ROp );
VMatrix& Fft( VMatrix &ROp, boolean INZEE = TTRUE);

/////////////// Reshaping functions

VMatrix& Vec( VMatrix& ROp );      // send matrix to vector
                                   // stack columns into an (r*c)x1
VMatrix& Vecdiag( VMatrix& ROp );  // extract diagonal into a vector
VMatrix& Diag( VMatrix& ROp );     // create a diagonal matrix from 
                                   // square matrix or column vector
VMatrix& Shape( VMatrix& ROp, int nrows = 1 );       // reshape into nrows

///////////////// accumulation 

typedef enum margins { ALL, ROWS, COLUMNS } margins; // summation margins

VMatrix& Sum( VMatrix& ROp, margins marg = ALL );    // sums over margins
VMatrix& Sumsq( VMatrix& ROp, margins marg = ALL );  // sum of squares
VMatrix& Cusum( VMatrix& ROp);                       // accumulate along rows

///////////////// max and min

VMatrix& Mmax( VMatrix& ROp, margins marg=ALL );   // matrix max
VMatrix& Mmin( VMatrix& ROp, margins marg=ALL );   //  matrix min

///////////////// elementary operations
///////////////// !!!!!!! modify input matrices

void Crow( VMatrix& ROp, int row=0, double c=1.0);
void Srow( VMatrix &ROp, int row1 = 0, int row2 = 0);
void Lrow( VMatrix &ROp, int row1 = 0, int row2 = 0, double c=0.0);
void Ccol( VMatrix& ROp, int col=0, double c=1.0);
void Scol( VMatrix &ROp, int col1 = 0, int col2 = 0);
void Lcol( VMatrix &ROp, int col1 = 0, int col2 = 0, double c=0.0);

A boolean type is provided. The values are FFALSE and TTRUE. They are misspelled to avoid conflicts with other compilers which may have also defined a boolean type.



Subsections