CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
npstat::LinInterpolatedTableND< Numeric, Axis > Class Template Reference

#include <LinInterpolatedTableND.h>

Public Types

typedef Axis axis_type
 
typedef Numeric value_type
 

Public Member Functions

void getCoords (unsigned long linearIndex, double *coords, unsigned coordsBufferSize) const
 
template<class Functor1 , class Functor2 >
std::unique_ptr
< LinInterpolatedTableND
invertRatioResponse (unsigned axisNumber, const Axis &replacementAxis, bool newAxisLeftLinear, bool newAxisRightLinear, Functor1 invg, Functor2 invh, const char *functionLabel=nullptr) const
 
template<class Functor1 , class Functor2 >
std::unique_ptr
< LinInterpolatedTableND
< Numeric, Axis > > 
invertRatioResponse (const unsigned axisNumber, const Axis &replacementAxis, const bool leftLinear, const bool rightLinear, Functor1 invg, Functor2 invh, const char *functionLabel) const
 
template<typename ConvertibleToUnsigned >
std::unique_ptr
< LinInterpolatedTableND
invertWRTAxis (ConvertibleToUnsigned axisNumber, const Axis &replacementAxis, bool newAxisLeftLinear, bool newAxisRightLinear, const char *functionLabel=nullptr) const
 
template<typename ConvertibleToUnsigned >
std::unique_ptr
< LinInterpolatedTableND
< Numeric, Axis > > 
invertWRTAxis (const ConvertibleToUnsigned axisNumC, const Axis &replacementAxis, const bool leftLinear, const bool rightLinear, const char *functionLabel) const
 
bool isUniformlyBinned () const
 
bool isWithinLimits (const double *point, unsigned dim) const
 
 LinInterpolatedTableND (const std::vector< Axis > &axes, const std::vector< std::pair< bool, bool > > &extrapolationType, const char *functionLabel=nullptr)
 
 LinInterpolatedTableND (const Axis &xAxis, bool leftX, bool rightX, const char *functionLabel=nullptr)
 
 LinInterpolatedTableND (const Axis &xAxis, bool leftX, bool rightX, const Axis &yAxis, bool leftY, bool rightY, const char *functionLabel=nullptr)
 
 LinInterpolatedTableND (const Axis &xAxis, bool leftX, bool rightX, const Axis &yAxis, bool leftY, bool rightY, const Axis &zAxis, bool leftZ, bool rightZ, const char *functionLabel=nullptr)
 
 LinInterpolatedTableND (const Axis &xAxis, bool leftX, bool rightX, const Axis &yAxis, bool leftY, bool rightY, const Axis &zAxis, bool leftZ, bool rightZ, const Axis &tAxis, bool leftT, bool rightT, const char *functionLabel=nullptr)
 
 LinInterpolatedTableND (const Axis &xAxis, bool leftX, bool rightX, const Axis &yAxis, bool leftY, bool rightY, const Axis &zAxis, bool leftZ, bool rightZ, const Axis &tAxis, bool leftT, bool rightT, const Axis &vAxis, bool leftV, bool rightV, const char *functionLabel=nullptr)
 
template<class Num2 >
 LinInterpolatedTableND (const LinInterpolatedTableND< Num2, Axis > &)
 
 LinInterpolatedTableND ()=delete
 
bool operator!= (const LinInterpolatedTableND &r) const
 
Numeric operator() (const double *point, unsigned dim) const
 
bool operator== (const LinInterpolatedTableND &) const
 
void setFunctionLabel (const char *newlabel)
 
Numeric operator() (const double &x0) const
 
Numeric operator() (const double &x0, const double &x1) const
 
Numeric operator() (const double &x0, const double &x1, const double &x2) const
 
Numeric operator() (const double &x0, const double &x1, const double &x2, const double &x3) const
 
Numeric operator() (const double &x0, const double &x1, const double &x2, const double &x3, const double &x4) const
 
unsigned dim () const
 
const std::vector< Axis > & axes () const
 
const Axis & axis (const unsigned i) const
 
unsigned long length () const
 
bool leftInterpolationLinear (unsigned i) const
 
bool rightInterpolationLinear (unsigned i) const
 
std::vector< std::pair< bool,
bool > > 
interpolationType () const
 
const std::string & functionLabel () const
 
const ArrayND< Numeric > & table () const
 
ArrayND< Numeric > & table ()
 
gs::ClassId classId () const
 
bool write (std::ostream &of) const
 

Static Public Member Functions

static const char * classname ()
 
static LinInterpolatedTableNDread (const gs::ClassId &id, std::istream &in)
 
static unsigned version ()
 

Private Member Functions

bool allConstInterpolated () const
 
 LinInterpolatedTableND (const ArrayND< Numeric > &data, const std::vector< Axis > &axes, const char *leftInterpolation, const char *rightInterpolation, const std::string &label)
 

Static Private Member Functions

template<class Functor1 >
static void invert1DResponse (const ArrayND< Numeric > &fromSlice, const Axis &fromAxis, const Axis &toAxis, bool newLeftLinear, bool newRightLinear, Functor1 invg, const double *rawx, const double *rawf, double *workspace, ArrayND< Numeric > *toSlice)
 
template<class Functor1 >
static double solveForRatioArg (double xmin, double xmax, double rmin, double rmax, double fval, Functor1 invg)
 

Private Attributes

bool allConstInterpolated_
 
std::vector< Axis > axes_
 
ArrayND< Numeric > data_
 
unsigned dim_
 
std::string functionLabel_
 
char leftInterpolationLinear_ [CHAR_BIT *sizeof(unsigned long)]
 
char rightInterpolationLinear_ [CHAR_BIT *sizeof(unsigned long)]
 

Friends

template<typename Num2 , typename Axis2 >
class LinInterpolatedTableND
 

Detailed Description

template<class Numeric, class Axis = UniformAxis>
class npstat::LinInterpolatedTableND< Numeric, Axis >

Template for multilinear interpolation/extrapolation of values provided on a rectangular coordinate grid. "Numeric" is the type stored in the table. "Axis" should be one of GridAxis, UniformAxis, or DualAxis classes or a user-provided class with a similar set of methods.

Definition at line 31 of file LinInterpolatedTableND.h.

Member Typedef Documentation

template<class Numeric, class Axis = UniformAxis>
typedef Axis npstat::LinInterpolatedTableND< Numeric, Axis >::axis_type

Definition at line 37 of file LinInterpolatedTableND.h.

