]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBsim/FGMatrix.h
source tree reorganization prior to flightgear 0.7
[flightgear.git] / src / FDM / JSBsim / FGMatrix.h
1 /*******************************************************************************
2
3 Header: FGMatrix.h
4 Author: Tony Peden [formatted here by Jon Berndt]
5 Date started: Unknown
6
7 HISTORY
8 --------------------------------------------------------------------------------
9 ??/??/??   TP   Created
10
11 /*******************************************************************************
12 SENTRY
13 *******************************************************************************/
14
15 #ifndef FGMATRIX_H
16 #define FGMATRIX_H
17
18 /*******************************************************************************
19 INCLUDES
20 *******************************************************************************/
21
22 #include <stdlib.h>
23 #include <iostream.h>
24 #include <fstream.h>
25
26 /*******************************************************************************
27 DEFINES
28 *******************************************************************************/
29
30
31 /*******************************************************************************
32 CONSTANTS
33 *******************************************************************************/
34
35
36 /*******************************************************************************
37 TYPEDEFS
38 *******************************************************************************/
39
40
41 /*******************************************************************************
42 GLOBALS
43 *******************************************************************************/
44
45 class FGMatrix
46 {
47 private:
48   double **data;
49   unsigned rows,cols;
50   bool keep;
51   char delim;
52   int width,prec,origin;
53   void TransposeSquare(void);
54   void TransposeNonSquare(void);
55
56 public:
57   FGMatrix(unsigned rows, unsigned cols);
58   FGMatrix(const FGMatrix& A);
59   ~FGMatrix(void);
60
61   FGMatrix& FGMatrix::operator=(const FGMatrix& A);
62   double& FGMatrix::operator()(unsigned row, unsigned col);
63
64   unsigned FGMatrix::Rows(void) const;
65   unsigned FGMatrix::Cols(void) const;
66
67   void FGMatrix::T(void);
68   void InitMatrix(void);
69   void InitMatrix(double value);
70
71   friend FGMatrix operator-(FGMatrix& A, FGMatrix& B);
72   friend FGMatrix operator+(FGMatrix& A, FGMatrix& B);
73   friend FGMatrix operator*(double scalar,FGMatrix& A);
74   friend FGMatrix operator*(FGMatrix& Left, FGMatrix& Right);
75   friend FGMatrix operator/(FGMatrix& A, double scalar);
76
77   friend void operator-=(FGMatrix &A,FGMatrix &B);
78   friend void operator+=(FGMatrix &A,FGMatrix &B);
79   friend void operator*=(FGMatrix &A,FGMatrix &B);
80   friend void operator*=(FGMatrix &A,double scalar);
81   friend void operator/=(FGMatrix &A,double scalar);
82
83   void SetOParams(char delim,int width,int prec, int origin=0);
84 };
85
86 class FGColumnVector : public FGMatrix
87 {
88 public:
89   FGColumnVector(void);
90   FGColumnVector(int m);
91   FGColumnVector(FGColumnVector& b);
92   ~FGColumnVector();
93
94   double& operator()(int m);
95 };
96
97 /******************************************************************************/
98 #endif