]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGColumnVector4.h
Emergency memory leak fix. ***Hopefully*** these fixes will get applied
[flightgear.git] / src / FDM / JSBSim / FGColumnVector4.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 FGCOLUMNVECTOR4_H
17 #define FGCOLUMNVECTOR4_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 #  if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
32      SG_USING_STD(ostream);
33      SG_USING_STD(istream);
34      SG_USING_STD(cerr);
35      SG_USING_STD(cout);
36      SG_USING_STD(endl);
37 #  endif
38 #else
39 #  include <string>
40 #  if defined (sgi) && !defined(__GNUC__)
41 #    include <fstream.h>
42 #    include <math.h>
43 #    include <iostream.h>
44 #  else
45 #    include <fstream>
46 #    include <cmath>
47 #    include <iostream>
48      using std::ostream;
49      using std::istream;
50      using std::cerr;
51      using std::cout;
52      using std::endl;
53 #  endif
54    using std::string;
55 #endif
56
57 #include "FGJSBBase.h"
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 DEFINITIONS
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 #define ID_COLUMNVECTOR4 "$Id$"
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 FORWARD DECLARATIONS
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 DECLARATION: FGColumnVector4
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 class FGColumnVector4 : public FGJSBBase
74 {
75 public:
76   FGColumnVector4(void);
77   FGColumnVector4(int m);
78   FGColumnVector4(const FGColumnVector4& b);
79   ~FGColumnVector4(void);
80   
81   FGColumnVector4 operator=(const FGColumnVector4& b);
82   
83   FGColumnVector4 operator*(const double scalar);
84   //FGColumnVector4 operator*(const FGColumnVector4& V);   // Cross product operator
85   FGColumnVector4 operator/(const double scalar);
86   FGColumnVector4 operator+(const FGColumnVector4& B); // must not return reference
87   FGColumnVector4 operator-(const FGColumnVector4& B);
88   
89   void operator-=(const FGColumnVector4 &B);
90   void operator+=(const FGColumnVector4 &B);
91   //void operator*=(const FGColumnVector4 &B);
92   void operator*=(const double scalar);
93   void operator/=(const double scalar);
94   
95   inline double operator()(int m) const { return data[m]; }
96   inline double& operator()(int m) { return data[m]; }
97   
98   FGColumnVector4& operator<<(const float ff);
99
100   inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; }
101   inline void InitMatrix(float ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
102
103   float Magnitude(void);
104   FGColumnVector4 Normalize(void);
105
106   friend FGColumnVector4 operator*(const double scalar, const FGColumnVector4& A);
107
108   friend ostream& operator<<(ostream& os, FGColumnVector4& col);
109
110
111   FGColumnVector4 multElementWise(const FGColumnVector4& V);
112
113 private:
114   double data[5];
115   int rowCtr;
116   void Debug(void);
117 };
118
119 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 #endif