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>
27 # ifdef FG_HAVE_STD_INCLUDES
38 /*******************************************************************************
40 *******************************************************************************/
44 /*******************************************************************************
45 DECLARATION: MatrixException
46 *******************************************************************************/
50 class MatrixException /* : public exception */
56 /*******************************************************************************
58 *******************************************************************************/
66 unsigned int rows,cols;
68 int width,prec,origin;
69 void TransposeSquare(void);
70 void TransposeNonSquare(void);
71 unsigned int rowCtr, colCtr;
74 FGMatrix(unsigned int r, unsigned int c);
75 FGMatrix(const FGMatrix& A);
78 FGMatrix& operator=(const FGMatrix& A);
79 inline double& operator()(unsigned int row, unsigned int col) const {return data[row][col];}
81 FGColumnVector operator*(const FGColumnVector& Col);
83 unsigned int Rows(void) const;
84 unsigned int Cols(void) const;
87 void InitMatrix(void);
88 void InitMatrix(double value);
90 FGMatrix operator-(const FGMatrix& B);
91 FGMatrix operator+(const FGMatrix& B);
92 FGMatrix operator*(const FGMatrix& B);
93 FGMatrix operator/(const double scalar);
94 FGMatrix& operator<<(const float ff);
96 friend ostream& operator<<(ostream& os, const FGMatrix& M);
97 friend istream& operator>>(istream& is, FGMatrix& M);
99 void operator-=(const FGMatrix &B);
100 void operator+=(const FGMatrix &B);
101 void operator*=(const FGMatrix &B);
102 void operator*=(const double scalar);
103 void operator/=(const double scalar);
105 friend FGMatrix operator*(double scalar,FGMatrix& A);
107 void SetOParams(char delim,int width,int prec, int origin=0);
110 /*******************************************************************************
111 DECLARATION: FGColumnVector
112 *******************************************************************************/
114 class FGColumnVector : public FGMatrix
117 FGColumnVector(void);
118 FGColumnVector(int m);
119 FGColumnVector(const FGColumnVector& b);
122 FGColumnVector operator*(const double scalar);
123 FGColumnVector operator/(const double scalar);
124 FGColumnVector operator+(const FGColumnVector& B);
125 float Magnitude(void);
126 FGColumnVector Normalize(void);
128 friend FGColumnVector operator*(const double scalar, const FGColumnVector& A);
130 double& operator()(int m) const;
133 /******************************************************************************/