isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
LUT1d.h
1 //-*- C++ -*-
2 //-*- coding: utf-8 -*-
3 //
4 // Source Author: Bryan Riel
5 // Copyright 2017-2018
6 //
7 
8 #pragma once
9 
10 #include "forward.h"
11 
12 #include <valarray>
13 
16 template <typename T>
17 class isce3::core::LUT1d {
18 
19  public:
21  inline LUT1d() : _haveData(false), _refValue(0.0), _extrapolate{true} {
22  std::valarray<double> x{0.0, 1.0};
23  std::valarray<double> y{0.0, 0.0};
24  _coords = x;
25  _values = y;
26  }
27 
29  inline LUT1d(T refValue) : _haveData(false), _refValue(refValue), _extrapolate{true} {}
30 
32  inline LUT1d(size_t size) : _haveData(false), _refValue(0.0), _extrapolate{true} {
33  _coords.resize(size);
34  _values.resize(size);
35  }
36 
41  inline LUT1d(const std::valarray<double> & coords, const std::valarray<T> & values,
42  bool extrapolate = false) :
43  _haveData(true),
44  _refValue(values[0]),
45  _coords(coords),
46  _values(values),
47  _extrapolate{extrapolate} {}
48 
51  inline LUT1d(const LUT1d<T> & lut) :
52  _haveData(lut.haveData()),
53  _refValue(lut.refValue()),
54  _coords(lut.coords()),
55  _values(lut.values()),
56  _extrapolate(lut.extrapolate()) {}
57 
60  inline LUT1d & operator=(const LUT1d<T> & lut) {
61  _haveData = lut.haveData();
62  _refValue = lut.refValue();
63  _coords = lut.coords();
64  _values = lut.values();
65  _extrapolate = lut.extrapolate();
66  return *this;
67  }
68 
70  inline LUT1d(const LUT2d<T> & lut2d);
71 
73  inline LUT1d & operator=(const LUT2d<T> & lut2d);
74 
77  inline std::valarray<double> & coords() { return _coords; }
78 
81  inline const std::valarray<double> & coords() const { return _coords; }
82 
85  inline void coords(const std::valarray<double> & c) { _coords = c; }
86 
89  inline std::valarray<T> & values() { return _values; }
90 
93  inline const std::valarray<T> & values() const { return _values; }
94 
97  inline void values(const std::valarray<T> & v) { _values = v; }
98 
101  inline bool extrapolate() const { return _extrapolate; }
102 
105  inline void extrapolate(bool flag) { _extrapolate = flag; }
106 
108  inline bool haveData() const { return _haveData; }
109 
111  inline T refValue() const { return _refValue; }
112 
115  inline size_t size() const { return _coords.size(); }
116 
118  inline T eval(double x) const;
119 
120  // Data members
121  private:
122  bool _haveData;
123  T _refValue;
124  std::valarray<double> _coords;
125  std::valarray<T> _values;
126  bool _extrapolate;
127 };
128 
129 // Get inline implementations for LUT1d
130 #define ISCE_CORE_LUT1D_ICC
131 #include "LUT1d.icc"
132 #undef ISCE_CORE_LUT1D_ICC
LUT1d(size_t size)
Constructor with size.
Definition: LUT1d.h:32
std::valarray< T > & values()
Get a reference to the coordinates.
Definition: LUT1d.h:89
bool extrapolate() const
Get extrapolate flag.
Definition: LUT1d.h:101
T refValue() const
Get reference value.
Definition: LUT1d.h:111
const std::valarray< T > & values() const
Get a read-only reference to the values.
Definition: LUT1d.h:93
T eval(double x) const
Evaluate the LUT.
Definition: LUT1d.icc:106
size_t size() const
Get size of LUT.
Definition: LUT1d.h:115
Data structure to hold a 1D Lookup table.
Definition: forward.h:29
const std::valarray< double > & coords() const
Get a read-only reference to the coordinates.
Definition: LUT1d.h:81
Data structure to store 2D Lookup table.
Definition: forward.h:30
LUT1d(T refValue)
Constructor with a constant reference value.
Definition: LUT1d.h:29
bool haveData() const
Get flag for having data.
Definition: LUT1d.h:108
void values(const std::valarray< T > &v)
Set the values.
Definition: LUT1d.h:97
LUT1d()
Default constructor.
Definition: LUT1d.h:21
LUT1d & operator=(const LUT1d< T > &lut)
Assignment operator.
Definition: LUT1d.h:60
LUT1d(const std::valarray< double > &coords, const std::valarray< T > &values, bool extrapolate=false)
Constructor with coordinates and values.
Definition: LUT1d.h:41
LUT1d(const LUT1d< T > &lut)
Copy constructor.
Definition: LUT1d.h:51
std::valarray< double > & coords()
Get a reference to the coordinates.
Definition: LUT1d.h:77
void extrapolate(bool flag)
Set extrapolate flag.
Definition: LUT1d.h:105
void coords(const std::valarray< double > &c)
Set the coordinates.
Definition: LUT1d.h:85

Generated for ISCE3.0 by doxygen 1.8.5.