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
37 /*******************************************************************************
39 *******************************************************************************/
43 /*******************************************************************************
44 DECLARATION: MatrixException
45 *******************************************************************************/
51 class MatrixException /* : public exception */
57 /*******************************************************************************
59 *******************************************************************************/
67 unsigned int rows,cols;
69 int width,prec,origin;
70 void TransposeSquare(void);
71 void TransposeNonSquare(void);
72 unsigned int rowCtr, colCtr;
75 FGMatrix(unsigned int r, unsigned int c);
76 FGMatrix(const FGMatrix& A);
79 FGMatrix& operator=(const FGMatrix& A);
80 inline double& operator()(unsigned int row, unsigned int col) const {return data[row][col];}
82 FGColumnVector operator*(const FGColumnVector& Col);
84 unsigned int Rows(void) const;
85 unsigned int Cols(void) const;
88 void InitMatrix(void);
89 void InitMatrix(double value);
91 FGMatrix operator-(const FGMatrix& B);
92 FGMatrix operator+(const FGMatrix& B);
93 FGMatrix operator*(const FGMatrix& B);
94 FGMatrix operator/(const double scalar);
95 FGMatrix& operator<<(const float ff);
97 friend ostream& operator<<(ostream& os, const FGMatrix& M);
98 friend istream& operator>>(istream& is, FGMatrix& M);
100 void operator-=(const FGMatrix &B);
101 void operator+=(const FGMatrix &B);
102 void operator*=(const FGMatrix &B);
103 void operator*=(const double scalar);
104 void operator/=(const double scalar);
106 friend FGMatrix operator*(double scalar,FGMatrix& A);
108 void SetOParams(char delim,int width,int prec, int origin=0);
111 /*******************************************************************************
112 DECLARATION: FGColumnVector
113 *******************************************************************************/
115 class FGColumnVector : public FGMatrix
118 FGColumnVector(void);
119 FGColumnVector(int m);
120 FGColumnVector(const FGColumnVector& b);
123 FGColumnVector operator*(const double scalar);
124 FGColumnVector operator*(const FGColumnVector& V); // Cross product operator
125 FGColumnVector operator/(const double scalar);
126 FGColumnVector operator+(const FGColumnVector& B);
127 FGColumnVector operator-(const FGColumnVector& B);
128 float Magnitude(void);
129 FGColumnVector Normalize(void);
131 friend FGColumnVector operator*(const double scalar, const FGColumnVector& A);
132 friend FGColumnVector operator*(const FGMatrix& M, const FGColumnVector& V);
134 double& operator()(int m) const;
137 /******************************************************************************/