isce3 0.25.0
Loading...
Searching...
No Matches
LUT1d.h
1#pragma once
2
3#include "forward.h"
4#include <isce3/core/EMatrix.h>
5#include <isce3/except/Error.h>
6
7#include <valarray>
8#include <Eigen/Core>
9
10namespace isce3::core {
11
14template <typename T>
15class LUT1d {
16
17 public:
18 using ArrayXt = Eigen::Array<T, Eigen::Dynamic, 1>;
20 inline LUT1d() : _haveData(false), _refValue(0.0), _extrapolate{true} {
21 std::valarray<double> x{0.0, 1.0};
22 std::valarray<double> y{0.0, 0.0};
23 _coords = x;
24 _values = y;
25 }
26
28 inline LUT1d(T refValue) : _haveData(false), _refValue(refValue), _extrapolate{true} {}
29
31 inline LUT1d(size_t size) : _haveData(false), _refValue(0.0), _extrapolate{true} {
32 _coords.resize(size);
33 _values.resize(size);
34 }
35
40 inline LUT1d(const std::valarray<double> & coords, const std::valarray<T> & values,
41 bool extrapolate = false) :
42 _haveData(true),
43 _refValue(values[0]),
44 _coords(coords),
45 _values(values),
46 _extrapolate{extrapolate} {}
47
50 inline LUT1d(const LUT1d<T> & lut) :
51 _haveData(lut.haveData()),
52 _refValue(lut.refValue()),
53 _coords(lut.coords()),
54 _values(lut.values()),
55 _extrapolate(lut.extrapolate()) {}
56
59 inline LUT1d & operator=(const LUT1d<T> & lut) {
60 _haveData = lut.haveData();
61 _refValue = lut.refValue();
62 _coords = lut.coords();
63 _values = lut.values();
64 _extrapolate = lut.extrapolate();
65 return *this;
66 }
67
70 inline std::valarray<double> & coords() { return _coords; }
71
74 inline const std::valarray<double> & coords() const { return _coords; }
75
78 inline void coords(const std::valarray<double> & c) { _coords = c; }
79
82 inline std::valarray<T> & values() { return _values; }
83
86 inline const std::valarray<T> & values() const { return _values; }
87
90 inline void values(const std::valarray<T> & v) { _values = v; }
91
94 inline bool extrapolate() const { return _extrapolate; }
95
98 inline void extrapolate(bool flag) { _extrapolate = flag; }
99
101 inline bool haveData() const { return _haveData; }
102
104 inline T refValue() const { return _refValue; }
105
108 inline size_t size() const { return _coords.size(); }
109
111 inline T eval(double x) const;
112 inline ArrayXt eval(const Eigen::Ref<const Eigen::ArrayXd>& x) const;
113 // Data members
114 private:
115 bool _haveData;
116 T _refValue;
117 std::valarray<double> _coords;
118 std::valarray<T> _values;
119 bool _extrapolate;
120};
121
126template <typename T>
127LUT1d<T> avgLUT2dToLUT1d(const LUT2d<T> & lut2d, const int axis = 0);
128
129} // namespace isce3::core
130
131// Get inline implementations for LUT1d
132#define ISCE_CORE_LUT1D_ICC
133#include "LUT1d.icc"
134#undef ISCE_CORE_LUT1D_ICC
Data structure to hold a 1D Lookup table.
Definition LUT1d.h:15
void values(const std::valarray< T > &v)
Set the values.
Definition LUT1d.h:90
bool haveData() const
Get flag for having data.
Definition LUT1d.h:101
std::valarray< T > & values()
Get a reference to the coordinates.
Definition LUT1d.h:82
bool extrapolate() const
Get extrapolate flag.
Definition LUT1d.h:94
LUT1d(const LUT1d< T > &lut)
Copy constructor.
Definition LUT1d.h:50
T refValue() const
Get reference value.
Definition LUT1d.h:104
LUT1d(size_t size)
Constructor with size.
Definition LUT1d.h:31
LUT1d()
Default constructor.
Definition LUT1d.h:20
LUT1d(T refValue)
Constructor with a constant reference value.
Definition LUT1d.h:28
const std::valarray< double > & coords() const
Get a read-only reference to the coordinates.
Definition LUT1d.h:74
void extrapolate(bool flag)
Set extrapolate flag.
Definition LUT1d.h:98
LUT1d(const std::valarray< double > &coords, const std::valarray< T > &values, bool extrapolate=false)
Constructor with coordinates and values.
Definition LUT1d.h:40
void coords(const std::valarray< double > &c)
Set the coordinates.
Definition LUT1d.h:78
const std::valarray< T > & values() const
Get a read-only reference to the values.
Definition LUT1d.h:86
size_t size() const
Get size of LUT.
Definition LUT1d.h:108
std::valarray< double > & coords()
Get a reference to the coordinates.
Definition LUT1d.h:70
LUT1d & operator=(const LUT1d< T > &lut)
Assignment operator.
Definition LUT1d.h:59
T eval(double x) const
Evaluate the LUT.
Definition LUT1d.icc:11

Generated for ISCE3.0 by doxygen 1.13.2.