template<class Numeric, class Axis = UniformAxis>
typedef Numeric npstat::LinInterpolatedTableND< Numeric, Axis >::value_type

Definition at line 36 of file LinInterpolatedTableND.h.

Constructor & Destructor Documentation

template<typename Numeric , class Axis >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const std::vector< Axis > &  axes,
const std::vector< std::pair< bool, bool > > &  extrapolationType,
const char *  functionLabel = nullptr 
)

Main constructor for arbitrary-dimensional interpolators.

"axes" are the axes of the rectangular coordinate grid.

In each pair provided by the "extrapolationType" argument, the first element of the pair specifies whether the extrapolation to negative infinity should be linear (if "true") or constant (if "false"). The second element of the pair specifies whether to extrapolate linearly to positive infinity.

"functionLabel" is an arbitrary string which can potentially be used by plotting programs and such.

Definition at line 529 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated(), npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::interpolationType(), npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

532  if (dim_ == 0 || dim_ >= CHAR_BIT * sizeof(unsigned long))
534  "In npstat::LinInterpolatedTableND constructor: requested "
535  "table dimensionality is not supported");
536  if (dim_ != interpolationType.size())
538  "In npstat::LinInterpolatedTableND constructor: "
539  "incompatible number of interpolation specifications");
540  for (unsigned i = 0; i < dim_; ++i) {
541  const std::pair<bool, bool>& pair(interpolationType[i]);
542  leftInterpolationLinear_[i] = pair.first;
543  rightInterpolationLinear_[i] = pair.second;
544  }
545 
547  }
char const * label
std::vector< std::pair< bool, bool > > interpolationType() const
const std::vector< Axis > & axes() const
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
ArrayShape makeTableShape(const std::vector< Axis > &axes)
template<typename Numeric , class Axis >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const Axis &  xAxis,
bool  leftX,
bool  rightX,
const char *  functionLabel = nullptr 
)

Convenience constructor for 1-d interpolators

Definition at line 703 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated(), npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_, npstat::LinInterpolatedTableND< Numeric, Axis >::axes_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

707  : data_(Private::makeTableShape(xAxis)), functionLabel_(label ? label : ""), dim_(1U) {
708  axes_.reserve(dim_);
709  axes_.push_back(xAxis);
710 
711  leftInterpolationLinear_[0] = leftX;
712  rightInterpolationLinear_[0] = rightX;
713 
715  }
char const * label
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
ArrayShape makeTableShape(const std::vector< Axis > &axes)
template<typename Numeric , class Axis >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const Axis &  xAxis,
bool  leftX,
bool  rightX,
const Axis &  yAxis,
bool  leftY,
bool  rightY,
const char *  functionLabel = nullptr 
)

Convenience constructor for 2-d interpolators

Definition at line 685 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated(), npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_, cms::cuda::assert(), npstat::LinInterpolatedTableND< Numeric, Axis >::axes_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

687  : data_(Private::makeTableShape(xAxis, yAxis)), functionLabel_(label ? label : ""), dim_(2U) {
688  axes_.reserve(dim_);
689  axes_.push_back(xAxis);
690  axes_.push_back(yAxis);
691 
692  unsigned i = 0;
693  leftInterpolationLinear_[i] = leftX;
694  rightInterpolationLinear_[i++] = rightX;
695  leftInterpolationLinear_[i] = leftY;
696  rightInterpolationLinear_[i++] = rightY;
697  assert(i == dim_);
698 
700  }
assert(be >=bs)
char const * label
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
ArrayShape makeTableShape(const std::vector< Axis > &axes)
template<typename Numeric , class Axis >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const Axis &  xAxis,
bool  leftX,
bool  rightX,
const Axis &  yAxis,
bool  leftY,
bool  rightY,
const Axis &  zAxis,
bool  leftZ,
bool  rightZ,
const char *  functionLabel = nullptr 
)

Convenience constructor for 3-d interpolators

Definition at line 656 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated(), npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_, cms::cuda::assert(), npstat::LinInterpolatedTableND< Numeric, Axis >::axes_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

666  : data_(Private::makeTableShape(xAxis, yAxis, zAxis)), functionLabel_(label ? label : ""), dim_(3U) {
667  axes_.reserve(dim_);
668  axes_.push_back(xAxis);
669  axes_.push_back(yAxis);
670  axes_.push_back(zAxis);
671 
672  unsigned i = 0;
673  leftInterpolationLinear_[i] = leftX;
674  rightInterpolationLinear_[i++] = rightX;
675  leftInterpolationLinear_[i] = leftY;
676  rightInterpolationLinear_[i++] = rightY;
677  leftInterpolationLinear_[i] = leftZ;
678  rightInterpolationLinear_[i++] = rightZ;
679  assert(i == dim_);
680 
682  }
assert(be >=bs)
char const * label
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
ArrayShape makeTableShape(const std::vector< Axis > &axes)
tuple zAxis
Definition: MetAnalyzer.py:57
template<typename Numeric , class Axis >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const Axis &  xAxis,
bool  leftX,
bool  rightX,
const Axis &  yAxis,
bool  leftY,
bool  rightY,
const Axis &  zAxis,
bool  leftZ,
bool  rightZ,
const Axis &  tAxis,
bool  leftT,
bool  rightT,
const char *  functionLabel = nullptr 
)

Convenience constructor for 4-d interpolators

Definition at line 621 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated(), npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_, cms::cuda::assert(), npstat::LinInterpolatedTableND< Numeric, Axis >::axes_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

634  : data_(Private::makeTableShape(xAxis, yAxis, zAxis, tAxis)), functionLabel_(label ? label : ""), dim_(4U) {
635  axes_.reserve(dim_);
636  axes_.push_back(xAxis);
637  axes_.push_back(yAxis);
638  axes_.push_back(zAxis);
639  axes_.push_back(tAxis);
640 
641  unsigned i = 0;
642  leftInterpolationLinear_[i] = leftX;
643  rightInterpolationLinear_[i++] = rightX;
644  leftInterpolationLinear_[i] = leftY;
645  rightInterpolationLinear_[i++] = rightY;
646  leftInterpolationLinear_[i] = leftZ;
647  rightInterpolationLinear_[i++] = rightZ;
648  leftInterpolationLinear_[i] = leftT;
649  rightInterpolationLinear_[i++] = rightT;
650  assert(i == dim_);
651 
653  }
assert(be >=bs)
char const * label
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
ArrayShape makeTableShape(const std::vector< Axis > &axes)
tuple zAxis
Definition: MetAnalyzer.py:57
template<typename Numeric , class Axis >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const Axis &  xAxis,
bool  leftX,
bool  rightX,
const Axis &  yAxis,
bool  leftY,
bool  rightY,
const Axis &  zAxis,
bool  leftZ,
bool  rightZ,
const Axis &  tAxis,
bool  leftT,
bool  rightT,
const Axis &  vAxis,
bool  leftV,
bool  rightV,
const char *  functionLabel = nullptr 
)

