KADATH
eq_int.cpp
1 /*
2  Copyright 2017 Philippe Grandclement
3 
4  This file is part of Kadath.
5 
6  Kadath is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Kadath is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Kadath. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "system_of_eqs.hpp"
21 #include "ope_eq.hpp"
22 #include "term_eq.hpp"
23 #include "scalar.hpp"
24 #include "tensor_impl.hpp"
25 namespace Kadath {
26 Eq_int::Eq_int (int np) : n_ope(np) {
27  parts = new Ope_eq*[n_ope] ;
28  for (int i=0 ; i<n_ope ; i++)
29  parts[i] = 0x0 ;
30 }
31 
33  for (int i=0 ; i<n_ope ; i++)
34  if (parts[i] !=0x0)
35  delete parts[i] ;
36  delete [] parts ;
37 }
38 
39 double Eq_int::get_val() const {
40  double res = 0. ;
41  for (int i=0 ; i<n_ope ; i++) {
42  res += parts[i]->action().get_val_d() ;
43  }
44  return res ;
45 }
46 
47 double Eq_int::get_der() const {
48  double res = 0. ;
49  for (int i=0 ; i<n_ope ; i++)
50  res += parts[i]->action().get_der_d() ;
51  return res ;
52 }
53 
54 void Eq_int::set_part (int pos, Ope_eq* so) {
55  assert ((pos>=0) && (pos<n_ope)) ;
56  parts[pos] = so ;
57 }}
Ope_eq ** parts
Array of pointers on the various terms.
double get_der() const
Return the variation of the equation.
Definition: eq_int.cpp:47
~Eq_int()
Destructor.
Definition: eq_int.cpp:32
int n_ope
Number of terms.
Eq_int(int nop)
Constructor just sets n_ope.
Definition: eq_int.cpp:26
void set_part(int i, Ope_eq *ope)
Sets one of the Ope_eq needed by the equation.
Definition: eq_int.cpp:54
double get_val() const
Return the value of the equation.
Definition: eq_int.cpp:39
Abstract class that describes the various operators that can appear in the equations.
Definition: ope_eq.hpp:32
virtual Term_eq action() const =0
Computes the action of the current Ope_eq using its various parts.
double get_val_d() const
Definition: term_eq.hpp:327