Marine systems simulation
Vectorfit.h
1#ifndef CVectorfit_h__
2#define CVectorfit_h__
3
4#include <complex>
5#include <Eigen/Eigen>
6
7using namespace Eigen;
8
9typedef Matrix< std::complex<double>,1,Dynamic> vec_complex;
10typedef Matrix< double,1,Dynamic> vec;
11typedef Matrix< double,Dynamic,Dynamic> mat ;
12typedef Matrix< std::complex<double>,Dynamic,Dynamic> mat_complex ;
13
14namespace Ship{
16 {
17 public:
18 EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
19 VectorFit();
20 int Fitoption() const { return m_Fitoption; }
21 void Fitoption(int val) { m_Fitoption = val; }
22
23 bool RelaxedConstraint() const { return m_RelaxedConstraint; }
24 void RelaxedConstraint(bool val) { m_RelaxedConstraint = val; }
25 bool FlipUnstable() const { return m_FlipUnstable; }
26 void FlipUnstable(bool val) { m_FlipUnstable = val; }
27 bool PoleIdentification() const { return m_PoleIdentification; }
28 void PoleIdentification(bool val) { m_PoleIdentification = val; }
29 bool ResidueIdentification() const { return m_ResidueIdentification; }
30 void ResidueIdentification(bool val) { m_ResidueIdentification = val; }
31 bool ComplexStateSpace() const { return m_ComplexStateSpace; }
32 void ComplexStateSpace(bool val) { m_ComplexStateSpace = val; }
33
34 mat_complex MatrixA() const { return matrixA; }
35 void MatrixA(mat_complex val) { matrixA = val; }
36 mat_complex MatrixB() const { return matrixB; }
37 void MatrixB(mat_complex val) { matrixB = val; }
38 mat_complex MatrixC() const { return matrixC; }
39 void MatrixC(mat_complex val) { matrixC = val; }
40 std::complex<double> MatrixD() const { return matrixD; }
41 void MatrixD(std::complex<double> val) { matrixD = val; }
42 std::complex<double> MatrixE() const { return matrixE; }
43 void MatrixE(std::complex<double> val) { matrixE = val; }
44
45 mat MatrixAreal() const ;
46 mat MatrixBreal() const ;
47 mat MatrixCreal() const ;
48 double MatrixDreal() const ;
49 double MatrixEreal() const ;
50
51 mat_complex Diff() const { return diff; }
52 double Rmserr() const { return rmserr;}
53
54 void Fit(const vec_complex &f, const vec_complex &s, vec_complex &poles, const vec & weight);
55
56 vec_complex LinSolveLS( mat &A, mat &B);
57 vec_complex LinSolve( mat &A, mat &B);
58 vec_complex MatrixPolynomial( const mat_complex &A );
59 vec_complex EigenValues( const mat_complex &ZER );
60
61 void QRFactor( mat &A_new, mat &Q, mat &R );
62 void TransferFunction( vec_complex& num, vec_complex &den);
63
64 private:
65 int m_Fitoption; // 1: Fitting with D=0, E=0, 2: Fitting with D~=0, E=0, 3: Fitting with D~=0, E~=0
66 bool m_RelaxedConstraint; // Use relaxed nontriviality constraint
67 bool m_FlipUnstable; // Unstable poles are kept unchanged
68 bool m_PoleIdentification; // The pole identification part is skipped, i.e (C,D,E)
69 bool m_ResidueIdentification; // The residue identification part is skipped, i.e. only the poles (A) are identified while C,D,E are returned as zero.
70 bool m_ComplexStateSpace; // The returned state-space model has real and complex parameters. Output variable A is diagonal (and sparse).
71
72 mat_complex diff;
73 double rmserr;
74
75 mat_complex matrixA;
76 mat_complex matrixB;
77 mat_complex matrixC;
78 std::complex<double> matrixD;
79 std::complex<double> matrixE;
80 static bool root_less_pred( std::complex<double> const& lh, std::complex<double> const &rh)
81 {
82 return lh.real() < rh.real();
83 }
84
85 };
86}
87
88
89#endif // CVectorfit_h__
Definition: Vectorfit.h:16
Simple waypoint object.
Definition: CableAttach.h:16