Convenience constructor for 5-d interpolators

Definition at line 578 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated(), npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_, cms::cuda::assert(), npstat::LinInterpolatedTableND< Numeric, Axis >::axes_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

594  : data_(Private::makeTableShape(xAxis, yAxis, zAxis, tAxis, vAxis)),
595  functionLabel_(label ? label : ""),
596  dim_(5U) {
597  axes_.reserve(dim_);
598  axes_.push_back(xAxis);
599  axes_.push_back(yAxis);
600  axes_.push_back(zAxis);
601  axes_.push_back(tAxis);
602  axes_.push_back(vAxis);
603 
604  unsigned i = 0;
605  leftInterpolationLinear_[i] = leftX;
606  rightInterpolationLinear_[i++] = rightX;
607  leftInterpolationLinear_[i] = leftY;
608  rightInterpolationLinear_[i++] = rightY;
609  leftInterpolationLinear_[i] = leftZ;
610  rightInterpolationLinear_[i++] = rightZ;
611  leftInterpolationLinear_[i] = leftT;
612  rightInterpolationLinear_[i++] = rightT;
613  leftInterpolationLinear_[i] = leftV;
614  rightInterpolationLinear_[i++] = rightV;
615  assert(i == dim_);
616 
618  }
assert(be >=bs)
char const * label
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
ArrayShape makeTableShape(const std::vector< Axis > &axes)
tuple zAxis
Definition: MetAnalyzer.py:57
template<typename Numeric , class Axis >
template<class Num2 >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const LinInterpolatedTableND< Num2, Axis > &  r)

Converting copy constructor from interpolator with another storage type

Definition at line 551 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

552  : data_(r.data_),
553  axes_(r.axes_),
554  functionLabel_(r.functionLabel_),
555  dim_(r.dim_),
556  allConstInterpolated_(r.allConstInterpolated_) {
557  for (unsigned i = 0; i < dim_; ++i) {
558  leftInterpolationLinear_[i] = r.leftInterpolationLinear_[i];
559  rightInterpolationLinear_[i] = r.rightInterpolationLinear_[i];
560  }
561  }
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
template<class Numeric, class Axis = UniformAxis>
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( )
delete

Default constructor not implemented

template<typename Numeric , class Axis >
npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND ( const ArrayND< Numeric > &  data,
const std::vector< Axis > &  axes,
const char *  leftInterpolation,
const char *  rightInterpolation,
const std::string &  label 
)
private

Definition at line 564 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated(), npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

569  : data_(data), axes_(axes), functionLabel_(label), dim_(data.rank()) {
570  for (unsigned i = 0; i < dim_; ++i) {
571  leftInterpolationLinear_[i] = leftInterpolation[i];
572  rightInterpolationLinear_[i] = rightInterpolation[i];
573  }
575  }
unsigned rank() const
Definition: ArrayND.h:242
char const * label
const std::vector< Axis > & axes() const
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]

Member Function Documentation

template<class Numeric , class Axis >
bool npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated ( ) const
private

Definition at line 429 of file LinInterpolatedTableND.h.

References mps_fire::i.

Referenced by npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND().

429  {
430  for (unsigned i = 0; i < dim_; ++i)
432  return false;
433  return true;
434  }
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
template<class Numeric, class Axis = UniformAxis>
const std::vector<Axis>& npstat::LinInterpolatedTableND< Numeric, Axis >::axes ( ) const
inline
template<class Numeric, class Axis = UniformAxis>
const Axis& npstat::LinInterpolatedTableND< Numeric, Axis >::axis ( const unsigned  i) const
inline

Definition at line 143 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::axes_.

143 { return axes_.at(i); }
template<class Numeric, class Axis = UniformAxis>
gs::ClassId npstat::LinInterpolatedTableND< Numeric, Axis >::classId ( ) const
inline

Definition at line 227 of file LinInterpolatedTableND.h.

227 { return gs::ClassId(*this); }
template<typename Numeric , class Axis >
const char * npstat::LinInterpolatedTableND< Numeric, Axis >::classname ( )
static

Definition at line 450 of file LinInterpolatedTableND.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

450  {
451  static const std::string myClass(gs::template_class_name<Numeric, Axis>("npstat::LinInterpolatedTableND"));
452  return myClass.c_str();
453  }
template<class Numeric, class Axis = UniformAxis>
unsigned npstat::LinInterpolatedTableND< Numeric, Axis >::dim ( ) const
inline
template<class Numeric, class Axis = UniformAxis>
const std::string& npstat::LinInterpolatedTableND< Numeric, Axis >::functionLabel ( ) const
inline
template<typename Numeric , class Axis >
void npstat::LinInterpolatedTableND< Numeric, Axis >::getCoords ( unsigned long  linearIndex,
double *  coords,
unsigned  coordsBufferSize 
) const

Convenience function for getting coordinates of the grid points

Definition at line 869 of file LinInterpolatedTableND.h.

References cms::cuda::assert(), and mps_fire::i.

871  {
872  if (coordsBufferSize < dim_)
874  "In LinInterpolatedTableND::getCoords: "
875  "insufficient buffer size");
876  assert(coords);
877  unsigned index[CHAR_BIT * sizeof(unsigned long)];
878  data_.convertLinearIndex(linearIndex, index, dim_);
879  for (unsigned i = 0; i < dim_; ++i)
880  coords[i] = axes_[i].coordinate(index[i]);
881  }
void convertLinearIndex(unsigned long l, unsigned *index, unsigned indexLen) const
Definition: ArrayND.h:3048
assert(be >=bs)
template<typename Numeric , class Axis >
std::vector< std::pair< bool, bool > > npstat::LinInterpolatedTableND< Numeric, Axis >::interpolationType ( ) const

Definition at line 520 of file LinInterpolatedTableND.h.

References mps_fire::i.

Referenced by npstat::LinInterpolatedTableND< Numeric, Axis >::LinInterpolatedTableND().

