44#define G_AT "GNodeArray::at(int&)"
45#define G_INSERT "GNodeArray::insert(int&, double&)"
46#define G_REMOVE "GNodeArray::remove(int&)"
47#define G_INTERPOLATE "GNodeArray::interpolate(double&,"\
48 " std::vector<double>&)"
49#define G_SET_VALUE "GNodeArray::set_value(double&)"
208 if (
this != &array) {
274 #if defined(G_RANGE_CHECK)
275 if (index < 0 || index >=
size()) {
303 #if defined(G_RANGE_CHECK)
304 if (index < 0 || index >=
size()) {
334 for (
int i = 0; i < num; ++i) {
335 m_node.push_back(array[i]);
379 #if defined(G_RANGE_CHECK)
386 if (index < 0 || index >=
size()) {
416 #if defined(G_RANGE_CHECK)
417 if (index < 0 || index >=
size()) {
443 if (!
nodes.is_empty()) {
448 int num =
nodes.size();
454 for (
int i = 0; i < num; ++i) {
484 for (
int i = 0; i < vector.
size(); ++i) {
485 m_node.push_back(vector[i]);
537 const std::vector<double>& vector)
const
542 "in node array, yet at least 2 nodes are required "
543 "for interpolation. Please specify more nodes "
544 "before calling the method.";
549 if (
m_node.size() != vector.size()) {
550 std::string msg =
"Vector length "+
gammalib::str(vector.size())+
552 " of node array. Please specify a vector of "
594 std::string msg =
"Attempting to set interpolating value without "
595 "having any nodes. Interpolation can only be "
596 "done if nodes are available.";
663 int high =
nodes - 1;
664 while ((high - low) > 1) {
665 int mid = (low+high) / 2;
666 if (
m_node[mid] > value) {
712 GFits fits(filename);
781 int num = table.
nrows();
790 for (
int i = 0; i < num; ++i) {
821 for (
int i = 0; i < num; ++i) {
859 result.append(
"=== GNodeArray ===");
882 result.append(
" grad=");
889 for (
int i = 0; i <
size(); ++i) {
995 for (
int i = 0; i <
nodes-1; ++i) {
1005 for (
int i = 0; i <
nodes-1; ++i) {
1007 if (std::abs(eps) > 1.0e-6) {
Exception handler interface definition.
Filename class interface definition.
FITS binary table class definition.
FITS table column abstract base class definition.
FITS table double column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Node array class interface definition.
Vector class interface definition.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
const std::string & extname(void) const
Return extension name.
Abstract interface for FITS table column.
virtual double real(const int &row, const int &inx=0) const =0
FITS table double column.
Abstract interface for FITS table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
const int & nrows(void) const
Return number of rows in table.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
void save(const bool &clobber=false)
Saves FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
double m_wgt_grad_left
Weight gradient for left node.
void save(const GFilename &filename, const bool &clobber=false) const
Save node array into FITS file.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
GNodeArray & operator=(const GNodeArray &array)
Assignment operator.
GNodeArray(void)
Void constructor.
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
void copy_members(const GNodeArray &array)
Copy class members.
void free_members(void)
Delete class members.
bool m_has_last_value
Last value is valid.
double m_wgt_right
Weight for right node for linear interpolation.
double m_linear_slope
Slope for linear array.
double m_wgt_grad_right
Weight gradient for right node.
virtual ~GNodeArray(void)
Destructor.
bool m_need_setup
Call of setup is required.
std::vector< double > m_node
Array of nodes.
const int & inx_right(void) const
Returns right node index.
const int & inx_left(void) const
Returns left node index.
bool is_empty(void) const
Signals if there are no nodes in node array.
double & at(const int &index)
Node access operator.
void reserve(const int &num)
Reserves space for nodes in node array.
const double & wgt_right(void) const
Returns right node weight.
bool m_is_linear
Nodes form a linear array.
const double & wgt_left(void) const
Returns left node weight.
void remove(const int &index)
Remove one node into array.
int m_inx_right
Index of right node for linear interpolation.
void load(const GFilename &filename)
Load nodes from FITS file.
void init_members(void)
Initialise class members.
void insert(const int &index, const double &node)
Insert one node into array.
void clear(void)
Clear node array.
GNodeArray * clone(void) const
Clone node array.
void extend(const GNodeArray &nodes)
Append node array.
void setup(void) const
Compute distance array and linear slope/offset.
void nodes(const int &num, const double *array)
Set node array.
double m_wgt_left
Weight for left node for linear interpolation.
std::string print(const GChatter &chatter=NORMAL) const
Print nodes.
int m_inx_left
Index of left node for linear interpolation.
int size(void) const
Return number of nodes in node array.
double m_linear_offset
Offset for linear array.
std::vector< double > m_step
Distance to next node.
void write(GFits &fits, const std::string &extname="NODES") const
Write nodes into FITS object.
double m_last_value
Last requested value.
void append(const double &node)
Append one node to array.
void read(const GFitsTable &table)
Read nodes from FITS table.
const int & size(void) const
Return size of vector.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.