to JSBSim so they can become permanent.
FGColumnVector3::FGColumnVector3(void)
{
- data = new double[4];
rowCtr = 1;
//cout << "Allocated: " << data << endl;
//if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
FGColumnVector3::FGColumnVector3(int m)
{
- data = new double[4];
rowCtr = 1;
data[1]=0;data[2]=0;data[3]=0;
//cout << "Allocated: " << data << endl;
FGColumnVector3::~FGColumnVector3(void)
{
//cout << "Freed: " << data << endl;
- delete[] data;
- data = NULL;
if (debug_lvl & 2) cout << "Destroyed: FGColumnVector3" << endl;
}
FGColumnVector3::FGColumnVector3(const FGColumnVector3& b)
{
- data = new double[4];
data[1] = b.data[1];
data[2] = b.data[2];
data[3] = b.data[3];
FGColumnVector3 FGColumnVector3::operator=(const FGColumnVector3& b)
{
- data = new double[4];
data[1] = b.data[1];
data[2] = b.data[2];
data[3] = b.data[3];
friend ostream& operator<<(ostream& os, const FGColumnVector3& col);
- inline double& operator()(int m) const { return data[m]; }
+ inline double operator()(int m) const { return data[m]; }
+ inline double& operator()(int m) { return data[m]; }
FGColumnVector3 multElementWise(const FGColumnVector3& V);
private:
- double *data;
+ double data[4];
int rowCtr;
void Debug(void);
};
FGColumnVector4::FGColumnVector4(void)
{
- data = new double[5];
rowCtr = 1;
//cout << "Allocated: " << data << endl;
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector4" << endl;
FGColumnVector4::FGColumnVector4(int m)
{
- data = new double[5];
rowCtr = 1;
data[1]=0;data[2]=0;data[3]=0;data[4]=0;
//cout << "Allocated: " << data << endl;
FGColumnVector4::~FGColumnVector4(void)
{
//cout << "Freed: " << data << endl;
- delete[] data;
- data = NULL;
if (debug_lvl & 2) cout << "Destroyed: FGColumnVector4" << endl;
}
FGColumnVector4::FGColumnVector4(const FGColumnVector4& b)
{
- data = new double[5];
data[1] = b.data[1];
data[2] = b.data[2];
data[3] = b.data[3];
FGColumnVector4 FGColumnVector4::operator=(const FGColumnVector4& b)
{
- data = new double[5];
data[1] = b.data[1];
data[2] = b.data[2];
data[3] = b.data[3];
void operator*=(const double scalar);
void operator/=(const double scalar);
- inline double& operator()(int m) const { return data[m]; }
+ inline double operator()(int m) const { return data[m]; }
+ inline double& operator()(int m) { return data[m]; }
FGColumnVector4& operator<<(const float ff);
FGColumnVector4 multElementWise(const FGColumnVector4& V);
private:
- double *data;
+ double data[5];
int rowCtr;
void Debug(void);
};
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-double** FGalloc(void)
-{
- double **A;
-
- A = new double *[4];
- if (!A) return NULL;
-
- double *tmp;
- tmp = new double [16];
-
- if (!tmp) {
- delete A;
- return NULL;
- }
- A[0] = tmp;
- A[1] = tmp + 4;
- A[2] = tmp + 8;
- A[3] = tmp + 12;
-#if 0
- A[0] = new double [4];
- if (!A[0]) return NULL;
- A[1] = new double [4];
- if (!A[1]) return NULL;
- A[2] = new double [4];
- if (!A[2]) return NULL;
- A[3] = new double [4];
- if (!A[3]) return NULL;
-#endif
-
- return A;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void dealloc(double **A)
-{
- delete[] A[0];
- delete[] A;
-}
-
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGMatrix33::FGMatrix33(void)
{
- data=FGalloc();
InitMatrix();
rowCtr = colCtr = 1;
FGMatrix33::FGMatrix33(int r, int c)
{
- data=FGalloc();
InitMatrix();
rowCtr = colCtr = 1;
delim = M.delim;
origin = M.origin;
- data=FGalloc();
-
data[1][1] = M.data[1][1];
data[1][2] = M.data[1][2];
data[1][3] = M.data[1][3];
FGMatrix33::~FGMatrix33(void)
{
- dealloc(data);
rowCtr = colCtr = 1;
if (debug_lvl & 2) cout << "Destroyed: FGMatrix33" << endl;
FGMatrix33& FGMatrix33::operator=(const FGMatrix33& M)
{
if (&M != this) {
- if (data != NULL) dealloc(data);
-
width = M.width;
prec = M.prec;
delim = M.delim;
origin = M.origin;
- data=FGalloc();
-
data[1][1] = M.data[1][1];
data[1][2] = M.data[1][2];
data[1][3] = M.data[1][3];
~FGMatrix33(void);
FGMatrix33& operator=(const FGMatrix33& A);
- inline double& operator()(unsigned int row, unsigned int col) const {return data[row][col];}
+ inline double operator()(unsigned int row, unsigned int col) const {return data[row][col];}
+ inline double& operator()(unsigned int row, unsigned int col) {return data[row][col];}
FGColumnVector3 operator*(const FGColumnVector3& Col);
void operator*=(const double scalar);
void operator/=(const double scalar);
-
void SetOParams(char delim,int width,int prec, int origin=0);
protected:
- double **data;
+ double data[4][4];
private:
char delim;