mirror of
https://github.com/tstack/lnav
synced 2024-11-05 21:21:19 +00:00
[build] use cmath instead of math.h
Defect Number: Reviewed By: Testing Done:
This commit is contained in:
parent
2e827da102
commit
686ce639a0
@ -29,11 +29,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#include "lnav_util.hh"
|
||||
#include "hist_source.hh"
|
||||
|
||||
|
@ -32,9 +32,8 @@
|
||||
#ifndef __hist_source_hh
|
||||
#define __hist_source_hh
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <map>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -269,7 +268,7 @@ public:
|
||||
};
|
||||
|
||||
double width() const {
|
||||
return fabs(this->bs_max_value - this->bs_min_value);
|
||||
return std::fabs(this->bs_max_value - this->bs_min_value);
|
||||
};
|
||||
|
||||
void update(double value) {
|
||||
|
@ -32,9 +32,10 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "lnav_log.hh"
|
||||
#include "listview_curses.hh"
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <glob.h>
|
||||
#include <locale.h>
|
||||
|
@ -34,7 +34,6 @@
|
||||
#ifndef __lnav_util_hh
|
||||
#define __lnav_util_hh
|
||||
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <poll.h>
|
||||
|
@ -10,7 +10,7 @@
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* and/or otherlist materials provided with the distribution.
|
||||
* * Neither the name of Timothy Stack nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
@ -32,9 +32,9 @@
|
||||
#ifndef __log_accel_h
|
||||
#define __log_accel_h
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
#include "lnav_log.hh"
|
||||
@ -131,7 +131,7 @@ public:
|
||||
double avg_accel = this->get_avg_accel();
|
||||
direction_t retval;
|
||||
|
||||
if (::fabs(avg_accel) <= THRESHOLD) {
|
||||
if (std::fabs(avg_accel) <= THRESHOLD) {
|
||||
retval = A_STEADY;
|
||||
}
|
||||
else if (avg_accel < 0.0) {
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
@ -32,7 +32,6 @@
|
||||
#ifndef __spectro_source_hh
|
||||
#define __spectro_source_hh
|
||||
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <map>
|
||||
|
@ -84,7 +84,7 @@ void textview_curses::reload_data(void)
|
||||
if (this->tc_sub_source != nullptr) {
|
||||
this->tc_sub_source->text_update_marks(this->tc_bookmarks);
|
||||
}
|
||||
this->listview_curses::reload_data();
|
||||
listview_curses::reload_data();
|
||||
}
|
||||
|
||||
void textview_curses::grep_begin(grep_proc<vis_line_t> &gp, vis_line_t start, vis_line_t stop)
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
#include "auto_mem.hh"
|
||||
@ -718,3 +719,46 @@ int view_colors::ensure_color_pair(const rgb_color &rgb_fg, const rgb_color &rgb
|
||||
xterm_colors.match_color(rgb_fg),
|
||||
rgb_bg.empty() ? (short) COLOR_BLACK : xterm_colors.match_color(rgb_bg));
|
||||
}
|
||||
|
||||
lab_color::lab_color(const rgb_color &rgb)
|
||||
{
|
||||
double r = rgb.rc_r / 255.0,
|
||||
g = rgb.rc_g / 255.0,
|
||||
b = rgb.rc_b / 255.0,
|
||||
x, y, z;
|
||||
|
||||
r = (r > 0.04045) ? pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
||||
g = (g > 0.04045) ? pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
||||
b = (b > 0.04045) ? pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
||||
|
||||
x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;
|
||||
y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;
|
||||
z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;
|
||||
|
||||
x = (x > 0.008856) ? pow(x, 1.0/3.0) : (7.787 * x) + 16.0/116.0;
|
||||
y = (y > 0.008856) ? pow(y, 1.0/3.0) : (7.787 * y) + 16.0/116.0;
|
||||
z = (z > 0.008856) ? pow(z, 1.0/3.0) : (7.787 * z) + 16.0/116.0;
|
||||
|
||||
this->lc_l = (116.0 * y) - 16;
|
||||
this->lc_a = 500.0 * (x - y);
|
||||
this->lc_b = 200.0 * (y - z);
|
||||
}
|
||||
|
||||
double lab_color::deltaE(const lab_color &other) const
|
||||
{
|
||||
double deltaL = this->lc_l - other.lc_l;
|
||||
double deltaA = this->lc_a - other.lc_a;
|
||||
double deltaB = this->lc_b - other.lc_b;
|
||||
double c1 = sqrt(this->lc_a * this->lc_a + this->lc_b * this->lc_b);
|
||||
double c2 = sqrt(other.lc_a * other.lc_a + other.lc_b * other.lc_b);
|
||||
double deltaC = c1 - c2;
|
||||
double deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;
|
||||
deltaH = deltaH < 0.0 ? 0.0 : sqrt(deltaH);
|
||||
double sc = 1.0 + 0.045 * c1;
|
||||
double sh = 1.0 + 0.015 * c1;
|
||||
double deltaLKlsl = deltaL / (1.0);
|
||||
double deltaCkcsc = deltaC / (sc);
|
||||
double deltaHkhsh = deltaH / (sh);
|
||||
double i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;
|
||||
return i < 0.0 ? 0.0 : sqrt(i);
|
||||
}
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <zlib.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
@ -309,46 +308,9 @@ struct lab_color {
|
||||
lab_color() : lc_l(0), lc_a(0), lc_b(0) {
|
||||
};
|
||||
|
||||
lab_color(const rgb_color &rgb) {
|
||||
double r = rgb.rc_r / 255.0,
|
||||
g = rgb.rc_g / 255.0,
|
||||
b = rgb.rc_b / 255.0,
|
||||
x, y, z;
|
||||
lab_color(const rgb_color &rgb);
|
||||
|
||||
r = (r > 0.04045) ? pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
||||
g = (g > 0.04045) ? pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
||||
b = (b > 0.04045) ? pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
||||
|
||||
x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;
|
||||
y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;
|
||||
z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;
|
||||
|
||||
x = (x > 0.008856) ? pow(x, 1.0/3.0) : (7.787 * x) + 16.0/116.0;
|
||||
y = (y > 0.008856) ? pow(y, 1.0/3.0) : (7.787 * y) + 16.0/116.0;
|
||||
z = (z > 0.008856) ? pow(z, 1.0/3.0) : (7.787 * z) + 16.0/116.0;
|
||||
|
||||
this->lc_l = (116.0 * y) - 16;
|
||||
this->lc_a = 500.0 * (x - y);
|
||||
this->lc_b = 200.0 * (y - z);
|
||||
}
|
||||
|
||||
double deltaE(const lab_color &other) const {
|
||||
double deltaL = this->lc_l - other.lc_l;
|
||||
double deltaA = this->lc_a - other.lc_a;
|
||||
double deltaB = this->lc_b - other.lc_b;
|
||||
double c1 = sqrt(this->lc_a * this->lc_a + this->lc_b * this->lc_b);
|
||||
double c2 = sqrt(other.lc_a * other.lc_a + other.lc_b * other.lc_b);
|
||||
double deltaC = c1 - c2;
|
||||
double deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;
|
||||
deltaH = deltaH < 0.0 ? 0.0 : sqrt(deltaH);
|
||||
double sc = 1.0 + 0.045 * c1;
|
||||
double sh = 1.0 + 0.015 * c1;
|
||||
double deltaLKlsl = deltaL / (1.0);
|
||||
double deltaCkcsc = deltaC / (sc);
|
||||
double deltaHkhsh = deltaH / (sh);
|
||||
double i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;
|
||||
return i < 0.0 ? 0.0 : sqrt(i);
|
||||
}
|
||||
double deltaE(const lab_color &other) const;
|
||||
|
||||
lab_color& operator=(const lab_color &other) {
|
||||
this->lc_l = other.lc_l;
|
||||
|
Loading…
Reference in New Issue
Block a user