520  {
521  std::vector<std::pair<bool, bool> > vec;
522  vec.reserve(dim_);
523  for (unsigned i = 0; i < dim_; ++i)
524  vec.push_back(std::pair<bool, bool>(leftInterpolationLinear_[i], rightInterpolationLinear_[i]));
525  return vec;
526  }
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
template<typename Numeric , class Axis >
template<class Functor1 >
void npstat::LinInterpolatedTableND< Numeric, Axis >::invert1DResponse ( const ArrayND< Numeric > &  fromSlice,
const Axis &  fromAxis,
const Axis &  toAxis,
bool  newLeftLinear,
bool  newRightLinear,
Functor1  invg,
const double *  rawx,
const double *  rawf,
double *  workspace,
ArrayND< Numeric > *  toSlice 
)
staticprivate

Definition at line 1084 of file LinInterpolatedTableND.h.

References cms::cuda::assert(), npstat::ArrayND< Numeric, StackLen, StackDim >::data(), mps_fire::i, npstat::ArrayND< Numeric, StackLen, StackDim >::length(), cuda_std::lower_bound(), npstat::ArrayND< Numeric, StackLen, StackDim >::rank(), x, and SiPixelPI::zero.

1093  {
1094  assert(toSlice);
1095  assert(fromSlice.rank() == 1U);
1096  assert(toSlice->rank() == 1U);
1097 
1098  const Numeric zero = Numeric();
1099  const Numeric* fromData = fromSlice.data();
1100  const unsigned fromLen = fromSlice.length();
1101  assert(fromLen > 1U);
1102  assert(fromLen == fromAxis.nCoords());
1103  Numeric* toD = const_cast<Numeric*>(toSlice->data());
1104  const unsigned nAxisPoints = toAxis.nCoords();
1105  assert(toSlice->length() == nAxisPoints);
1106 
1107  for (unsigned i = 0; i < fromLen; ++i) {
1108  if (fromData[i] <= zero)
1110  "In LinInterpolatedTableND::invert1DResponse: "
1111  "non-positive response found. This ratio "
1112  "response table is not invertible.");
1113  workspace[i] = rawx[i] * fromData[i];
1114  }
1115 
1116  const double yfirst = workspace[0];
1117  const double ylast = workspace[fromLen - 1U];
1118 
1119  bool adjustZero = false;
1120  unsigned nBelow = 0;
1121  for (unsigned ipt = 0; ipt < nAxisPoints; ++ipt) {
1122  const double y = rawf[ipt];
1123  unsigned i0 = 0;
1124  bool solve = false;
1125  if (y == 0.0) {
1126  assert(ipt == 0U);
1127  if (newLeftLinear)
1128  adjustZero = true;
1129  } else if (y <= yfirst) {
1130  ++nBelow;
1131  solve = newLeftLinear;
1132  } else if (y >= ylast) {
1133  solve = newRightLinear;
1134  i0 = solve ? fromLen - 2 : fromLen - 1;
1135  } else {
1136  solve = true;
1137  i0 = static_cast<unsigned>(std::lower_bound(workspace, workspace + fromLen, y) - workspace) - 1U;
1138  }
1139  if (solve) {
1140  const double x = solveForRatioArg(
1141  fromAxis.coordinate(i0), fromAxis.coordinate(i0 + 1), fromData[i0], fromData[i0 + 1], y, invg);
1142  toD[ipt] = invg(x) / y;
1143  } else
1144  toD[ipt] = 1.0 / fromData[i0];
1145  }
1146  if (adjustZero && nBelow)
1147  toD[0] = toD[1];
1148  }
unsigned rank() const
Definition: ArrayND.h:242
unsigned long length() const
Definition: ArrayND.h:233
assert(be >=bs)
static double solveForRatioArg(double xmin, double xmax, double rmin, double rmax, double fval, Functor1 invg)
const Numeric * data() const
Definition: ArrayND.h:236
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
template<class Numeric, class Axis = UniformAxis>
template<class Functor1 , class Functor2 >
std::unique_ptr<LinInterpolatedTableND> npstat::LinInterpolatedTableND< Numeric, Axis >::invertRatioResponse ( unsigned  axisNumber,
const Axis &  replacementAxis,
bool  newAxisLeftLinear,
bool  newAxisRightLinear,
Functor1  invg,
Functor2  invh,
const char *  functionLabel = nullptr 
) const

This method inverts the ratio response. That is, we assume that the table encodes r(x) for some function f(x) = x*r(x). We also assume that the original axis does not represent x directly – instead, axis coordinates are given by g(x) (in practice, g is often the natural log). We will also assume that the new axis is not going to represent f(x) directly – it will be h(f(x)) instead. The functors "invg" and "invh" below must do the inverse: taking the axes coordinates to the actual values of x and f(x). Both "invg" and "invh" must be monotonously increasing functions. The code assumes that x*r(x) -> 0 when x->0 (that is, r(x) is bounded at 0) and it also assumes (but does not check explicitly) that x*r(x) is monotonously increasing with x.

The returned interpolation table encodes the values of x/f(x). Of course, they are just 1/r(x), but the trick is to be able to look them up quickly as a function of h(f(x)). Naturally, this whole operation is meaningful only in case "Numeric" type is either float or double.

template<class Numeric, class Axis = UniformAxis>
template<class Functor1 , class Functor2 >
std::unique_ptr<LinInterpolatedTableND<Numeric, Axis> > npstat::LinInterpolatedTableND< Numeric, Axis >::invertRatioResponse ( const unsigned  axisNumber,
const Axis &  replacementAxis,
const bool  leftLinear,
const bool  rightLinear,
Functor1  invg,
Functor2  invh,
const char *  functionLabel 
) const

Definition at line 770 of file LinInterpolatedTableND.h.

References submitPVResolutionJobs::count, validate-o2o-wbm::f, mps_fire::i, npstat::ArrayNDScanner::isValid(), and x.

