RT-WDF  0.0.1
Real-time Wave Digital Filter Framework
rt-wdf_nlSolvers.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the RT-WDF library.
5  Copyright (c) 2015,2016 - Maximilian Rest, Ross Dunkel, Kurt Werner.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  RT-WDF is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  -----------------------------------------------------------------------------
17  To release a closed-source product which uses RT-WDF, commercial licenses are
18  available: write to rt-wdf@e-rm.de for more information.
19 
20  ==============================================================================
21 
22  rt-wdf_nlSolvers.h
23  Created: 2 Dec 2015 4:08:19pm
24  Author: mrest
25 
26  ==============================================================================
27  */
28 
29 #ifndef RTWDF_NLSOLVERS_H_INCLUDED
30 #define RTWDF_NLSOLVERS_H_INCLUDED
31 
32 //==============================================================================
33 #include <float.h>
34 
35 #include "rt-wdf_types.h"
36 #include "rt-wdf_nlModels.h"
37 
38 
39 
40 //==============================================================================
41 // Define enums for solver identifiers
42 
43 
44 // Iterative:
45 // TODO: introduce enums!
47 #define NEWTON_SOLVER 1
48 
49 
50 
51 //==============================================================================
52 // Newton Solver config parameters
53 
55 #define TOL 1.0e-06 // TODO: evaluate physically meaningful tolerance.
56 
57 #define ITMAX 50
58 
59 
60 //==============================================================================
61 // Forward declarations
62 class nlSolver;
63 class nlNewtonSolver;
64 
65 
66 //==============================================================================
67 class nlSolver {
68 
69 public:
70  //----------------------------------------------------------------------
74  nlSolver();
75 
76  //----------------------------------------------------------------------
80  virtual ~nlSolver();
81 
82  //----------------------------------------------------------------------
90  int getNumPorts();
91 
92  //----------------------------------------------------------------------
104  virtual void nlSolve( vec* inWaves,
105  vec* outWaves ) = 0;
106 
107  //----------------------------------------------------------------------
111  std::vector<nlModel*> nlModels;
116 
117 };
118 
119 
120 //==============================================================================
121 class nlNewtonSolver : public nlSolver {
122 
123 protected:
124  //----------------------------------------------------------------------
128  vec* x0;
130  vec* fNL;
132  mat* JNL;
134  vec* F;
136  mat* J;
138  vec* Fmat_fNL;
140  bool firstRun = true;
141 
142 public:
143  //----------------------------------------------------------------------
157  nlNewtonSolver( std::vector<int> nlList,
158  matData* myMatData );
159 
163  ~nlNewtonSolver( );
164 
165  //----------------------------------------------------------------------
179  void nlSolve( vec* inWaves,
180  vec* outWaves );
181 
182  //----------------------------------------------------------------------
194  void evalNlModels(vec* inWaves, matData* myMatData, vec* x);
195 
196 };
197 
198 
199 #endif // RTWDF_NLSOLVERS_H_INCLUDED
vec * Fmat_fNL
Definition: rt-wdf_nlSolvers.h:138
vec * fNL
Definition: rt-wdf_nlSolvers.h:130
virtual ~nlSolver()
Definition: rt-wdf_nlSolvers.cpp:38
Definition: rt-wdf_types.h:45
int numNLPorts
Definition: rt-wdf_nlSolvers.h:115
mat * J
Definition: rt-wdf_nlSolvers.h:136
matData * myMatData
Definition: rt-wdf_nlSolvers.h:126
Definition: rt-wdf_nlSolvers.h:121
int getNumPorts()
Definition: rt-wdf_nlSolvers.cpp:43
virtual void nlSolve(vec *inWaves, vec *outWaves)=0
Definition: rt-wdf_nlSolvers.h:67
vec * F
Definition: rt-wdf_nlSolvers.h:134
std::vector< nlModel * > nlModels
Definition: rt-wdf_nlSolvers.h:111
vec * x0
Definition: rt-wdf_nlSolvers.h:128
nlSolver()
Definition: rt-wdf_nlSolvers.cpp:34
mat * JNL
Definition: rt-wdf_nlSolvers.h:132