GeoModel - GeoModelCore
Rectangular.cpp
1 //==========================================================================//
2 // Imported from the QAT library (qat.pitt.edu) by the copyright holder //
3 // Joe Boudreau. Software licensed under the terms and conditions of the //
4 // GNU Lesser Public License v3. //
5 //==========================================================================//
6 #include "GeoGenericFunctions/Rectangular.h"
7 #include "GeoGenericFunctions/FixedConstant.h"
8 #include <assert.h>
9 
10 namespace GeoGenfun {
11 FUNCTION_OBJECT_IMP(Rectangular)
12 
13 Rectangular::Rectangular():
14  _x0("x0", -1.0, -10, 0),
15  _x1("x1", 1.0, 0, 10),
16  _baseline("baseline", 0,-10, 10),
17  _height("height",1, -10, 10)
18 {}
19 
20 Rectangular::Rectangular(const Rectangular & right) :
21 AbsFunction(right),
22 _x0(right._x0),
23 _x1(right._x1),
24 _baseline(right._baseline),
25 _height(right._height)
26 {
27 }
28 
29 Rectangular::~Rectangular() {
30 }
31 
32 double Rectangular::operator() (double x) const {
33  if (x<_x0.getValue()) {
34  return _baseline.getValue();
35  }
36  else if (x<_x1.getValue()) {
37  return _height.getValue();
38  }
39  else {
40  return _baseline.getValue();
41  }
42 }
43 
44 Parameter & Rectangular::x0() {
45  return _x0;
46 }
47 
48 Parameter & Rectangular::x1() {
49  return _x1;
50 }
51 
52 Parameter & Rectangular::baseline() {
53  return _baseline;
54 }
55 
56 Parameter & Rectangular::height() {
57  return _height;
58 }
59 
60 const Parameter & Rectangular::x0() const {
61  return _x0;
62 }
63 
64 const Parameter & Rectangular::x1() const {
65  return _x1;
66 }
67 
68 const Parameter & Rectangular::baseline() const {
69  return _baseline;
70 }
71 
72 const Parameter & Rectangular::height() const{
73  return _height;
74 }
75 
76 // don't generate warnings about unused parameter inside assert
77 #if defined __GNUC__
78  #if __GNUC__ > 3 && __GNUC_MINOR__ > 6
79  #pragma GCC diagnostic push
80  #pragma GCC diagnostic ignored "-Wunused-parameter"
81  #endif
82 #endif
83 #ifdef __clang__
84  #pragma clang diagnostic push
85  #pragma clang diagnostic ignored "-Wunused-parameter"
86 #endif
87 Derivative Rectangular::partial(unsigned int index) const {
88  assert(index==0);
89  const AbsFunction & fPrime = FixedConstant(0);;
90  return Derivative(&fPrime);
91 }
92 #if defined __GNUC__
93  #if __GNUC__ > 3 && __GNUC_MINOR__ > 6
94  #pragma GCC diagnostic pop
95  #endif
96 #endif
97 #ifdef __clang__
98  #pragma clang diagnostic pop
99 #endif
100 
101 } // namespace Genfun
Definition: Abs.h:15