2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-13 01:12:03 +00:00
|
|
|
|
|
|
|
Header: FGMatrix.h
|
2000-04-24 23:49:06 +00:00
|
|
|
Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
|
1999-02-13 01:12:03 +00:00
|
|
|
Date started: Unknown
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
??/??/?? TP Created
|
2000-04-24 23:49:06 +00:00
|
|
|
03/16/2000 JSB Added exception throwing
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-13 01:12:03 +00:00
|
|
|
SENTRY
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-13 01:12:03 +00:00
|
|
|
|
|
|
|
#ifndef FGMATRIX_H
|
|
|
|
#define FGMATRIX_H
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-13 01:12:03 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-13 01:12:03 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2000-04-24 23:49:06 +00:00
|
|
|
#ifdef FGFS
|
|
|
|
# include <simgear/compiler.h>
|
2001-04-02 03:12:38 +00:00
|
|
|
# include STL_STRING
|
|
|
|
SG_USING_STD(string);
|
|
|
|
SG_USING_STD(ostream);
|
|
|
|
SG_USING_STD(istream);
|
|
|
|
SG_USING_STD(cerr);
|
|
|
|
SG_USING_STD(endl);
|
2001-03-30 01:04:50 +00:00
|
|
|
# ifdef FG_HAVE_STD_INCLUDES
|
2000-04-24 23:49:06 +00:00
|
|
|
# include <fstream>
|
2000-07-06 21:02:46 +00:00
|
|
|
# include <cmath>
|
2000-10-02 23:07:30 +00:00
|
|
|
# include <iostream>
|
2000-04-24 23:49:06 +00:00
|
|
|
# else
|
|
|
|
# include <fstream.h>
|
2000-07-06 21:02:46 +00:00
|
|
|
# include <math.h>
|
2000-10-02 23:07:30 +00:00
|
|
|
# include <iostream.h>
|
2000-04-24 23:49:06 +00:00
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <fstream>
|
2000-07-06 21:02:46 +00:00
|
|
|
# include <cmath>
|
2000-10-02 23:07:30 +00:00
|
|
|
# include <iostream>
|
2001-04-02 03:12:38 +00:00
|
|
|
# include <string>
|
|
|
|
using std::string;
|
|
|
|
using std::ostream;
|
|
|
|
using std::istream;
|
|
|
|
using std::cerr;
|
|
|
|
using std::endl;
|
2000-04-24 23:49:06 +00:00
|
|
|
#endif
|
1999-02-13 01:12:03 +00:00
|
|
|
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
DEFINITIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
#define ID_MATRIX "$Id$"
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
FORWARD DECLARATIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
class FGColumnVector;
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
DECLARATION: MatrixException
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
class MatrixException /* : public exception */
|
2000-04-24 23:49:06 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
string Message;
|
|
|
|
};
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
DECLARATION: FGMatrix
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-13 01:12:03 +00:00
|
|
|
|
|
|
|
class FGMatrix
|
|
|
|
{
|
|
|
|
public:
|
2000-04-24 23:49:06 +00:00
|
|
|
FGMatrix(unsigned int r, unsigned int c);
|
1999-02-13 01:12:03 +00:00
|
|
|
FGMatrix(const FGMatrix& A);
|
2001-03-30 01:04:50 +00:00
|
|
|
FGMatrix(void) {};
|
1999-02-13 01:12:03 +00:00
|
|
|
~FGMatrix(void);
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
FGMatrix& operator=(const FGMatrix& A);
|
|
|
|
inline double& operator()(unsigned int row, unsigned int col) const {return data[row][col];}
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
FGColumnVector operator*(const FGColumnVector& Col);
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
unsigned int Rows(void) const;
|
|
|
|
unsigned int Cols(void) const;
|
|
|
|
|
|
|
|
void T(void);
|
1999-02-13 01:12:03 +00:00
|
|
|
void InitMatrix(void);
|
|
|
|
void InitMatrix(double value);
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
FGMatrix operator-(const FGMatrix& B);
|
|
|
|
FGMatrix operator+(const FGMatrix& B);
|
|
|
|
FGMatrix operator*(const FGMatrix& B);
|
|
|
|
FGMatrix operator/(const double scalar);
|
|
|
|
FGMatrix& operator<<(const float ff);
|
|
|
|
|
|
|
|
friend ostream& operator<<(ostream& os, const FGMatrix& M);
|
|
|
|
friend istream& operator>>(istream& is, FGMatrix& M);
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
void operator-=(const FGMatrix &B);
|
|
|
|
void operator+=(const FGMatrix &B);
|
|
|
|
void operator*=(const FGMatrix &B);
|
|
|
|
void operator*=(const double scalar);
|
|
|
|
void operator/=(const double scalar);
|
|
|
|
|
|
|
|
friend FGMatrix operator*(double scalar,FGMatrix& A);
|
1999-02-13 01:12:03 +00:00
|
|
|
|
|
|
|
void SetOParams(char delim,int width,int prec, int origin=0);
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
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);
|
1999-02-13 01:12:03 +00:00
|
|
|
};
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-04-24 23:49:06 +00:00
|
|
|
DECLARATION: FGColumnVector
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-04-24 23:49:06 +00:00
|
|
|
|
1999-02-13 01:12:03 +00:00
|
|
|
class FGColumnVector : public FGMatrix
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FGColumnVector(void);
|
|
|
|
FGColumnVector(int m);
|
2000-04-24 23:49:06 +00:00
|
|
|
FGColumnVector(const FGColumnVector& b);
|
2001-03-30 01:04:50 +00:00
|
|
|
~FGColumnVector(void);
|
1999-02-13 01:12:03 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
FGColumnVector operator*(const double scalar);
|
2001-04-17 21:19:54 +00:00
|
|
|
FGColumnVector operator*(const FGColumnVector& V); // Cross product operator
|
2000-04-24 23:49:06 +00:00
|
|
|
FGColumnVector operator/(const double scalar);
|
2001-03-30 01:04:50 +00:00
|
|
|
FGColumnVector operator+(const FGColumnVector& B); // must not return reference
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
FGColumnVector operator-(const FGColumnVector& B);
|
|
|
|
float Magnitude(void);
|
2000-04-24 23:49:06 +00:00
|
|
|
FGColumnVector Normalize(void);
|
|
|
|
|
|
|
|
friend FGColumnVector operator*(const double scalar, const FGColumnVector& A);
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
friend FGColumnVector operator*(const FGMatrix& M, const FGColumnVector& V);
|
2000-04-24 23:49:06 +00:00
|
|
|
|
|
|
|
double& operator()(int m) const;
|
2001-04-02 03:12:38 +00:00
|
|
|
|
2001-04-17 21:19:54 +00:00
|
|
|
FGColumnVector multElementWise(const FGColumnVector& V);
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Debug(void);
|
|
|
|
};
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-13 01:12:03 +00:00
|
|
|
#endif
|