Debian Codegraph @

fon/Function.cpp

raw symbols SCIP
1 /* Function.cpp
2 *
3 * Copyright (C) 1992-2012,2015-2018,2020,2022-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 "Function.h"cxx . . $ `<file>/fon/Function.h`/
20
21 #include "oo_DESTROY.h"cxx . . $ `<file>/sys/oo_DESTROY.h`/
22 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
23 #include "oo_COPY.h"cxx . . $ `<file>/sys/oo_COPY.h`/
24 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
25 #include "oo_EQUAL.h"cxx . . $ `<file>/sys/oo_EQUAL.h`/
26 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
27 #include "oo_CAN_WRITE_AS_ENCODING.h"cxx . . $ `<file>/sys/oo_CAN_WRITE_AS_ENCODING.h`/
28 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
29 #include "oo_WRITE_TEXT.h"cxx . . $ `<file>/sys/oo_WRITE_TEXT.h`/
30 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
31 #include "oo_READ_TEXT.h"cxx . . $ `<file>/sys/oo_READ_TEXT.h`/
32 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
33 #include "oo_WRITE_BINARY.h"cxx . . $ `<file>/sys/oo_WRITE_BINARY.h`/
34 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
35 #include "oo_READ_BINARY.h"cxx . . $ `<file>/sys/oo_READ_BINARY.h`/
36 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
37 #include "oo_DESCRIPTION.h"cxx . . $ `<file>/sys/oo_DESCRIPTION.h`/
38 #include "Function_def.h"cxx . . $ `<file>/fon/Function_def.h`/
39
40 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Function, Daata, 0);
41
42 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (FunctionList, Ordered, 0);
43
44 void structFunction :: v1_info () {
45 Function_Parent :: v1_infocxx . . $ structThing#v1_info(49f6e7a06ebc5aa8). ();
46 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Domain:");
47 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" xmin: ", xmin);
48 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" xmax: ", xmax);
49 }
50
51 void structFunction :: v_shiftX (double xfrom, double xto) {
52 NUMshiftcxx . . $ NUMshift(5d4b701516ac998a). (& xmin, xfrom, xto);
53 NUMshiftcxx . . $ NUMshift(5d4b701516ac998a). (& xmax, xfrom, xto);
54 }
55
56 void structFunction :: v_scaleX (double xminfrom, double xmaxfrom, double xminto, double xmaxto) {
57 NUMscalecxx . . $ NUMscale(7a063e507c827c33). (& xmin, xminfrom, xmaxfrom, xminto, xmaxto);
58 NUMscalecxx . . $ NUMscale(7a063e507c827c33). (& xmax, xminfrom, xmaxfrom, xminto, xmaxto);
59 }
60
61 void Function_initcxx . . $ Function_init(ac72a71dd6ac1bfb). (mutableFunction me, double xmin_, double xmax_) {
62 mycxx . . $ `melder/melder.h:44:9`! xmin = xmin_;
63 mycxx . . $ `melder/melder.h:44:9`! xmax = xmax_;
64 }
65
66 int Function_getMinimumUnitcxx . . $ Function_getMinimumUnit(3ca9094f3c2853b9). (constFunction me, integercxx . . $ integer# level) {
67 return mycxx . . $ `melder/melder.h:44:9`! v_getMinimumUnit (level);
68 }
69
70 int Function_getMaximumUnitcxx . . $ Function_getMaximumUnit(3ca9094f3c2853b9). (constFunction me, integercxx . . $ integer# level) {
71 return mycxx . . $ `melder/melder.h:44:9`! v_getMaximumUnit (level);
72 }
73
74 int Function_getDomainQuantitycxx . . $ Function_getDomainQuantity(1f467e71fce55133). (constFunction me) {
75 return mycxx . . $ `melder/melder.h:44:9`! v_domainQuantity ();
76 }
77
78 conststring32cxx . . $ conststring32# Function_getUnitTextcxx . . $ Function_getUnitText(a97c80dc386b9edb). (constFunction me, integercxx . . $ integer# level, int unit, uint32cxx . . $ uint32# flags) {
79 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (unit >= mycxx . . $ `melder/melder.h:44:9`! v_getMinimumUnit (level) && unit <= mycxx . . $ `melder/melder.h:44:9`! v_getMaximumUnit (level));
80 return mycxx . . $ `melder/melder.h:44:9`! v_getUnitText (level, unit, flags);
81 }
82
83 bool Function_isUnitLogarithmiccxx . . $ Function_isUnitLogarithmic(a5dfd34c63a2afb0). (constFunction me, integercxx . . $ integer# level, int unit) {
84 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (unit >= mycxx . . $ `melder/melder.h:44:9`! v_getMinimumUnit (level) && unit <= mycxx . . $ `melder/melder.h:44:9`! v_getMaximumUnit (level));
85 return mycxx . . $ `melder/melder.h:44:9`! v_isUnitLogarithmic (level, unit);
86 }
87
88 double Function_convertStandardToSpecialUnitcxx . . $ Function_convertStandardToSpecialUnit(2ac20cd4dc1e204c). (constFunction me, double value, integercxx . . $ integer# level, int unit) {
89 return isdefinedcxx . . $ isdefined(f8197d536af80c96). (value) ? mycxx . . $ `melder/melder.h:44:9`! v_convertStandardToSpecialUnit (value, level, unit) : undefinedcxx . . $ undefined.;
90 }
91
92 double Function_convertSpecialToStandardUnitcxx . . $ Function_convertSpecialToStandardUnit(2ac20cd4dc1e204c). (constFunction me, double value, integercxx . . $ integer# level, int unit) {
93 return isdefinedcxx . . $ isdefined(f8197d536af80c96). (value) ? mycxx . . $ `melder/melder.h:44:9`! v_convertSpecialToStandardUnit (value, level, unit) : undefinedcxx . . $ undefined.;
94 }
95
96 double Function_convertToNonlogarithmiccxx . . $ Function_convertToNonlogarithmic(2ac20cd4dc1e204c). (constFunction me, double value, integercxx . . $ integer# level, int unit) {
97 return isdefinedcxx . . $ isdefined(f8197d536af80c96). (value) && mycxx . . $ `melder/melder.h:44:9`! v_isUnitLogarithmic (level, unit) ? powcxx . . $ pow(b71928d39fde4295). (10.0, value) : value;
98 }
99
100 void Function_shiftXBycxx . . $ Function_shiftXBy(730db58827849a4c). (const mutableFunction me, const double shift) {
101 mycxx . . $ `melder/melder.h:44:9`! v_shiftX (0.0, shift);
102 }
103
104 void Function_shiftXTocxx . . $ Function_shiftXTo(ac72a71dd6ac1bfb). (const mutableFunction me, const double xfrom, const double xto) {
105 mycxx . . $ `melder/melder.h:44:9`! v_shiftX (xfrom, xto);
106 }
107
108 void Function_scaleXBycxx . . $ Function_scaleXBy(730db58827849a4c). (const mutableFunction me, const double factor) {
109 mycxx . . $ `melder/melder.h:44:9`! v_scaleX (0.0, 1.0, 0.0, factor);
110 }
111
112 void Function_scaleXTocxx . . $ Function_scaleXTo(ac72a71dd6ac1bfb). (const mutableFunction me, double xminto, double xmaxto) {
113 mycxx . . $ `melder/melder.h:44:9`! v_scaleX (mycxx . . $ `melder/melder.h:44:9`! xmin, mycxx . . $ `melder/melder.h:44:9`! xmax, xminto, xmaxto);
114 }
115
116 double Function_windowcxx . . $ Function_window(f7856f627868a823). (double tim, int windowType) {
117 static double one_by_bessi_0_12, one_by_bessi_0_20;
118 switch (windowType) {
119 case Function_RECTANGULARcxx . . $ `fon/Function.h:73:9`!:
120 if (tim < -0.5 || tim > 0.5) return 0.0;
121 return 1;
122 case Function_TRIANGULARcxx . . $ `fon/Function.h:74:9`!:
123 if (tim < -0.5 || tim > 0.5) return 0.0;
124 return 1 - tim - tim;
125 case Function_PARABOLICcxx . . $ `fon/Function.h:75:9`!:
126 if (tim < -0.5 || tim > 0.5) return 0.0;
127 return 1 - 4 * tim * tim;
128 case Function_HANNINGcxx . . $ `fon/Function.h:76:9`!:
129 if (tim < -0.5 || tim > 0.5) return 0.0;
130 return 0.5 + 0.5 * coscxx . . $ cos(fee4f1d22bc8e617). (2 * NUMpicxx . . $ NUMpi. * tim);
131 case Function_HAMMINGcxx . . $ `fon/Function.h:77:9`!:
132 if (tim < -0.5 || tim > 0.5) return 0.0;
133 return 0.54 + 0.46 * coscxx . . $ cos(fee4f1d22bc8e617). (2 * NUMpicxx . . $ NUMpi. * tim);
134 case Function_POTTERcxx . . $ `fon/Function.h:78:9`!:
135 if (tim < -0.77 || tim > 0.77) return 0.0;
136 return 0.54 + 0.46 * coscxx . . $ cos(fee4f1d22bc8e617). (2 * NUMpicxx . . $ NUMpi. * tim);
137 case Function_KAISER12cxx . . $ `fon/Function.h:79:9`!:
138 if (tim < -0.77 || tim > 0.77) return 0.0;
139 if (one_by_bessi_0_12 == 0.0) one_by_bessi_0_12 = 1.0 / NUMbessel_i0_fcxx . . $ NUMbessel_i0_f(447c67c6676f75c3). (12);
140 return NUMbessel_i0_fcxx . . $ NUMbessel_i0_f(447c67c6676f75c3). (12 * sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (1 - (1.0 / 0.77 / 0.77) * tim * tim)) * one_by_bessi_0_12;
141 case Function_KAISER20cxx . . $ `fon/Function.h:80:9`!:
142 if (tim <= -1 || tim >= 1) return 0.0;
143 if (one_by_bessi_0_20 == 0.0) one_by_bessi_0_20 = 1.0 / NUMbessel_i0_fcxx . . $ NUMbessel_i0_f(447c67c6676f75c3). (20.24);
144 return NUMbessel_i0_fcxx . . $ NUMbessel_i0_f(447c67c6676f75c3). (20.24 * sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (1 - tim * tim)) * one_by_bessi_0_20;
145 case Function_GAUSSIANcxx . . $ `fon/Function.h:81:9`!:
146 return expcxx . . $ exp(fee4f1d22bc8e617). ((- NUMpicxx . . $ NUMpi. * NUMpicxx . . $ NUMpi.) * tim * tim);
147 default:
148 return 0.0;
149 }
150 }
151
152 void Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (const constFunction me, double *const xmin, double *const xmax) {
153 if (*xmin >= *xmax) {
154 *xmin = mycxx . . $ `melder/melder.h:44:9`! xmin;
155 *xmax = mycxx . . $ `melder/melder.h:44:9`! xmax;
156 }
157 }
158
159 void Function_bidirectionalAutowindowcxx . . $ Function_bidirectionalAutowindow(88b7840c59a57eaf). (const constFunction me, double *const x1, double *const x2) {
160 if (*x1 == *x2) {
161 *x1 = mycxx . . $ `melder/melder.h:44:9`! xmin;
162 *x2 = mycxx . . $ `melder/melder.h:44:9`! xmax;
163 }
164 }
165
166 bool Function_intersectRangeWithDomaincxx . . $ Function_intersectRangeWithDomain(b58540e0674cd12). (const constFunction me, double *const x1, double *const x2) {
167 if (*x1 == *x2)
168 return false;
169 if (*x1 < *x2) {
170 if (*x1 < mycxx . . $ `melder/melder.h:44:9`! xmin)
171 *x1 = mycxx . . $ `melder/melder.h:44:9`! xmin; // intersect requested range with logical domain // TODO: try Melder_clipLeft()
172 if (*x2 > mycxx . . $ `melder/melder.h:44:9`! xmax)
173 *x2 = mycxx . . $ `melder/melder.h:44:9`! xmax;
174 if (*x2 <= *x1)
175 return false; // requested range and logical domain do not intersect
176 } else {
177 if (*x2 < mycxx . . $ `melder/melder.h:44:9`! xmin)
178 *x2 = mycxx . . $ `melder/melder.h:44:9`! xmin; // intersect requested range with logical domain
179 if (*x1 > mycxx . . $ `melder/melder.h:44:9`! xmax)
180 *x1 = mycxx . . $ `melder/melder.h:44:9`! xmax;
181 if (*x1 <= *x2)
182 return false; // requested range and logical domain do not intersect
183 }
184 return true;
185 }
186
187 /* End of file Function.cpp */