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
33 # include <iostream.h>
43 /*******************************************************************************
45 *******************************************************************************/
49 /*******************************************************************************
50 DECLARATION: MatrixException
51 *******************************************************************************/
59 class MatrixException /* : public exception */
65 /*******************************************************************************
67 *******************************************************************************/
75 unsigned int rows,cols;
77 int width,prec,origin;
78 void TransposeSquare(void);
79 void TransposeNonSquare(void);
80 unsigned int rowCtr, colCtr;
83 FGMatrix(unsigned int r, unsigned int c);
84 FGMatrix(const FGMatrix& A);
87 FGMatrix& operator=(const FGMatrix& A);
88 inline double& operator()(unsigned int row, unsigned int col) const {return data[row][col];}
90 FGColumnVector operator*(const FGColumnVector& Col);
92 unsigned int Rows(void) const;
93 unsigned int Cols(void) const;
96 void InitMatrix(void);
97 void InitMatrix(double value);
99 FGMatrix operator-(const FGMatrix& B);
100 FGMatrix operator+(const FGMatrix& B);
101 FGMatrix operator*(const FGMatrix& B);
102 FGMatrix operator/(const double scalar);
103 FGMatrix& operator<<(const float ff);
105 friend ostream& operator<<(ostream& os, const FGMatrix& M);
106 friend istream& operator>>(istream& is, FGMatrix& M);
108 void operator-=(const FGMatrix &B);
109 void operator+=(const FGMatrix &B);
110 void operator*=(const FGMatrix &B);
111 void operator*=(const double scalar);
112 void operator/=(const double scalar);
114 friend FGMatrix operator*(double scalar,FGMatrix& A);
116 void SetOParams(char delim,int width,int prec, int origin=0);
119 /*******************************************************************************
120 DECLARATION: FGColumnVector
121 *******************************************************************************/
123 class FGColumnVector : public FGMatrix
126 FGColumnVector(void);
127 FGColumnVector(int m);
128 FGColumnVector(const FGColumnVector& b);
131 FGColumnVector operator*(const double scalar);
132 FGColumnVector operator*(const FGColumnVector& V); // Cross product operator
133 FGColumnVector operator/(const double scalar);
134 FGColumnVector operator+(const FGColumnVector& B);
135 FGColumnVector operator-(const FGColumnVector& B);
136 float Magnitude(void);
137 FGColumnVector Normalize(void);
139 friend FGColumnVector operator*(const double scalar, const FGColumnVector& A);
140 friend FGColumnVector operator*(const FGMatrix& M, const FGColumnVector& V);
142 double& operator()(int m) const;
144 FGColumnVector multElementWise(const FGColumnVector& V);
147 /******************************************************************************/