Debian Codegraph @

melder/NUMmath.cpp

raw symbols SCIP
1 /* NUMmath.cpp
2 *
3 * Copyright (C) 1992-2008,2011,2012,2014,2015,2017,2018,2025 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "melder.h"
20
21 void NUMshift (double *x, double xfrom, double xto) {
22 if (*x == xfrom)
23 *x = xto;
24 else
25 *x += xto - xfrom;
26 }
27
28 void NUMscale (double *x, double xminfrom, double xmaxfrom, double xminto, double xmaxto) {
29 if (*x == xminfrom)
30 *x = xminto;
31 else if (*x == xmaxfrom)
32 *x = xmaxto;
33 else
34 *x = xminto + (xmaxto - xminto) * ((*x - xminfrom) / (xmaxfrom - xminfrom));
35 }
36
37 /* End of file NUMmath.cpp */