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 SG_HAVE_STD_INCLUDES
33 # include <iostream.h>
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 #define ID_MATRIX "$Header"
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 DECLARATION: MatrixException
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 class MatrixException /* : public exception */
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81 unsigned int rows,cols;
83 int width,prec,origin;
84 void TransposeSquare(void);
85 void TransposeNonSquare(void);
86 unsigned int rowCtr, colCtr;
89 FGMatrix(unsigned int r, unsigned int c);
90 FGMatrix(const FGMatrix& A);
93 FGMatrix& operator=(const FGMatrix& A);
94 inline double& operator()(unsigned int row, unsigned int col) const {return data[row][col];}
96 FGColumnVector operator*(const FGColumnVector& Col);
98 unsigned int Rows(void) const;
99 unsigned int Cols(void) const;
102 void InitMatrix(void);
103 void InitMatrix(double value);
105 FGMatrix operator-(const FGMatrix& B);
106 FGMatrix operator+(const FGMatrix& B);
107 FGMatrix operator*(const FGMatrix& B);
108 FGMatrix operator/(const double scalar);
109 FGMatrix& operator<<(const float ff);
111 friend ostream& operator<<(ostream& os, const FGMatrix& M);
112 friend istream& operator>>(istream& is, FGMatrix& M);
114 void operator-=(const FGMatrix &B);
115 void operator+=(const FGMatrix &B);
116 void operator*=(const FGMatrix &B);
117 void operator*=(const double scalar);
118 void operator/=(const double scalar);
120 friend FGMatrix operator*(double scalar,FGMatrix& A);
122 void SetOParams(char delim,int width,int prec, int origin=0);
125 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126 DECLARATION: FGColumnVector
127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
129 class FGColumnVector : public FGMatrix
132 FGColumnVector(void);
133 FGColumnVector(int m);
134 FGColumnVector(const FGColumnVector& b);
137 FGColumnVector operator*(const double scalar);
138 FGColumnVector operator*(const FGColumnVector& V); // Cross product operator
139 FGColumnVector operator/(const double scalar);
140 FGColumnVector operator+(const FGColumnVector& B);
141 FGColumnVector operator-(const FGColumnVector& B);
142 float Magnitude(void);
143 FGColumnVector Normalize(void);
145 friend FGColumnVector operator*(const double scalar, const FGColumnVector& A);
146 friend FGColumnVector operator*(const FGMatrix& M, const FGColumnVector& V);
148 double& operator()(int m) const;
150 FGColumnVector multElementWise(const FGColumnVector& V);
153 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%