Skip to content

Deprecate math macros #4414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libvips/arithmetic/abs.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ vips_abs_build(VipsObject *object)
int x; \
\
for (x = 0; x < sz; x++) \
q[x] = VIPS_FABS(p[x]); \
q[x] = fabs(p[x]); \
}

/* Complex abs operation: calculate modulus.
Expand Down
2 changes: 1 addition & 1 deletion libvips/arithmetic/deviate.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ vips_deviate_build(VipsObject *object)
s2 = deviate->sum2;

g_object_set(object,
"out", sqrt(VIPS_FABS(s2 - (s * s / vals)) / (vals - 1)),
"out", sqrt(fabs(s2 - (s * s / vals)) / (vals - 1)),
NULL);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion libvips/arithmetic/divide.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ G_DEFINE_TYPE(VipsDivide, vips_divide, VIPS_TYPE_BINARY);
q[0] = 0.0; \
q[1] = 0.0; \
} \
else if (VIPS_FABS(right[0]) > VIPS_FABS(right[1])) { \
else if (fabs(right[0]) > fabs(right[1])) { \
double a = right[1] / right[0]; \
double b = right[0] + right[1] * a; \
\
Expand Down
4 changes: 2 additions & 2 deletions libvips/arithmetic/max.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ vips_max_stop(VipsStatistic *statistic, void *seq)
TYPE m; \
\
for (i = 0; i < sz && values->n < values->size; i++) \
if (!VIPS_ISNAN(p[i])) \
if (!isnan(p[i])) \
vips_values_add(values, p[i], x + i / bands, y); \
m = values->value[0]; \
\
Expand All @@ -358,7 +358,7 @@ vips_max_stop(VipsStatistic *statistic, void *seq)
for (i = 0; i < sz && values->n < values->size; i++) { \
TYPE mod2 = p[0] * p[0] + p[1] * p[1]; \
\
if (!VIPS_ISNAN(mod2)) \
if (!isnan(mod2)) \
vips_values_add(values, p[i], x + i / bands, y); \
\
p += 2; \
Expand Down
2 changes: 1 addition & 1 deletion libvips/arithmetic/maxpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ G_DEFINE_TYPE(VipsMaxpair, vips_maxpair, VIPS_TYPE_BINARY);
TYPE *restrict q = (TYPE *) out; \
\
for (int x = 0; x < sz; x++) \
q[x] = VIPS_FMAX(left[x], right[x]); \
q[x] = fmax(left[x], right[x]); \
}

static void
Expand Down
4 changes: 2 additions & 2 deletions libvips/arithmetic/measure.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ vips_measure_build(VipsObject *object)
* averages near zero (can get these if use
* measure on IM_TYPE_LAB images).
*/
if (dev * 5 > VIPS_FABS(avg) &&
VIPS_FABS(avg) > 3)
if (dev * 5 > fabs(avg) &&
fabs(avg) > 3)
g_warning(_("%s: "
"patch %d x %d, "
"band %d: "
Expand Down
4 changes: 2 additions & 2 deletions libvips/arithmetic/min.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ vips_min_stop(VipsStatistic *statistic, void *seq)
TYPE m; \
\
for (i = 0; i < sz && values->n < values->size; i++) \
if (!VIPS_ISNAN(p[i])) \
if (!isnan(p[i])) \
vips_values_add(values, p[i], x + i / bands, y); \
m = values->value[0]; \
\
Expand All @@ -358,7 +358,7 @@ vips_min_stop(VipsStatistic *statistic, void *seq)
for (i = 0; i < sz && values->n < values->size; i++) { \
TYPE mod2 = p[0] * p[0] + p[1] * p[1]; \
\
if (!VIPS_ISNAN(mod2)) \
if (!isnan(mod2)) \
vips_values_add(values, p[i], x + i / bands, y); \
\
p += 2; \
Expand Down
2 changes: 1 addition & 1 deletion libvips/arithmetic/minpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ G_DEFINE_TYPE(VipsMinpair, vips_minpair, VIPS_TYPE_BINARY);
TYPE *restrict q = (TYPE *) out; \
\
for (int x = 0; x < sz; x++) \
q[x] = VIPS_FMIN(left[x], right[x]); \
q[x] = fmin(left[x], right[x]); \
}

static void
Expand Down
2 changes: 1 addition & 1 deletion libvips/arithmetic/remainder.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ vips_remainder_build(VipsObject *object)
double a = p1[x]; \
double b = p2[x]; \
\
q[x] = b ? a - b * VIPS_FLOOR(a / b) : -1; \
q[x] = b ? a - b * floor(a / b) : -1; \
} \
}

