]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGMatrix.h
JSBSim tweaks.
[flightgear.git] / src / FDM / JSBSim / FGMatrix.h
index c7a45d03b05cb8554971d91c6580ec59ca2bc748..99673444ed604c2f8f37b2813fc04424bd460b03 100644 (file)
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 Header: FGMatrix.h
 Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
@@ -9,70 +9,76 @@ HISTORY
 ??/??/??   TP   Created
 03/16/2000 JSB  Added exception throwing
 
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #ifndef FGMATRIX_H
 #define FGMATRIX_H
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include <stdlib.h>
 #ifdef FGFS
+#  include <math.h>
 #  include <simgear/compiler.h>
 #  include STL_STRING
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <fstream>
-#  else
-#    include <fstream.h>
-#  endif
-   FG_USING_STD(string);
+#  include STL_FSTREAM
+#  include STL_IOSTREAM
+   SG_USING_STD(string);
+   SG_USING_STD(ostream);
+   SG_USING_STD(istream);
+   SG_USING_STD(cerr);
+   SG_USING_STD(cout);
+   SG_USING_STD(endl);
 #else
-#  include <string>
 #  include <fstream>
+#  include <cmath>
+#  include <iostream>
+#  include <string>
+   using std::string;
+   using std::ostream;
+   using std::istream;
+   using std::cerr;
+   using std::cout;
+   using std::endl;
 #endif
 
-/*******************************************************************************
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_MATRIX "$Id$"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 class FGColumnVector;
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DECLARATION: MatrixException
-*******************************************************************************/
-
-using namespace std;
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class MatrixException /* :  public exception */  
+class MatrixException /* :  public exception */
 {
 public:
   string Message;
 };
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DECLARATION: FGMatrix
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 class FGMatrix
 {
-protected:
-  double **data;
-
-private:
-  unsigned int rows,cols;
-  char delim;
-  int width,prec,origin;
-  void TransposeSquare(void);
-  void TransposeNonSquare(void);
-  unsigned int rowCtr, colCtr;
-
 public:
   FGMatrix(unsigned int r, unsigned int c);
   FGMatrix(const FGMatrix& A);
+  FGMatrix(void) {};
   ~FGMatrix(void);
 
   FGMatrix& operator=(const FGMatrix& A);
@@ -105,11 +111,23 @@ public:
   friend FGMatrix operator*(double scalar,FGMatrix& A);
 
   void SetOParams(char delim,int width,int prec, int origin=0);
+
+protected:
+  double **data;
+  unsigned int rows,cols;
+
+private:
+  char delim;
+  int width,prec,origin;
+  void TransposeSquare(void);
+  void TransposeNonSquare(void);
+  unsigned int rowCtr, colCtr;
+  void Debug(void);
 };
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DECLARATION: FGColumnVector
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 class FGColumnVector : public FGMatrix
 {
@@ -117,18 +135,26 @@ public:
   FGColumnVector(void);
   FGColumnVector(int m);
   FGColumnVector(const FGColumnVector& b);
-  ~FGColumnVector();
+  ~FGColumnVector(void);
 
   FGColumnVector operator*(const double scalar);
+  FGColumnVector operator*(const FGColumnVector& V);   // Cross product operator
   FGColumnVector operator/(const double scalar);
-  FGColumnVector operator+(const FGColumnVector& B);
-  float Magnitude(void); 
+  FGColumnVector operator+(const FGColumnVector& B); // must not return reference
+  FGColumnVector operator-(const FGColumnVector& B);
+  float Magnitude(void);
   FGColumnVector Normalize(void);
 
   friend FGColumnVector operator*(const double scalar, const FGColumnVector& A);
+  friend FGColumnVector operator*(const FGMatrix& M, const FGColumnVector& V);
 
   double& operator()(int m) const;
+
+  FGColumnVector multElementWise(const FGColumnVector& V);
+
+private:
+  void Debug(void);
 };
 
-/******************************************************************************/
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 #endif