777  {
778  if (axisNumber >= dim_)
780  "In npstat::LinInterpolatedTableND::invertRatioResponse: "
781  "axis number is out of range");
782 
783  // Generate the new set of axes
784  std::vector<Axis> newAxes(axes_);
785  newAxes[axisNumber] = replacementAxis;
786 
787  std::vector<std::pair<bool, bool> > iType(interpolationType());
788  iType[axisNumber] = std::pair<bool, bool>(leftLinear, rightLinear);
789 
790  // Transform the original axis to the raw x values
791  const Axis& oldAxis(axes_[axisNumber]);
792  std::vector<double> rawx;
793  const unsigned nCoords = oldAxis.nCoords();
794  rawx.reserve(nCoords);
795  for (unsigned i = 0; i < nCoords; ++i) {
796  const double x = invg(oldAxis.coordinate(i));
797  if (x < 0.0)
799  "In npstat::LinInterpolatedTableND::invertRatioResponse: "
800  "invalid original axis definition (negative transformed "
801  "coordinate)");
802  rawx.push_back(x);
803  }
804 
805  // Transform the new axis to the raw f(x) values
806  std::vector<double> rawf;
807  const unsigned nFuncs = replacementAxis.nCoords();
808  rawf.reserve(nFuncs);
809  for (unsigned i = 0; i < nFuncs; ++i) {
810  const double f = invh(replacementAxis.coordinate(i));
811  if (f < 0.0)
813  "In npstat::LinInterpolatedTableND::invertRatioResponse: "
814  "invalid new axis definition (negative transformed "
815  "coordinate)");
816  rawf.push_back(f);
817  }
818 
819  // Workspace needed for the inversion code
820  std::vector<double> workspace(nCoords);
821 
822  // Create the new table
823  CPP11_auto_ptr<LinInterpolatedTableND> pTable(new LinInterpolatedTableND(newAxes, iType, functionLabel));
824 
825  if (dim_ > 1U) {
826  // Prepare array slices
827  unsigned sliceIndex[CHAR_BIT * sizeof(unsigned long)];
828  unsigned fixedIndices[CHAR_BIT * sizeof(unsigned long)];
829  unsigned count = 0;
830  for (unsigned i = 0; i < dim_; ++i)
831  if (i != axisNumber) {
832  sliceIndex[count] = data_.span(i);
833  fixedIndices[count++] = i;
834  }
835  ArrayND<Numeric> parentSlice(data_, fixedIndices, count);
836  ArrayND<Numeric> dauSlice(pTable->data_, fixedIndices, count);
837 
838  // Cycle over the slices
839  for (ArrayNDScanner scan(sliceIndex, count); scan.isValid(); ++scan) {
840  scan.getIndex(sliceIndex, count);
841  data_.exportSlice(&parentSlice, fixedIndices, sliceIndex, count);
842  invert1DResponse(parentSlice,
843  oldAxis,
844  replacementAxis,
845  leftLinear,
846  rightLinear,
847  invg,
848  &rawx[0],
849  &rawf[0],
850  &workspace[0],
851  &dauSlice);
852  pTable->data_.importSlice(dauSlice, fixedIndices, sliceIndex, count);
853  }
854  } else
856  oldAxis,
857  replacementAxis,
858  leftLinear,
859  rightLinear,
860  invg,
861  &rawx[0],
862  &rawf[0],
863  &workspace[0],
864  &pTable->data_);
865  return pTable;
866  }
static void invert1DResponse(const ArrayND< Numeric > &fromSlice, const Axis &fromAxis, const Axis &toAxis, bool newLeftLinear, bool newRightLinear, Functor1 invg, const double *rawx, const double *rawf, double *workspace, ArrayND< Numeric > *toSlice)
unsigned span(unsigned dim) const
Definition: ArrayND.h:5088
std::vector< std::pair< bool, bool > > interpolationType() const
const std::string & functionLabel() const
Numeric * data_
Definition: ArrayND.h:1049
void exportSlice(ArrayND< Num2, Len2, Dim2 > *slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
Definition: ArrayND.h:696
template<class Numeric, class Axis = UniformAxis>
template<typename ConvertibleToUnsigned >
std::unique_ptr<LinInterpolatedTableND> npstat::LinInterpolatedTableND< Numeric, Axis >::invertWRTAxis ( ConvertibleToUnsigned  axisNumber,
const Axis &  replacementAxis,
bool  newAxisLeftLinear,
bool  newAxisRightLinear,
const char *  functionLabel = nullptr 
) const

Invert the function w.r.t. the variable represented by one of the axes. The function values must change monotonously along the chosen axis. Note that this operation is meaningful only in case "Numeric" type is either float or double.

template<class Numeric, class Axis = UniformAxis>
template<typename ConvertibleToUnsigned >
std::unique_ptr<LinInterpolatedTableND<Numeric, Axis> > npstat::LinInterpolatedTableND< Numeric, Axis >::invertWRTAxis ( const ConvertibleToUnsigned  axisNumC,
const Axis &  replacementAxis,
const bool  leftLinear,
const bool  rightLinear,
const char *  functionLabel 
) const

Definition at line 719 of file LinInterpolatedTableND.h.

References submitPVResolutionJobs::count, mps_fire::i, npstat::ArrayNDScanner::isValid(), and npstat::Private::lind_invert1DSlice().

724  {
725  const unsigned axisNumber = static_cast<unsigned>(axisNumC);
726 
727  if (axisNumber >= dim_)
729  "In npstat::LinInterpolatedTableND::invertAxis: "
730  "axis number is out of range");
731 
732  // Generate the new set of axes
733  std::vector<Axis> newAxes(axes_);
734  newAxes[axisNumber] = replacementAxis;
735 
736  std::vector<std::pair<bool, bool> > iType(interpolationType());
737  iType[axisNumber] = std::pair<bool, bool>(leftLinear, rightLinear);
738 
739  // Create the new table
740  CPP11_auto_ptr<LinInterpolatedTableND> pTable(new LinInterpolatedTableND(newAxes, iType, functionLabel));
741 
742  if (dim_ > 1U) {
743  // Prepare array slices
744  unsigned sliceIndex[CHAR_BIT * sizeof(unsigned long)];
745  unsigned fixedIndices[CHAR_BIT * sizeof(unsigned long)];
746  unsigned count = 0;
747  for (unsigned i = 0; i < dim_; ++i)
748  if (i != axisNumber) {
749  sliceIndex[count] = data_.span(i);
750  fixedIndices[count++] = i;
751  }
752  ArrayND<Numeric> parentSlice(data_, fixedIndices, count);
753  ArrayND<Numeric> dauSlice(pTable->data_, fixedIndices, count);
754 
755  // Cycle over the slices
756  for (ArrayNDScanner scan(sliceIndex, count); scan.isValid(); ++scan) {
757  scan.getIndex(sliceIndex, count);
758  data_.exportSlice(&parentSlice, fixedIndices, sliceIndex, count);
760  parentSlice, axes_[axisNumber], replacementAxis, leftLinear, rightLinear, &dauSlice);
761  pTable->data_.importSlice(dauSlice, fixedIndices, sliceIndex, count);
762  }
763  } else
764  Private::lind_invert1DSlice(data_, axes_[0], replacementAxis, leftLinear, rightLinear, &pTable->data_);
765  return pTable;
766  }
unsigned span(unsigned dim) const
Definition: ArrayND.h:5088
std::vector< std::pair< bool, bool > > interpolationType() const
void lind_invert1DSlice(const ArrayND< Numeric > &fromSlice, const Axis &fromAxis, const Axis &toAxis, const bool leftLinear, const bool rightLinear, ArrayND< Numeric > *toSlice)
const std::string & functionLabel() const
void exportSlice(ArrayND< Num2, Len2, Dim2 > *slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
Definition: ArrayND.h:696
template<typename Numeric , class Axis >
bool npstat::LinInterpolatedTableND< Numeric, Axis >::isUniformlyBinned ( ) const

This method returns "true" if the method isUniform() of each interpolator axis returns "true"

Definition at line 512 of file LinInterpolatedTableND.h.

References mps_fire::i.

512  {
513  for (unsigned i = 0; i < dim_; ++i)
514  if (!axes_[i].isUniform())
515  return false;
516  return true;
517  }
template<typename Numeric , class Axis >
bool npstat::LinInterpolatedTableND< Numeric, Axis >::isWithinLimits ( const double *  point,
unsigned  dim 
) const

This method will return "true" if the point is inside the grid limits or on the boundary

Definition at line 884 of file LinInterpolatedTableND.h.

References cms::cuda::assert(), mps_fire::i, SiStripPI::max, and SiStripPI::min.

884  {
885  if (len != dim_)
887  "In npstat::LinInterpolatedTableND::isWithinLimits: "
888  "incompatible point dimensionality");
889  assert(point);
890 
891  for (unsigned i = 0; i < dim_; ++i)
892  if (point[i] < axes_[i].min() || point[i] > axes_[i].max())
893  return false;
894  return true;
895  }
assert(be >=bs)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
template<typename Numeric , class Axis >
bool npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear ( unsigned  i) const

