Mail Archives: djgpp/2004/03/30/17:46:52
Chris wrote:
> I cannot figure out why my old program no longer compiles under the
> current release of DJGPP (it worked with a REALLY old version). As
> you can see,
> FSTREAM is include, but it says IFSTREAM is not declared in this
> scope?! I
> do not understand this error. Any help is greatly appreciated!
>
> Code snippet from header file "matrix.h"
Corrected snippet:
#include <fstream>
using namespace std;
typedef double FLOAT_TYPE;
class Matrix
{
private:
char name[20]; // matrix name
int rows; // matrix rows
int columns; // matrix columns
FLOAT_TYPE *elem; // pointer to matrix data
public:
// Constructors
Matrix(); // default constructor
Matrix(float &); // conversion constructor
Matrix(Matrix &); // copy constructor
Matrix(char *); // name-only constructor
Matrix(int, int = 0); // size-only constructor
Matrix(char *, int, int = 0); // name & size constructor
// Destructor
~Matrix(); // destructor
// Member Functions
void SetName(char *); // set matrix name
void GetName(char *); // get matrix name
void SizeOf(void); // display size of matrix
int NRows(void); // returns # of rows
int NCols(void); // returns # of columns
void ReDim(int = 0, int = 0); // set matrix dimensions
void ReDim(Matrix &); // set matrix dimensions
void Randomize(int = 1, int = 0); // randomize a matrix
void Identity(int, int = 0); // make Identity Matrix
void Identity(Matrix &); // make Identity Matrix
int Diag(Matrix &); // diagonalize a matrix
void KeyLoad(void); // load Matrix from Keyboard
int LoadAscii(ifstream &); // load Matrix from Ascii File
int SaveAscii(ofstream &); // save Matrix to Ascii File
int Load(ifstream &); // load Matrix from Matlab File
int Save(ofstream &); // save Matrix to Matlab File
void ErrorHandler(int); // matrix error handler
FLOAT_TYPE Max(void); // get max element
FLOAT_TYPE Min(void); // get min element
// Overloaded Operators
FLOAT_TYPE & operator() (int, int); // overloaded () operator
Matrix & operator() (int, int, int, int); // get a submatrix
Matrix & operator+(Matrix &); // add matrices
Matrix & operator-(); // negate matrix
Matrix & operator-(Matrix &); // subtract matrices
Matrix & operator*(Matrix &); // multiply matrices
Matrix & operator=(Matrix &); // overloaded = operator
Matrix & operator*=(Matrix &); // element by element mult
Matrix & operator!(); // invert matrix
Matrix & operator~(); // transpose matrix
Matrix & operator||(Matrix &); // column augment 2 matrices
Matrix & operator&&(Matrix &); // row augment 2 matrices
int operator==(Matrix &); // compare 2 matrices
operator FLOAT_TYPE(); // Matrix -> FLOAT_TYPE
Matrix & operator=(FLOAT_TYPE &); // FLOAT_TYPE -> Matrix
friend Matrix & operator+(Matrix &, FLOAT_TYPE); // add matrix &
// scalar
friend Matrix & operator+(FLOAT_TYPE, Matrix &); // add scalar &
// matrix
friend Matrix & operator-(Matrix &, FLOAT_TYPE); // subtract scalar
// from matrix
friend Matrix & operator-(FLOAT_TYPE, Matrix &); // subtract matrix
// from scalar
friend Matrix & operator*(Matrix &, FLOAT_TYPE); // multiply matrix
// & scalar
friend Matrix & operator*(FLOAT_TYPE, Matrix &); // multiply scalar
// & matrix
friend ostream & operator<<(ostream &, Matrix &); // overloaded <<
// operator
};
- Raw text -