1 /*******************************************************************************
4 Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
8 --------------------------------------------------------------------------------
10 03/16/2000 JSB Added exception throwing
12 ********************************************************************************
14 *******************************************************************************/
19 /*******************************************************************************
21 *******************************************************************************/
25 # include <simgear/compiler.h>
26 # ifdef FG_HAVE_STD_INCLUDES
40 /*******************************************************************************
42 *******************************************************************************/
46 /*******************************************************************************
47 DECLARATION: MatrixException
48 *******************************************************************************/
54 class MatrixException /* : public exception */
60 /*******************************************************************************
62 *******************************************************************************/
70 unsigned int rows,cols;
72 int width,prec,origin;
73 void TransposeSquare(void);
74 void TransposeNonSquare(void);
75 unsigned int rowCtr, colCtr;
78 FGMatrix(unsigned int r, unsigned int c);
79 FGMatrix(const FGMatrix& A);
82 FGMatrix& operator=(const FGMatrix& A);
83 inline double& operator()(unsigned int row, unsigned int col) const {return data[row][col];}
85 FGColumnVector operator*(const FGColumnVector& Col);
87 unsigned int Rows(void) const;
88 unsigned int Cols(void) const;
91 void InitMatrix(void);
92 void InitMatrix(double value);
94 FGMatrix operator-(const FGMatrix& B);
95 FGMatrix operator+(const FGMatrix& B);
96 FGMatrix operator*(const FGMatrix& B);
97 FGMatrix operator/(const double scalar);
98 FGMatrix& operator<<(const float ff);
100 friend ostream& operator<<(ostream& os, const FGMatrix& M);
101 friend istream& operator>>(istream& is, FGMatrix& M);
103 void operator-=(const FGMatrix &B);
104 void operator+=(const FGMatrix &B);
105 void operator*=(const FGMatrix &B);
106 void operator*=(const double scalar);
107 void operator/=(const double scalar);
109 friend FGMatrix operator*(double scalar,FGMatrix& A);
111 void SetOParams(char delim,int width,int prec, int origin=0);
114 /*******************************************************************************
115 DECLARATION: FGColumnVector
116 *******************************************************************************/
118 class FGColumnVector : public FGMatrix
121 FGColumnVector(void);
122 FGColumnVector(int m);
123 FGColumnVector(const FGColumnVector& b);
126 FGColumnVector operator*(const double scalar);
127 FGColumnVector operator*(const FGColumnVector& V); // Cross product operator
128 FGColumnVector operator/(const double scalar);
129 FGColumnVector operator+(const FGColumnVector& B);
130 FGColumnVector operator-(const FGColumnVector& B);
131 float Magnitude(void);
132 FGColumnVector Normalize(void);
134 friend FGColumnVector operator*(const double scalar, const FGColumnVector& A);
135 friend FGColumnVector operator*(const FGMatrix& M, const FGColumnVector& V);
137 double& operator()(int m) const;
139 FGColumnVector multElementWise(const FGColumnVector& V);
142 /******************************************************************************/