Expand Down
6 changes: 3 additions & 3 deletions libvips/arithmetic/round.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ vips_round_buffer(VipsArithmetic *arithmetic,

switch (round->round) {
case VIPS_OPERATION_ROUND_RINT:
SWITCH(VIPS_RINT);
SWITCH(rint);
break;
case VIPS_OPERATION_ROUND_CEIL:
SWITCH(VIPS_CEIL);
SWITCH(ceil);
break;
case VIPS_OPERATION_ROUND_FLOOR:
SWITCH(VIPS_FLOOR);
SWITCH(floor);
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions libvips/arithmetic/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ vips_stats_build(VipsObject *object)

row[COL_AVG] = row[COL_SUM] / pels;
row[COL_SD] = sqrt(
VIPS_FABS(row[COL_SUM2] -
fabs(row[COL_SUM2] -
(row[COL_SUM] * row[COL_SUM] / pels)) /
(pels - 1));
}

row0[COL_AVG] = row0[COL_SUM] / vals;
row0[COL_SD] = sqrt(
VIPS_FABS(row0[COL_SUM2] -
fabs(row0[COL_SUM2] -
(row0[COL_SUM] * row0[COL_SUM] / vals)) /
(vals - 1));

Expand Down
2 changes: 1 addition & 1 deletion libvips/colour/HSV2sRGB.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ vips_HSV2sRGB_line(VipsColour *colour, VipsPel *out, VipsPel **in, int width)
float c, x, m;

c = p[2] * p[1] / 255.0;
x = c * (1 - VIPS_FABS(fmod(p[0] / SIXTH_OF_CHAR, 2) - 1));
x = c * (1 - fabs(fmod(p[0] / SIXTH_OF_CHAR, 2) - 1));
m = p[2] - c;

if (p[0] < (int) SIXTH_OF_CHAR) {
Expand Down
2 changes: 1 addition & 1 deletion libvips/colour/LCh2UCS.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ vips_col_Ch2hcmc(float C, float h)
}

P = cos(VIPS_RAD(k7 * h + k8));
D = k4 + k5 * P * pow(VIPS_FABS(P), k6);
D = k4 + k5 * P * pow(fabs(P), k6);
g = C * C * C * C;
f = sqrt(g / (g + 1900.0));
hcmc = h + D * f;
Expand Down
4 changes: 2 additions & 2 deletions libvips/colour/Lab2LabQ.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ vips_Lab2LabQ_line(VipsColour *colour, VipsPel *out, VipsPel **in, int width)
q[0] = intv >> 2; /* drop bot 2 bits and store */

fval = 8.0 * p[1]; /* do a */
intv = VIPS_RINT(fval);
intv = rint(fval);
intv = VIPS_CLIP(-1024, intv, 1023);
lsbs |= (intv & 0x7) << 3; /* 00000111 -> 00111000 */
q[1] = intv >> 3; /* drop bot 3 bits & store */

fval = 8.0 * p[2]; /* do b */
intv = VIPS_RINT(fval);
intv = rint(fval);
intv = VIPS_CLIP(-1024, intv, 1023);
lsbs |= (intv & 0x7);
q[2] = intv >> 3;
Expand Down
14 changes: 7 additions & 7 deletions libvips/colour/LabQ2sRGB.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ calcul_tables(int range, int *Y2v, float *v2Y)
else
v = (1.0 + 0.055) * pow(f, 1.0 / 2.4) - 0.055;

Y2v[i] = VIPS_RINT((range - 1) * v);
Y2v[i] = rint((range - 1) * v);
}

/* Copy the final element. This is used in the piecewise linear
Expand Down Expand Up @@ -303,7 +303,7 @@ vips_col_scRGB2sRGB(int range, int *lut,
* Don't use isnormal(), it is false for 0.0 and for subnormal
* numbers.
*/
if (VIPS_ISNAN(R) || VIPS_ISNAN(G) || VIPS_ISNAN(B)) {
if (isnan(R) || isnan(G) || isnan(B)) {
*r = 0;
*g = 0;
*b = 0;
Expand Down Expand Up @@ -337,19 +337,19 @@ vips_col_scRGB2sRGB(int range, int *lut,
CLIP(0, Yf, maxval);
Yi = (int) Yf;
v = lut[Yi] + (lut[Yi + 1] - lut[Yi]) * (Yf - Yi);
*r = VIPS_RINT(v);
*r = rint(v);

Yf = G * maxval;
CLIP(0, Yf, maxval);
Yi = (int) Yf;
v = lut[Yi] + (lut[Yi + 1] - lut[Yi]) * (Yf - Yi);
*g = VIPS_RINT(v);
*g = rint(v);

Yf = B * maxval;
CLIP(0, Yf, maxval);
Yi = (int) Yf;
v = lut[Yi] + (lut[Yi + 1] - lut[Yi]) * (Yf - Yi);
*b = VIPS_RINT(v);
*b = rint(v);

if (og_ret)
*og_ret = og;
Expand Down Expand Up @@ -399,7 +399,7 @@ vips_col_scRGB2BW(int range, int *lut, float R, float G, float B,
/* Y can be Nan. Throw those values out, they will break
* our clipping.
*/
if (VIPS_ISNAN(Y)) {
if (isnan(Y)) {
*g = 0;

return -1;
Expand All @@ -417,7 +417,7 @@ vips_col_scRGB2BW(int range, int *lut, float R, float G, float B,
CLIP(0, Yf, maxval);
Yi = (int) Yf;
v = lut[Yi] + (lut[Yi + 1] - lut[Yi]) * (Yf - Yi);
*g = VIPS_RINT(v);
*g = rint(v);

if (og_ret)
*og_ret = og;
Expand Down
6 changes: 3 additions & 3 deletions libvips/colour/UCS2LCh.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ vips_col_Lcmc2L(float Lcmc)
{
int known;

known = VIPS_FLOOR(Lcmc * 10.0);
known = floor(Lcmc * 10.0);
known = VIPS_CLIP(0, known, 999);

return LI[known] +
Expand All @@ -173,7 +173,7 @@ vips_col_Ccmc2C(float Ccmc)
{
int known;

known = VIPS_FLOOR(Ccmc * 10.0);
known = floor(Ccmc * 10.0);
known = VIPS_CLIP(0, known, 2999);

return CI[known] +
Expand Down Expand Up @@ -202,7 +202,7 @@ vips_col_Chcmc2h(float C, float hcmc)
r = (int) ((C + 1.0) / 2.0);
r = VIPS_CLIP(0, r, 99);

known = VIPS_FLOOR(hcmc);
known = floor(hcmc);
known = VIPS_CLIP(0, known, 359);

return hI[r][known] +
Expand Down
6 changes: 3 additions & 3 deletions libvips/colour/dE00.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ vips_col_dE00(float L1, float a1, float b1,
*/
double Ldb = (L1d + L2d) / 2;
double Cdb = (C1d + C2d) / 2;
double hdb = VIPS_FABS(h1d - h2d) < 180
double hdb = fabs(h1d - h2d) < 180
? (h1d + h2d) / 2
: VIPS_FABS(h1d + h2d - 360) / 2;
: fabs(h1d + h2d - 360) / 2;

/* dtheta, RC
*/
Expand All @@ -162,7 +162,7 @@ vips_col_dE00(float L1, float a1, float b1,

/* hue difference ... careful!
*/
double dhd = VIPS_FABS(h1d - h2d) < 180
double dhd = fabs(h1d - h2d) < 180
? h1d - h2d
: 360 - (h1d - h2d);

Expand Down
4 changes: 2 additions & 2 deletions libvips/conversion/unpremultiply.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ G_DEFINE_TYPE(VipsUnpremultiply, vips_unpremultiply, VIPS_TYPE_CONVERSION);
\
for (x = 0; x < width; x++) { \
IN alpha = p[alpha_band]; \
OUT factor = VIPS_ABS(alpha) < 0.01 ? 0 : max_alpha / alpha; \
OUT factor = fabs(alpha) < 0.01 ? 0 : max_alpha / alpha; \
\
for (i = 0; i < alpha_band; i++) \
q[i] = factor * p[i]; \
Expand All @@ -158,7 +158,7 @@ G_DEFINE_TYPE(VipsUnpremultiply, vips_unpremultiply, VIPS_TYPE_CONVERSION);
\
for (x = 0; x < width; x++) { \
IN alpha = p[3]; \
OUT factor = VIPS_ABS(alpha) < 0.01 ? 0 : max_alpha / alpha; \
OUT factor = fabs(alpha) < 0.01 ? 0 : max_alpha / alpha; \
\
q[0] = factor * p[0]; \
q[1] = factor * p[1]; \
Expand Down
6 changes: 3 additions & 3 deletions libvips/convolution/conva.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ vips_conva_decompose_hlines(VipsConva *conva)
* fixed n-lines which includes any negative parts.
*/
depth = (max - min) / conva->layers;
layers_above = VIPS_CEIL(max / depth);
layers_above = ceil(max / depth);
depth = max / layers_above;
layers_below = VIPS_FLOOR(min / depth);
layers_below = floor(min / depth);
conva->layers = layers_above - layers_below; // FIXME: Invalidates operation cache

VIPS_DEBUG_MSG("vips_conva_decompose_hlines: depth = %g, layers = %d\n",
Expand Down Expand Up @@ -744,7 +744,7 @@ vips_conva_decompose_boxes(VipsConva *conva)
for (z = 0; z < size; z++)
sum += fabs(coeff[z]);

conva->divisor = VIPS_RINT(area * scale / sum);
conva->divisor = rint(area * scale / sum);
conva->rounding = (conva->divisor + 1) / 2;
conva->offset = offset;

Expand Down
2 changes: 1 addition & 1 deletion libvips/convolution/convasep.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ vips_convasep_decompose(VipsConvasep *convasep)
for (z = 0; z < convasep->width; z++)
sum += coeff[z];

convasep->divisor = VIPS_RINT(sum * area / scale);
convasep->divisor = rint(sum * area / scale);
if (convasep->divisor == 0)
convasep->divisor = 1;
convasep->rounding = (convasep->divisor + 1) / 2;
Expand Down
20 changes: 10 additions & 10 deletions libvips/convolution/convi.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ vips_convi_uchar_vector_gen(VipsRegion *out_region,
VipsConvi *convi = (VipsConvi *) b;
VipsConvolution *convolution = (VipsConvolution *) convi;
VipsImage *M = convolution->M;
int offset = VIPS_RINT(vips_image_get_offset(M));
int offset = rint(vips_image_get_offset(M));
VipsImage *in = (VipsImage *) a;
VipsRegion *ir = seq->ir;
const int nnz = convi->nnz;
Expand Down Expand Up @@ -521,7 +521,7 @@ vips_convi_compile_clip(VipsConvi *convi)
{
VipsConvolution *convolution = (VipsConvolution *) convi;
VipsImage *M = convolution->M;
int offset = VIPS_RINT(vips_image_get_offset(M));
int offset = rint(vips_image_get_offset(M));

OrcProgram *p;
OrcCompileResult result;
Expand Down Expand Up @@ -755,9 +755,9 @@ vips_convi_gen(VipsRegion *out_region,
VipsConvi *convi = (VipsConvi *) b;
VipsConvolution *convolution = (VipsConvolution *) convi;
VipsImage *M = convolution->M;
int scale = VIPS_RINT(vips_image_get_scale(M));
int scale = rint(vips_image_get_scale(M));
int rounding = scale / 2;
int offset = VIPS_RINT(vips_image_get_offset(M));
int offset = rint(vips_image_get_offset(M));
VipsImage *in = (VipsImage *) a;
VipsRegion *ir = seq->ir;
int *restrict t = convi->coeff;
Expand Down Expand Up @@ -890,12 +890,12 @@ vips__image_intize(VipsImage *in, VipsImage **out)
for (y = 0; y < t->Ysize; y++)
for (x = 0; x < t->Xsize; x++)
*VIPS_MATRIX(*out, x, y) =
VIPS_RINT(*VIPS_MATRIX(t, x, y));
rint(*VIPS_MATRIX(t, x, y));

out_scale = VIPS_RINT(vips_image_get_scale(t));
out_scale = rint(vips_image_get_scale(t));
if (out_scale == 0)
out_scale = 1;
out_offset = VIPS_RINT(vips_image_get_offset(t));
out_offset = rint(vips_image_get_offset(t));

/* Now convolve a 1 everywhere image with the int version we've made,
* what do we get?
Expand All @@ -908,7 +908,7 @@ vips__image_intize(VipsImage *in, VipsImage **out)

/* And adjust the scale to get as close to a match as we can.
*/
out_scale = VIPS_RINT(out_scale + (int_result - double_result));
out_scale = rint(out_scale + (int_result - double_result));
if (out_scale == 0)
out_scale = 1;

Expand Down Expand Up @@ -1023,7 +1023,7 @@ vips_convi_intize(VipsConvi *convi, VipsImage *M)
for (i = 0; i < convi->n_point; i++) {
/* 128 since this is signed.
*/
convi->mant[i] = VIPS_RINT(128 * scaled[i] * pow(2, -shift));
convi->mant[i] = rint(128 * scaled[i] * pow(2, -shift));

if (convi->mant[i] < -128 ||
convi->mant[i] > 127) {
Expand Down Expand Up @@ -1106,7 +1106,7 @@ vips_convi_intize(VipsConvi *convi, VipsImage *M)
int_value = VIPS_LSHIFT_INT(int_sum, convi->exp);
int_value = VIPS_CLIP(0, int_value, 255);

if (VIPS_ABS(true_value - int_value) > 2) {
if (abs(true_value - int_value) > 2) {
g_info("vips_convi_intize: too inaccurate");
return -1;
}
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy