]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGMatrix33.h
Adjust the turbine names for N1, N2 and EGT_degC to match those already specified...
[flightgear.git] / src / FDM / JSBSim / FGMatrix33.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGMatrix33.h
4 Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
5 Date started: Unknown
6
7 HISTORY
8 --------------------------------------------------------------------------------
9 ??/??/??   TP   Created
10 03/16/2000 JSB  Added exception throwing
11
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 SENTRY
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
15
16 #ifndef FGMATRIX33_H
17 #define FGMATRIX33_H
18
19 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 INCLUDES
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
22
23 #include <stdlib.h>
24 #ifdef FGFS
25 #  include <math.h>
26 #  include <simgear/compiler.h>
27 #  include STL_STRING
28 #  include STL_FSTREAM
29 #  include STL_IOSTREAM
30    SG_USING_STD(string);
31    SG_USING_STD(ostream);
32    SG_USING_STD(istream);
33    SG_USING_STD(cerr);
34    SG_USING_STD(cout);
35    SG_USING_STD(endl);
36 #else
37 #  include <string>
38 #  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
39      include <fstream.h>
40      include <iostream.h>
41 #    include <math.h>
42 #  else
43 #    include <fstream>
44 #    include <iostream>
45 #    if defined(sgi) && !defined(__GNUC__)
46 #      include <math.h>
47 #    else
48 #      include <cmath>
49 #    endif
50      using std::ostream;
51      using std::istream;
52      using std::cerr;
53      using std::cout;
54      using std::endl;
55 #  endif
56    using std::string;
57 #endif
58
59 #include "FGColumnVector3.h"
60 #include "FGJSBBase.h"
61
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 DEFINITIONS
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65
66 #define ID_MATRIX33 "$Id$"
67
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 FORWARD DECLARATIONS
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71
72 namespace JSBSim {
73
74 class FGColumnVector3;
75
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 CLASS DOCUMENTATION
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
79
80 /** Exception convenience class.
81   */
82
83 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 DECLARATION: MatrixException
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
86
87 class MatrixException : public FGJSBBase
88 {
89 public:
90   string Message;
91 };
92
93 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 CLASS DOCUMENTATION
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
96
97 /** Handles matrix math operations.
98   */
99
100 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 DECLARATION: FGMatrix33
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
103
104 class FGMatrix33 : public FGJSBBase
105 {
106 public:
107   FGMatrix33(void);
108   FGMatrix33(int r, int c);
109   FGMatrix33(const FGMatrix33& A);
110   ~FGMatrix33(void);
111
112   FGMatrix33& operator=(const FGMatrix33& A);
113   inline double operator()(unsigned int row, unsigned int col) const {return data[row][col];}
114   inline double& operator()(unsigned int row, unsigned int col) {return data[row][col];}
115
116   FGColumnVector3 operator*(const FGColumnVector3& Col);
117
118   inline unsigned int Rows(void) const { return 3; }
119   inline unsigned int Cols(void) const { return 3; }
120
121   void T(void);
122   void InitMatrix(void);
123   void InitMatrix(double value);
124   
125   //friend FGMatrix33 operator*(double scalar,FGMatrix33& A);
126
127   FGMatrix33 operator-(const FGMatrix33& B);
128   FGMatrix33 operator+(const FGMatrix33& B);
129   FGMatrix33 operator*(const FGMatrix33& B);
130   FGMatrix33 operator*(const double scalar);
131   FGMatrix33 operator/(const double scalar);
132   FGMatrix33& operator<<(const double ff);
133
134   friend ostream& operator<<(ostream& os, const FGMatrix33& M);
135   friend istream& operator>>(istream& is, FGMatrix33& M);
136
137   void operator-=(const FGMatrix33 &B);
138   void operator+=(const FGMatrix33 &B);
139   void operator*=(const FGMatrix33 &B);
140   void operator*=(const double scalar);
141   void operator/=(const double scalar);
142
143 protected:
144   double data[4][4];
145
146 private:
147   void TransposeSquare(void);
148   unsigned int rowCtr, colCtr;
149   void Debug(int from);
150 };
151 }
152 #endif