Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
why is it i am getting from this block (12,1) qualifier PMatrix is not a class or namespace, and Declaration terminated incorrectly?

#include <math.h>
#include <iostream.h>
#include <conio.h>

/*#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif */

//--------------------------------------------------------------------
PMatrix::PMatrix() : element(NULL){                   *****     (12,1):Qualifier PMatrix is not a class or namespace************
                                                      *****            declaration terminated incorrectly**************
}										//Default constructor
//--------------------------------------------------------------------
PMatrix::~PMatrix(){
	delete [] element;
	element = NULL;
}										//Destructor
//--------------------------------------------------------------------
void PMatrix::GetCopyOfElements(double * copy)const{
	ASSERT(copy != NULL);
	for(int i = 0; i < m_nElements; ++i){
		copy[i] = element[i];
	}
}										//GetCopyOfElements
//--------------------------------------------------------------------
void PMatrix::MeEqualsOther(const PMatrix & other){
	ASSERT(m_nRows == other.GetNumberRows() && m_nCols == other.GetNumberCols());
	const double * pe = other.GetElements();
	for(int i = 0; i < m_nElements; ++i){
		element[i] = pe[i];
	}


and

C#
class PMatrix{
//A general matrix.
protected:
    int m_nRows;
    int m_nCols;
    int m_nElements;
    double * element;
public:
    PMatrix(); //Default constructor.
    virtual ~PMatrix();
    inline virtual int     GetNumberRows()const = 0;
    inline virtual int     GetNumberCols()const = 0;
    inline virtual int     GetNumberElements()const = 0;
    inline const double *  GetElements()const{return element;}
    inline double *        GetNonconstantElements(){return element;}
    inline const double *  GetRow(int row)const{ASSERT(row >= 0 && row < m_nRows); return element + row * m_nCols;}
    inline double *        GetNonconstantRow(int row)const{ASSERT(row >= 0 && row < m_nRows); return element + row * m_nCols;}
    inline virtual double  GetElement(int row, int col)const = 0;
    void                   GetCopyOfElements(double * copy)const;
    bool IsZero()const;
    bool HasLargeElements(double max)const;
    void         MeEqualsMeTransposed();
    void         MeEqualsOther(const PMatrix & other);
    void         MeEqualsMinusOther(const PMatrix & other);
    virtual void MeEqualsMinusMe()const;
    void         InsertDiagonalSubmatrix(int order, int startRow, int startCol, double diag)const;
    void         MakeMeZero()const{for(int i = 0; i < m_nElements; ++i)element[i] = 0.0;}
    virtual void MeTimesColumnVector(const double * givenVector, double * resultingVector)const = 0;
    virtual void RowVectorTimesMe(const double * givenVector, double * resultingVector)const = 0;
    virtual void MeTimesMatrix(const PMatrix & Given, PMatrix & Result)const = 0;
    virtual void MeTransposedTimesMatrix(const PMatrix & Given, PMatrix & Result)const = 0;
    virtual void MeTimesMatrixTransposed(const PMatrix & Given, PMatrix & Result)const = 0;
    double       MeInnerProductMatrix(const PMatrix & M)const;
    virtual void MeEqualsSumOf(const PMatrix & A, const PMatrix & B)const;
    virtual void MeEqualsNegativeSumOf(const PMatrix & A, const PMatrix & B)const;
    virtual void MeEqualsDifferenceBetween(const PMatrix & A, const PMatrix & B)const;
    virtual void MeEqualsMePlus(const PMatrix & other)const;
    virtual void MeEqualsMeMinus(const PMatrix & other)const;
    virtual void MeEqualsMinusMePlus(const PMatrix & other)const;
    virtual void MeEqualsMinusMeMinus(const PMatrix & other)const;

    //The following virtual operators are inherited by all derived classes. They are
    //implemented in PMatrix.cpp, and can be used as-is, or overriden for efficiency.
    virtual void operator+=(const PMatrix & C);
    virtual void operator-=(const PMatrix & C);
    virtual void operator*=(double dd);
    virtual void operator/=(double dd);

    //Utility.
    virtual ArrayOfStr ReportMatrix(const char * title = NULL, const char * format = NULL)const;
    virtual bool CompareMatrix(const PMatrix & m)const;
};                                      //Class PMatrix
//--------------------------------------------------------------------

#endif // !defined(AFX_PMATRX_H__F4499B64_A4E5_4610_AFF0_3C0E2E369429__INCLUDED_)
Posted
Updated 23-Dec-21 14:03pm
v2
Comments
Richard MacCutchan 3-Dec-11 15:28pm    
Where is the PMatrix class defined?
carlmack 3-Dec-11 15:33pm    
class PMatrix{
//A general matrix.
protected:
int m_nRows;
int m_nCols;
int m_nElements;
double * element;
public:
PMatrix(); //Default constructor.
virtual ~PMatrix();
inline virtual int GetNumberRows()const = 0;
inline virtual int GetNumberCols()const = 0;
inline virtual int GetNumberElements()const = 0;
inline const double * GetElements()const{return element;}
inline double * GetNonconstantElements(){return element;}
inline const double * GetRow(int row)const{ASSERT(row >= 0 && row < m_nRows); return element + row * m_nCols;}
inline double * GetNonconstantRow(int row)const{ASSERT(row >= 0 && row < m_nRows); return element + row * m_nCols;}
inline virtual double GetElement(int row, int col)const = 0;
void GetCopyOfElements(double * copy)const;
bool IsZero()const;
bool HasLargeElements(double max)const;
void MeEqualsMeTransposed();
void MeEqualsOther(const PMatrix & other);
void MeEqualsMinusOther(const PMatrix & other);
virtual void MeEqualsMinusMe()const;
void InsertDiagonalSubmatrix(int order, int startRow, int startCol, double diag)const;
void MakeMeZero()const{for(int i = 0; i < m_nElements; ++i)element[i] = 0.0;}
virtual void MeTimesColumnVector(const double * givenVector, double * resultingVector)const = 0;
virtual void RowVectorTimesMe(const double * givenVector, double * resultingVector)const = 0;
virtual void MeTimesMatrix(const PMatrix & Given, PMatrix & Result)const = 0;
virtual void MeTransposedTimesMatrix(const PMatrix & Given, PMatrix & Result)const = 0;
virtual void MeTimesMatrixTransposed(const PMatrix & Given, PMatrix & Result)const = 0;
double MeInnerProductMatrix(const PMatrix & M)const;
virtual void MeEqualsSumOf(const PMatrix & A, const PMatrix & B)const;
virtual void MeEqualsNegativeSumOf(const PMatrix & A, const PMatrix & B)const;
virtual void MeEqualsDifferenceBetween(const PMatrix & A, const PMatrix & B)const;
virtual void MeEqualsMePlus(const PMatrix & other)const;
virtual void MeEqualsMeMinus(const PMatrix & other)const;
virtual void MeEqualsMinusMePlus(const PMatrix & other)const;
virtual void MeEqualsMinusMeMinus(const PMatrix & other)const;

//The following virtual operators are inherited by all derived classes. They are
//implemented in PMatrix.cpp, and can be used as-is, or overriden for efficiency.
virtual void operator+=(const PMatrix & C);
virtual void operator-=(const PMatrix & C);
virtual void operator*=(double dd);
virtual void operator/=(double dd);

//Utility.
virtual ArrayOfStr ReportMatrix(const char * title = NULL, const char * format = NULL)const;
virtual bool CompareMatrix(const PMatrix & m)const;
}; //Class PMatrix
//--------------------------------------------------------------------

#endif // !defined(AFX_PMATRX_H__F4499B64_A4E5_4610_AFF0_3C0E2E369429__INCLUDED_)
carlmack 3-Dec-11 15:36pm    
i need to go through the definition once more cause i get 10 errors soon as i include it in the code
Richard MacCutchan 3-Dec-11 15:49pm    
But it's not included in your sample above. I would suggest you start with a much simpler definition and add bits one at a time; that way you are less likely to get hit with a ton of errors in one go.
Also you have defined this as an abstract class, is that what you meant?
carlmack 3-Dec-11 15:59pm    
ok i am doing that as we speak

1 solution

That is code from the Professor Sergio Pissanetzky’s book.
The links to download the source codes of this books do not works.(https://www.SciControls.com/eBooks/…)
You can share the following files with me:

VectorMatrix.zip
RigidBodyKinematicsCode.zip

Thanks for all.

Best Regards.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900