Definition at line 494 of file LinInterpolatedTableND.h.

References mps_fire::i.

494  {
495  if (i >= dim_)
497  "In npstat::LinInterpolatedTableND::leftInterpolationLinear: "
498  "index out of range");
499  return leftInterpolationLinear_[i];
500  }
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
template<class Numeric, class Axis = UniformAxis>
unsigned long npstat::LinInterpolatedTableND< Numeric, Axis >::length ( ) const
inline
template<class Numeric, class Axis = UniformAxis>
bool npstat::LinInterpolatedTableND< Numeric, Axis >::operator!= ( const LinInterpolatedTableND< Numeric, Axis > &  r) const
inline

Logical negation of operator==

Definition at line 223 of file LinInterpolatedTableND.h.

References alignCSCRings::r.

223 { return !(*this == r); }
template<typename Numeric , class Axis >
Numeric npstat::LinInterpolatedTableND< Numeric, Axis >::operator() ( const double *  point,
unsigned  dim 
) const

Basic interpolation result. Argument point dimensionality must be compatible with the interpolator dimensionality.

Definition at line 898 of file LinInterpolatedTableND.h.

References cms::cuda::assert(), visDQMUpload::buf, dat, mps_fire::i, linear(), SiStripPI::max, SiStripPI::min, w(), and histoStyle::weight.

898  {
899  typedef typename ProperDblFromCmpl<Numeric>::type proper_double;
900 
901  if (len != dim_)
903  "In npstat::LinInterpolatedTableND::operator(): "
904  "incompatible point dimensionality");
905  assert(point);
906 
907  bool interpolateArray = true;
909  for (unsigned i = 0; i < dim_; ++i)
910  if ((leftInterpolationLinear_[i] && point[i] < axes_[i].min()) ||
911  (rightInterpolationLinear_[i] && point[i] > axes_[i].max())) {
912  interpolateArray = false;
913  break;
914  }
915 
916  if (interpolateArray) {
917  // Translate coordinates into the array system and
918  // simply use the ArrayND interpolation facilities
919  double buf[CHAR_BIT * sizeof(unsigned long)];
920  for (unsigned i = 0; i < dim_; ++i) {
921  const std::pair<unsigned, double>& pair = axes_[i].getInterval(point[i]);
922  buf[i] = pair.first + 1U - pair.second;
923  }
924  return data_.interpolate1(buf, dim_);
925  } else {
926  unsigned ix[CHAR_BIT * sizeof(unsigned long)];
927  double weight[CHAR_BIT * sizeof(unsigned long)];
928  for (unsigned i = 0; i < dim_; ++i) {
929  const bool linear = (leftInterpolationLinear_[i] && point[i] < axes_[i].min()) ||
931  const std::pair<unsigned, double>& pair =
932  linear ? axes_[i].linearInterval(point[i]) : axes_[i].getInterval(point[i]);
933  ix[i] = pair.first;
934  weight[i] = pair.second;
935  }
936 
937  Numeric sum = Numeric();
938  const unsigned long maxcycle = 1UL << dim_;
939  const unsigned long* strides = data_.strides();
940  const Numeric* dat = data_.data();
941  for (unsigned long icycle = 0UL; icycle < maxcycle; ++icycle) {
942  double w = 1.0;
943  unsigned long icell = 0UL;
944  for (unsigned i = 0; i < dim_; ++i) {
945  if (icycle & (1UL << i)) {
946  w *= (1.0 - weight[i]);
947  icell += strides[i] * (ix[i] + 1U);
948  } else {
949  w *= weight[i];
950  icell += strides[i] * ix[i];
951  }
952  }
953  sum += dat[icell] * static_cast<proper_double>(w);
954  }
955  return sum;
956  }
957  }
assert(be >=bs)
Numeric interpolate1(const double *x, unsigned xDim) const
Definition: ArrayND.h:4211
const Numeric * data() const
Definition: ArrayND.h:236
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
static std::vector< std::string > checklist dat
const unsigned long * strides() const
Definition: ArrayND.h:263
T w() const
float linear(float x)
int weight
Definition: histoStyle.py:51
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
template<typename Numeric , class Axis >
Numeric npstat::LinInterpolatedTableND< Numeric, Axis >::operator() ( const double &  x0) const

Convenience function for low-dimensional interpolators

Definition at line 960 of file LinInterpolatedTableND.h.

References createJobs::tmp.

