STIR  6.2.0
stir_math.h
1 /*
2  Copyright (C) 2016, UCL
3  This file is part of STIR.
4 
5  SPDX-License-Identifier: Apache-2.0
6 
7  See STIR/LICENSE.txt for details
8 */
9 
10 #ifndef __stir_STIR_MATH_H__
11 #define __stir_STIR_MATH_H__
12 
13 using std::cout;
14 using std::endl;
15 using std::fstream;
16 using std::transform;
17 using std::max;
18 using std::min;
19 using std::string;
20 using std::vector;
21 
22 USING_NAMESPACE_STIR
23 
24 // Nikos Efthimiou: Minimal header file to be able to use this class from other
25 // places in the code.
26 
27 // a function object that takes a power of a float, and then multiplies with a float, and finally adds a float
28 class pow_times_add
29 {
30 public:
31  pow_times_add(
32  const float add_scalar, const float mult_scalar, const float power, const float min_threshold, const float max_threshold)
33  : add(add_scalar),
34  mult(mult_scalar),
35  power(power),
36  min_threshold(min_threshold),
37  max_threshold(max_threshold)
38  {}
39 
40  float operator()(float const arg) const
41  {
42  const float value = min(max(arg, min_threshold), max_threshold);
43  return add + mult * (power == 1 ? value : pow(value, power));
44  }
45 
46 private:
47  const float add;
48  const float mult;
49  const float power;
50  const float min_threshold;
51  const float max_threshold;
52 };
53 
54 #endif
double min_threshold
value to reduce the total_rpc_time values
Definition: distributed_functions.cxx:44