Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPower.hh
Go to the documentation of this file.
1 #ifndef __JMATH__JPOWER__
2 #define __JMATH__JPOWER__
3 
4 #include <istream>
5 #include <ostream>
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JMATH {}
13 namespace JPP { using namespace JMATH; }
14 
15 namespace JMATH {
16 
17  /**
18  * Power law function object.
19  *
20  * Evaluation of function, derivative and integral values.
21  */
22  class JPower {
23  public:
24  /**
25  * Constructor.
26  *
27  * \param alpha spectral index
28  * \param factor multiplication factor
29  */
30  JPower(const double alpha,
31  const double factor = 1.0)
32  {
33  this->alpha = alpha;
34  this->factor = factor;
35  }
36 
37 
38  /**
39  * Function value.
40  *
41  * \param x abscissa value
42  * \return function value
43  */
44  double getValue(const double x) const
45  {
46  return factor * pow(x, alpha);
47  }
48 
49 
50  /**
51  * Derivative value.
52  *
53  * \param x abscissa value
54  * \return derivative value
55  */
56  double getDerivative(const double x) const
57  {
58  return factor * alpha * pow(x, alpha - 1);
59  }
60 
61 
62  /**
63  * Integral value.
64  *
65  * \param x abscissa value
66  * \return integral value
67  */
68  double getIntegral(const double x) const
69  {
70  if (alpha != -1.0)
71  return factor * pow(x, alpha + 1) / (alpha + 1);
72  else
73  return factor * log(x);
74  }
75 
76 
77  /**
78  * Function value.
79  *
80  * \param x abscissa value
81  * \return function value
82  */
83  double operator()(const double x) const
84  {
85  return getValue(x);
86  }
87 
88 
89  /**
90  * Read power from input.
91  *
92  * \param in input stream
93  * \param object power
94  * \return input stream
95  */
96  friend inline std::istream& operator>>(std::istream& in, JPower& object)
97  {
98  in >> object.alpha >> object.factor;
99 
100  return in;
101  }
102 
103 
104  /**
105  * Write power to output.
106  *
107  * \param out output stream
108  * \param object trigonometric
109  * \return output stream
110  */
111  friend inline std::ostream& operator<<(std::ostream& out, const JPower& object)
112  {
113  return out << object.alpha << ' ' << object.factor;
114  }
115 
116  protected:
117  double alpha;
118  double factor;
119  };
120 }
121 
122 #endif
Power law function object.
Definition: JPower.hh:22
double alpha
Definition: JPower.hh:117
double getValue(const double x) const
Function value.
Definition: JPower.hh:44
double operator()(const double x) const
Function value.
Definition: JPower.hh:83
JPower(const double alpha, const double factor=1.0)
Constructor.
Definition: JPower.hh:30
friend std::istream & operator>>(std::istream &in, JPower &object)
Read power from input.
Definition: JPower.hh:96
double getIntegral(const double x) const
Integral value.
Definition: JPower.hh:68
double getDerivative(const double x) const
Derivative value.
Definition: JPower.hh:56
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
double factor
Definition: JPower.hh:118
then cat $TRIPOD_INITIAL<< EOF1 256877.5 4743716.7-2438.42 256815.5 4743395.0-2435.53 257096.2 4743636.0-2439.5EOFfiif[[!-f $DETECTOR]];then JEditDetector-a $DETECTOR_INITIAL-s"-1 addz -6.9"-o $DETECTOR--!eval`JPrintDetector-a $DETECTOR-O SUMMARY`for STRING in ${STRINGS[*]};do set_variable MODULE`getModule-a $DETECTOR-L"$STRING 0"`JEditDetector-a $DETECTOR-M"$MODULE setz -2.9"-o $DETECTOR--!donefiif[[!-f $TRIPOD]];then cp-p $TRIPOD_INITIAL $TRIPODfiJAcoustics.sh $DETECTOR_IDcat > acoustics_trigger_parameters txt<< EOFQ=0.0;TMax_s=0.020;quantile=0.9;numberOfHits=90;EOFJAcousticsEventBuilder.sh $DETECTOR $RUNS[*]INPUT_FILES=(`ls KM3NeT_ ${(l:8::0::0:) DETECTOR_ID}_0 *${^RUNS}_event.root`) cd $WORKDIRif[!$HOMEDIR-ef $WORKDIR];then cp-p $HOMEDIR/$DETECTOR $WORKDIR cp-p $HOMEDIR/$TRIPOD $WORKDIR cp-p $HOMEDIR/${^INPUT_FILES}$WORKDIR cp-p $HOMEDIR/{acoustics_fit_parameters, acoustics_trigger_parameters, disable, hydrophone, mechanics, sound_velocity, tripod, waveform}.txt $WORKDIRfisource $JPP_DIR/examples/JAcoustics/acoustics-fit-toolkit.shtimer_startinitialise stage_1B 0.002 0.1 0 > &stage log
friend std::ostream & operator<<(std::ostream &out, const JPower &object)
Write power to output.
Definition: JPower.hh:111
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46