960  {
961  const unsigned nArgs = 1U;
962  if (dim_ != nArgs)
964  "In npstat::LinInterpolatedTableND::operator(): number of "
965  "arguments, 1, is incompatible with the interpolator dimensionality");
966  double tmp[nArgs];
967  tmp[0] = x0;
968  return operator()(tmp, nArgs);
969  }
Numeric operator()(const double *point, unsigned dim) const
tmp
align.sh
Definition: createJobs.py:716
template<typename Numeric , class Axis >
Numeric npstat::LinInterpolatedTableND< Numeric, Axis >::operator() ( const double &  x0,
const double &  x1 
) const

Definition at line 972 of file LinInterpolatedTableND.h.

References createJobs::tmp.

972  {
973  const unsigned nArgs = 2U;
974  if (dim_ != nArgs)
976  "In npstat::LinInterpolatedTableND::operator(): number of "
977  "arguments, 2, is incompatible with the interpolator dimensionality");
978  double tmp[nArgs];
979  tmp[0] = x0;
980  tmp[1] = x1;
981  return operator()(tmp, nArgs);
982  }
Numeric operator()(const double *point, unsigned dim) const
tmp
align.sh
Definition: createJobs.py:716
template<typename Numeric , class Axis >
Numeric npstat::LinInterpolatedTableND< Numeric, Axis >::operator() ( const double &  x0,
const double &  x1,
const double &  x2 
) const

Definition at line 985 of file LinInterpolatedTableND.h.

References createJobs::tmp.

987  {
988  const unsigned nArgs = 3U;
989  if (dim_ != nArgs)
991  "In npstat::LinInterpolatedTableND::operator(): number of "
992  "arguments, 3, is incompatible with the interpolator dimensionality");
993  double tmp[nArgs];
994  tmp[0] = x0;
995  tmp[1] = x1;
996  tmp[2] = x2;
997  return operator()(tmp, nArgs);
998  }
Numeric operator()(const double *point, unsigned dim) const
tmp
align.sh
Definition: createJobs.py:716
template<typename Numeric , class Axis >
Numeric npstat::LinInterpolatedTableND< Numeric, Axis >::operator() ( const double &  x0,
const double &  x1,
const double &  x2,
const double &  x3 
) const

Definition at line 1001 of file LinInterpolatedTableND.h.

References createJobs::tmp.

1004  {
1005  const unsigned nArgs = 4U;
1006  if (dim_ != nArgs)
1008  "In npstat::LinInterpolatedTableND::operator(): number of "
1009  "arguments, 4, is incompatible with the interpolator dimensionality");
1010  double tmp[nArgs];
1011  tmp[0] = x0;
1012  tmp[1] = x1;
1013  tmp[2] = x2;
1014  tmp[3] = x3;
1015  return operator()(tmp, nArgs);
1016  }
Numeric operator()(const double *point, unsigned dim) const
tmp
align.sh
Definition: createJobs.py:716
template<typename Numeric , class Axis >
Numeric npstat::LinInterpolatedTableND< Numeric, Axis >::operator() ( const double &  x0,
const double &  x1,
const double &  x2,
const double &  x3,
const double &  x4 
) const

Definition at line 1019 of file LinInterpolatedTableND.h.

References createJobs::tmp.

1020  {
1021  const unsigned nArgs = 5U;
1022  if (dim_ != nArgs)
1024  "In npstat::LinInterpolatedTableND::operator(): number of "
1025  "arguments, 5, is incompatible with the interpolator dimensionality");
1026  double tmp[nArgs];
1027  tmp[0] = x0;
1028  tmp[1] = x1;
1029  tmp[2] = x2;
1030  tmp[3] = x3;
1031  tmp[4] = x4;
1032  return operator()(tmp, nArgs);
1033  }
Numeric operator()(const double *point, unsigned dim) const
tmp
align.sh
Definition: createJobs.py:716
template<class Numeric , class Axis >
bool npstat::LinInterpolatedTableND< Numeric, Axis >::operator== ( const LinInterpolatedTableND< Numeric, Axis > &  r) const

Comparison for equality

Definition at line 437 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::axes_, npstat::LinInterpolatedTableND< Numeric, Axis >::data_, npstat::LinInterpolatedTableND< Numeric, Axis >::dim_, npstat::LinInterpolatedTableND< Numeric, Axis >::functionLabel_, mps_fire::i, npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_, and npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_.

437  {
438  if (dim_ != r.dim_)
439  return false;
440  for (unsigned i = 0; i < dim_; ++i) {
441  if (leftInterpolationLinear_[i] != r.leftInterpolationLinear_[i])
442  return false;
443  if (rightInterpolationLinear_[i] != r.rightInterpolationLinear_[i])
444  return false;
445  }
446  return data_ == r.data_ && axes_ == r.axes_ && functionLabel_ == r.functionLabel_;
447  }
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
template<typename Numeric , class Axis >
LinInterpolatedTableND< Numeric, Axis > * npstat::LinInterpolatedTableND< Numeric, Axis >::read ( const gs::ClassId &  id,
std::istream &  in 
)
static

Definition at line 467 of file LinInterpolatedTableND.h.

References data, label, npstat::ArrayND< Numeric, StackLen, StackDim >::rank(), npstat::ArrayND< Numeric, StackLen, StackDim >::restore(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

468  {
469  static const gs::ClassId current(gs::ClassId::makeId<LinInterpolatedTableND<Numeric, Axis> >());
470  current.ensureSameId(id);
471 
472  gs::ClassId ida(in, 1);
473  ArrayND<Numeric> data;
474  ArrayND<Numeric>::restore(ida, in, &data);
475  std::vector<Axis> axes;
476  gs::read_heap_obj_vector_as_placed(in, &axes);
477  const unsigned dim = axes.size();
478  if (dim > CHAR_BIT * sizeof(unsigned long) || data.rank() != dim)
479  throw gs::IOInvalidData(
480  "In npstat::LinInterpolatedTableND::read: "
481  "read back invalid dimensionality");
482  char leftInterpolation[CHAR_BIT * sizeof(unsigned long)];
483  gs::read_pod_array(in, leftInterpolation, dim);
484  char rightInterpolation[CHAR_BIT * sizeof(unsigned long)];
485  gs::read_pod_array(in, rightInterpolation, dim);
487  gs::read_pod(in, &label);
488  if (in.fail())
489  throw gs::IOReadFailure("In npstat::LinInterpolatedTableND::read: input stream failure");
490  return new LinInterpolatedTableND(data, axes, leftInterpolation, rightInterpolation, label);
491  }
char const * label
const std::vector< Axis > & axes() const
static void restore(const gs::ClassId &id, std::istream &in, ArrayND *array)
Definition: ArrayND.h:5386
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
template<typename Numeric , class Axis >
bool npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear ( unsigned  i) const

Definition at line 503 of file LinInterpolatedTableND.h.

References mps_fire::i.

503  {
504  if (i >= dim_)
506  "In npstat::LinInterpolatedTableND::rightInterpolationLinear: "
507  "index out of range");
509  }
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
template<class Numeric, class Axis = UniformAxis>
void npstat::LinInterpolatedTableND< Numeric, Axis >::setFunctionLabel ( const char *  newlabel)
inline

