// // Programmer: Craig Stuart Sapp // Creation Date: Wed Feb 24 03:30:03 PST 1999 // Last Modified: Wed Jul 31 17:27:18 PDT 2002 added getRow() and getColumn() // Last Modified: Wed Jul 31 17:27:18 PDT 2002 added setRow() and setColumn() // Last Modified: Sun Feb 20 17:45:39 PST 2011 added setAll() // Filename: /home/craig/sigNet/Matrix.h // Syntax: C++ // $Smake: smake %b.cpp // #ifndef _MATRIX_H_INCLUDED #define _MATRIX_H_INCLUDED #include "Array.h" #ifndef OLDCPP #include using namespace std; #else #include #endif template class Matrix { public: Matrix (void); Matrix (const Matrix& aMatrix); Matrix (int rowCount, int columnCount); Matrix (int rowCount, int columnCount, type& thing); Matrix (int columnCount); Matrix (type* data, int rowCount, int columnCount); ~Matrix (); Matrix& add (type scalar); Matrix& add (const Matrix& aMatrix); type& cell (int row, int column); type cell (int row, int column) const; int getSize (void) const; int getRowCount (void) const; int getColumnCount (void) const; void getRow (Array& anArray, int index); void getColumn (Array& anArray, int index); void setRow (int index, Array& anArray); void setColumn (int index, Array& anArray); Matrix& multiply (type scalar); type& operator[] (int index); Matrix& operator= (const Matrix& aMatrix); Matrix& operator+= (const Matrix& aMatrix); void setSize (int row, int column); void transpose (void); void zero (void); void setAll (type& thing); // static functions: static Matrix& multiply (Matrix& output, const Matrix& one, Matrix& two); static Matrix& multiply (Matrix& output, Matrix& one, type aScalar); static Matrix& add (Matrix& output, const Matrix& one, const Matrix& two); static void transpose (Matrix& output, const Matrix& one); protected: int transposeQ; // whether or not the matrix is transposed int dim1; // number of rows/columns in the matrix int dim2; // number of rows/columns in the matrix type* storage; // where the matrix of numbers is stored private: void checkdim (int row, int column) const; }; // helping functions: template ostream& operator<<(ostream& out, const Matrix& aMatrix); // This following line is necessary because of template behavior: #include "Matrix.cpp" #endif /* _MATRIX_H_INCLUDED */ // md5sum: c7406ace8da89dade8971d53f0f9f19e Matrix.h [20050403]