10 Axis::Axis(
double min,
double max,
EMode mode,
double delta) : mMin(min), mMax(max), mMode(mode), mMinDelta(delta)
18 spdlog::warn(
"Swaping min[{}] and max[{}] values entered by user, because min is higher then max !!!", min,
44 if (decimalsMin == 0 && decimalsMax == 0) {
51 int m = std::min(decimalsMin, decimalsMax);
60 int m = std::max(decimalsMin, decimalsMax);
68 if (
mMode == kAligned)
83 void Axis::find(
double v,
double & min,
double & max, std::string & path,
int levelrequest,
int levelmax)
89 spdlog::trace(
"Finding value[{}] levelrequest[{}] levelmas[{}]...", v, levelrequest, levelmax);
98 if (v < mMin || v >
mMax || NDM::Utils::is_equal(v,
mMax)) {
99 spdlog::warn(
"Value '{}' is out of range <{},{}) !!!", v,
mMin,
mMax);
106 find(v, levelrequest, levelmax, currentlevel, min, max, path);
112 spdlog::trace(
"Result value[{}] <{},{}) path[{}] level[{}] internal[<{},{})] ...",
to_user(v), min, max, path,
116 void Axis::find(
double & v,
int & levelrequest,
int & levelmax,
int & currentlevel,
double & min,
double & max,
123 if (NDM::Utils::is_equal(v, min)) {
124 if (currentlevel >= levelrequest)
return;
126 if (NDM::Utils::is_equal(v, max)) {
127 if (currentlevel == 0)
return;
136 if (currentlevel > levelmax)
return;
140 double avg = (max +
min) / 2;
141 spdlog::trace(
"min[{}]({}) max[{}]({}) avg[{}]({}) value[{}] ...", min,
to_user(min), max,
to_user(max), avg,
152 spdlog::trace(
"level=[{}] path={}...", currentlevel, path);
153 find(v, levelrequest, levelmax, currentlevel, min, max, path);
179 spdlog::warn(
"Power is zero !!! Doing nothing ...");
183 if ((power < 0) && std::pow(2, std::abs(power)) >
mMaxB) {
185 spdlog::warn(
"Divide is not possible !!! Reason : mMaxB[{}] < divide[{}]",
mMaxB, std::pow(2, std::abs(power)));
189 if (direction ==
'>') {
193 else if (power < 0) {
195 for (
int i = 0; i < std::abs(power); ++i)
mMax -= (
mMax -
mMin) / 2;
198 else if (direction ==
'<') {
202 else if (power < 0) {
204 for (
int i = 0; i < std::abs(power); ++i)
mMin += (
mMax -
mMin) / 2;
208 spdlog::error(
"Direction '{}' is not supported !!!");
209 spdlog::error(
" Hint: Try '>' for right or '<' for left.");
221 spdlog::info(
"min[{}] max[{}] maxb[{}({})] mode[{}] level[{}] shift[{}] multiply[{}]",
mMin,
mMax,
mMaxB,
maxb_user(),
232 double fractpart, intpart, tmp;
233 fractpart = modf(num, &intpart);
234 spdlog::trace(
"L1 : num[{}] tmp[{}] intpart[{}] fractpart[{}]", num, tmp, intpart, fractpart);
235 while (fractpart > min && fractpart < max) {
236 tmp = fractpart * mult;
237 fractpart = modf(tmp, &intpart);
238 spdlog::trace(
"L2 : num[{}] tmp[{}] intpart[{}] fractpart[{}]", num, tmp, intpart, fractpart);
251 if (num < 0.01)
return 0;
254 double fractpart, intpart, tmp;
255 fractpart = modf(num, &intpart);
256 spdlog::trace(
"H1 : num[{}] tmp[{}] intpart[{}] fractpart[{}]", num, tmp, intpart, fractpart);
257 while (fractpart < min) {
258 tmp = intpart / mult;
259 fractpart = modf(tmp, &intpart);
260 spdlog::trace(
"H2 : num[{}] tmp[{}] intpart[{}] fractpart[{}]", num, tmp, intpart, fractpart);
272 double p2 = pow(2, level);
274 spdlog::error(
"Cannot split histogram with {} bins into {} levels because (2^{}={}) > {}. Stop.",
mMaxB, level,
278 double step =
mMaxB / p2;
280 spdlog::debug(
"split: level[{}] max[{}] step[{}]", level,
mMaxB, step);
282 for (
double iMins = 0; iMins <
mMaxB; iMins += step) {
284 mins.push_back(
to_user(iMins));
void split(std::vector< double > &mins, int level)
double mMaxB
Internal maximum.
double to_user(double v) const
Convert interal to user format.
double to_internal(double v) const
Convert user to internal format.
void minmax(double min, double max)
Sets user defined minimum and maximum.
int decimels_right(double num, double mult=10, double min=0.01, double max=0.99)
void find(double v, double &min, double &max, std::string &path, int levelrequest=-1, int levelmax=100)
Find bin and print info for given value.
double mMinDelta
Minimal delta of axis range.
unsigned int mLevel
Level of division.
double max() const
Returns user defined maximum.
void print() const
Prints axis info.
double mMin
User defined minimum.
double mShift
Shift to the internal min/max parameters.
void expand(char direction= '>', int power=1)
Expand range.
void shrink(char direction= '>', int power=1)
Shrink range.
double maxb() const
Returns internal maximum.
void modify_range(char direction= '>', int power=1)
double mMultiply
Multiply to the internal min/max parameters.
double min() const
Returns user defined minimum.
double mMax
User defined maximum.
double maxb_user() const
Returns internal maximum2.
Axis(double min=0.0, double max=1.0, EMode mode=kAligned, double delta=1)
int decimels_left(double num, double mult=10, double min=0.01)