Modifier for the function label

Definition at line 173 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::functionLabel_.

173 { functionLabel_ = newlabel ? newlabel : ""; }
template<typename Numeric , class Axis >
template<class Functor1 >
double npstat::LinInterpolatedTableND< Numeric, Axis >::solveForRatioArg ( double  xmin,
double  xmax,
double  rmin,
double  rmax,
double  fval,
Functor1  invg 
)
staticprivate

Definition at line 1037 of file LinInterpolatedTableND.h.

References funct::abs(), cms::cuda::assert(), npstat::Private::lind_interpolateSimple(), hlt_dqm_clientPB-live_cfg::xmax, and hlt_dqm_clientPB-live_cfg::xmin.

1038  {
1039  // Find two values of x so that f(x0) <= fval <= f(x1)
1040  double x0 = xmin;
1041  double x1 = xmax;
1042  double fmin = invg(xmin) * rmin;
1043  double fmax = invg(xmax) * rmax;
1044  const double step = xmax - xmin;
1045  assert(fmin < fmax);
1046  assert(step > 0.0);
1047 
1048  unsigned stepcount = 0;
1049  const unsigned maxSteps = 1000U;
1050  for (double stepfactor = 1.0; (fval < fmin || fval > fmax) && stepcount < maxSteps; stepfactor *= 2.0, ++stepcount)
1051  if (fval < fmin) {
1052  x1 = x0;
1053  fmax = fmin;
1054  x0 -= stepfactor * step;
1055  fmin = invg(x0) * Private::lind_interpolateSimple(xmin, xmax, rmin, rmax, x0);
1056  } else {
1057  x0 = x1;
1058  fmin = fmax;
1059  x1 += stepfactor * step;
1060  fmax = invg(x1) * Private::lind_interpolateSimple(xmin, xmax, rmin, rmax, x1);
1061  }
1062  if (stepcount == maxSteps)
1064  "In LinInterpolatedTableND::solveForRatioArg: "
1065  "faled to bracket the root");
1066 
1067  assert(x1 >= x0);
1068  while ((x1 - x0) / (std::abs(x1) + std::abs(x0) + DBL_EPSILON) > 4.0 * DBL_EPSILON) {
1069  const double xhalf = (x1 + x0) / 2.0;
1070  const double fhalf = invg(xhalf) * Private::lind_interpolateSimple(xmin, xmax, rmin, rmax, xhalf);
1071  if (fval < fhalf) {
1072  x1 = xhalf;
1073  fmax = fhalf;
1074  } else {
1075  x0 = xhalf;
1076  fmin = fhalf;
1077  }
1078  }
1079  return (x1 + x0) / 2.0;
1080  }
assert(be >=bs)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double lind_interpolateSimple(const double x0, const double x1, const double y0, const double y1, const double x)
step
Definition: StallMonitor.cc:98
template<class Numeric, class Axis = UniformAxis>
const ArrayND<Numeric>& npstat::LinInterpolatedTableND< Numeric, Axis >::table ( ) const
inline

Access the interpolator table data

Definition at line 153 of file LinInterpolatedTableND.h.

References npstat::LinInterpolatedTableND< Numeric, Axis >::data_.

Referenced by npstat::StorableInterpolationFunctor< Numeric, Axis, Converter >::table().

153 { return data_; }
template<class Numeric, class Axis = UniformAxis>
ArrayND<Numeric>& npstat::LinInterpolatedTableND< Numeric, Axis >::table ( )
inline
template<class Numeric, class Axis = UniformAxis>
static unsigned npstat::LinInterpolatedTableND< Numeric, Axis >::version ( )
inlinestatic

Definition at line 232 of file LinInterpolatedTableND.h.

Referenced by validation.Sample::datasetpattern(), and validation.Sample::filename().

232 { return 1; }
template<typename Numeric , class Axis >
bool npstat::LinInterpolatedTableND< Numeric, Axis >::write ( std::ostream &  of) const

Definition at line 456 of file LinInterpolatedTableND.h.

References mps_update::status.

456  {
457  const bool status = data_.classId().write(of) && data_.write(of) && gs::write_obj_vector(of, axes_);
458  if (status) {
459  gs::write_pod_array(of, leftInterpolationLinear_, dim_);
460  gs::write_pod_array(of, rightInterpolationLinear_, dim_);
461  gs::write_pod(of, functionLabel_);
462  }
463  return status && !of.fail();
464  }
bool write(std::ostream &of) const
Definition: ArrayND.h:5378
list status
Definition: mps_update.py:107
gs::ClassId classId() const
Definition: ArrayND.h:1039
tuple of
Definition: haddnano.py:40
char rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
char leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]

Friends And Related Function Documentation

template<class Numeric, class Axis = UniformAxis>
template<typename Num2 , typename Axis2 >
friend class LinInterpolatedTableND
friend

Definition at line 33 of file LinInterpolatedTableND.h.

Member Data Documentation

template<class Numeric, class Axis = UniformAxis>
bool npstat::LinInterpolatedTableND< Numeric, Axis >::allConstInterpolated_
private
template<class Numeric, class Axis = UniformAxis>
std::vector<Axis> npstat::LinInterpolatedTableND< Numeric, Axis >::axes_
private
template<class Numeric, class Axis = UniformAxis>
ArrayND<Numeric> npstat::LinInterpolatedTableND< Numeric, Axis >::data_
private
template<class Numeric, class Axis = UniformAxis>
unsigned npstat::LinInterpolatedTableND< Numeric, Axis >::dim_
private
template<class Numeric, class Axis = UniformAxis>
std::string npstat::LinInterpolatedTableND< Numeric, Axis >::functionLabel_
private
template<class Numeric, class Axis = UniformAxis>
char npstat::LinInterpolatedTableND< Numeric, Axis >::leftInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
private
template<class Numeric, class Axis = UniformAxis>
char npstat::LinInterpolatedTableND< Numeric, Axis >::rightInterpolationLinear_[CHAR_BIT *sizeof(unsigned long)]
private