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()) {
448 int num = nodes.
size();
454 for (
int i = 0; i < num; ++i) {
455 m_node.push_back(nodes[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.";
656 else if (value >
m_node[nodes-1]) {
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) {
GNodeArray & operator=(const GNodeArray &array)
Assignment operator.
int size(void) const
Return number of nodes in node array.
FITS table double column class interface definition.
virtual ~GNodeArray(void)
Destructor.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GVector abs(const GVector &vector)
Computes absolute of vector elements.
void free_members(void)
Delete class members.
void load(const GFilename &filename)
Load nodes from FITS file.
bool m_has_last_value
Last value is valid.
double m_linear_offset
Offset for linear array.
const double & wgt_left(void) const
Returns left node weight.
void clear(void)
Clear node array.
void reserve(const int &num)
Reserves space for nodes in node array.
std::string extname(const std::string &defaultname="") const
Return extension name.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
FITS file class interface definition.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
double m_wgt_grad_left
Weight gradient for left node.
double m_linear_slope
Slope for linear array.
FITS table column abstract base class definition.
std::vector< double > m_node
Array of nodes.
bool is_empty(void) const
Signals if there are no nodes in node array.
void save(const GFilename &filename, const bool &clobber=false) const
Save node array into FITS file.
void write(GFits &fits, const std::string &extname="NODES") const
Write nodes into FITS object.
void init_members(void)
Initialise class members.
double m_wgt_right
Weight for right node for linear interpolation.
double m_last_value
Last requested value.
Node array class interface definition.
void remove(const int &index)
Remove one node into array.
double m_wgt_left
Weight for left node for linear interpolation.
void setup(void) const
Compute distance array and linear slope/offset.
const double & wgt_right(void) const
Returns right node weight.
void remove(const int &extno)
Remove HDU from FITS file.
Abstract interface for FITS table column.
double & at(const int &index)
Node access operator.
std::vector< double > m_step
Distance to next node.
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
void extend(const GNodeArray &nodes)
Append node array.
Abstract interface for FITS table.
const int & inx_left(void) const
Returns left node index.
bool m_need_setup
Call of setup is required.
Vector class interface definition.
GNodeArray(void)
Void constructor.
const std::string & extname(void) const
Return extension name.
int m_inx_left
Index of left node for linear interpolation.
int m_inx_right
Index of right node for linear interpolation.
void nodes(const int &num, const double *array)
Set node array.
const int & inx_right(void) const
Returns right node index.
const int & nrows(void) const
Return number of rows in table.
double m_wgt_grad_right
Weight gradient for right node.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string print(const GChatter &chatter=NORMAL) const
Print nodes.
virtual double real(const int &row, const int &inx=0) const =0
GNodeArray * clone(void) const
Clone node array.
void insert(const int &index, const double &node)
Insert one node into array.
Exception handler interface definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
FITS binary table class definition.
void read(const GFitsTable &table)
Read nodes from FITS table.
const int & size(void) const
Return size of vector.
bool m_is_linear
Nodes form a linear array.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void append(const double &node)
Append one node to array.
void close(void)
Close FITS file.
FITS table double column.
Filename class interface definition.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.
void copy_members(const GNodeArray &array)
Copy class members.