]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGColumnVector4.h
Patches from Erik Hofman for SGI compatibility:
[flightgear.git] / src / FDM / JSBSim / FGColumnVector4.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGColumnVector4.h
4 Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
5 Date started: Unknown
6
7 HISTORY
8 --------------------------------------------------------------------------------
9
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 SENTRY
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
13
14 #ifndef FGCOLUMNVECTOR4_H
15 #define FGCOLUMNVECTOR4_H
16
17 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 INCLUDES
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
20
21 #include <stdlib.h>
22 #ifdef FGFS
23 #  include <math.h>
24 #  include <simgear/compiler.h>
25 #  include STL_STRING
26 #  include STL_FSTREAM
27 #  include STL_IOSTREAM
28    SG_USING_STD(string);
29    SG_USING_STD(ostream);
30    SG_USING_STD(istream);
31    SG_USING_STD(cerr);
32    SG_USING_STD(cout);
33    SG_USING_STD(endl);
34 #else
35 #  include <string>
36 #  if defined (sgi) && !defined(__GNUC__)
37 #    include <fstream.h>
38 #    include <math.h>
39 #    include <iostream.h>
40 #  else
41 #    include <fstream>
42 #    include <cmath>
43 #    include <iostream>
44      using std::ostream;
45      using std::istream;
46      using std::cerr;
47      using std::cout;
48      using std::endl;
49 #  endif
50    using std::string;
51 #endif
52
53 #include "FGJSBBase.h"
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 DEFINITIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 #define ID_COLUMNVECTOR4 "$Id$"
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 FORWARD DECLARATIONS
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 DECLARATION: FGColumnVector4
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69 class FGColumnVector4 : public FGJSBBase
70 {
71 public:
72   FGColumnVector4(void);
73   FGColumnVector4(double A, double B, double C, double D);
74   FGColumnVector4(const FGColumnVector4& b);
75   ~FGColumnVector4(void);
76   
77   FGColumnVector4 operator=(const FGColumnVector4& b);
78   
79   FGColumnVector4 operator*(const double scalar);
80   FGColumnVector4 operator/(const double scalar);
81   FGColumnVector4 operator+(const FGColumnVector4& B); // must not return reference
82   FGColumnVector4 operator-(const FGColumnVector4& B);
83   
84   void operator-=(const FGColumnVector4 &B);
85   void operator+=(const FGColumnVector4 &B);
86   void operator*=(const double scalar);
87   void operator/=(const double scalar);
88   
89   inline double operator()(int m) const { return data[m]; }
90   inline double& operator()(int m) { return data[m]; }
91   
92   FGColumnVector4& operator<<(const double ff);
93
94   inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; data[4]=0; }
95   inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; data[4]=ff;}
96
97   double Magnitude(void);
98   FGColumnVector4 Normalize(void);
99
100   friend FGColumnVector4 operator*(const double scalar, const FGColumnVector4& A);
101
102   friend ostream& operator<<(ostream& os, FGColumnVector4& col);
103
104
105   FGColumnVector4 multElementWise(const FGColumnVector4& V);
106
107 private:
108   double data[5];
109   int rowCtr;
110   void Debug(int from);
111 };
112
113 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 #endif
115