Debian Codegraph @

fon/SampledXY.cpp

raw symbols SCIP
1 /* SampledXY.cpp
2 *
3 * Copyright (C) 1992-2017,2019,2021,2023 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 2 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 "SampledXY.h"cxx . . $ `<file>/fon/SampledXY.h`/
20
21 #include "oo_DESTROY.h"cxx . . $ `<file>/sys/oo_DESTROY.h`/
22 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
23 #include "oo_COPY.h"cxx . . $ `<file>/sys/oo_COPY.h`/
24 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
25 #include "oo_EQUAL.h"cxx . . $ `<file>/sys/oo_EQUAL.h`/
26 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
27 #include "oo_CAN_WRITE_AS_ENCODING.h"cxx . . $ `<file>/sys/oo_CAN_WRITE_AS_ENCODING.h`/
28 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
29 #include "oo_WRITE_TEXT.h"cxx . . $ `<file>/sys/oo_WRITE_TEXT.h`/
30 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
31 #include "oo_READ_TEXT.h"cxx . . $ `<file>/sys/oo_READ_TEXT.h`/
32 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
33 #include "oo_WRITE_BINARY.h"cxx . . $ `<file>/sys/oo_WRITE_BINARY.h`/
34 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
35 #include "oo_READ_BINARY.h"cxx . . $ `<file>/sys/oo_READ_BINARY.h`/
36 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
37 #include "oo_DESCRIPTION.h"cxx . . $ `<file>/sys/oo_DESCRIPTION.h`/
38 #include "SampledXY_def.h"cxx . . $ `<file>/fon/SampledXY_def.h`/
39
40 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (SampledXY, Sampled, 0);
41
42 /*
43 * CHECK
44 if (xmin > xmax || ymin > ymax) {
45 Melder_throw (U"xmax should be greater than xmax and ymax should be greater than ymin.");
46 }
47 if (nx < 1 || ny < 1) {
48 Melder_throw (U"nx and ny should be at least 1.");
49 }
50 if (dx <= 0 || dy <= 0) {
51 Melder_throw (U"dx and dy should be positive.");
52 }
53 }
54 */
55
56 void SampledXY_initcxx . . $ SampledXY_init(6070c73102fabd7). (SampledXY me,
57 double xmin, double xmax, integercxx . . $ integer# nx, double dx, double x1,
58 double ymin, double ymax, integercxx . . $ integer# ny, double dy, double y1)
59 {
60 Sampled_initcxx . . $ Sampled_init(5b6f70c633f31208). (me, xmin, xmax, nx, dx, x1);
61 mycxx . . $ `melder/melder.h:44:9`! ymin = ymin;
62 mycxx . . $ `melder/melder.h:44:9`! ymax = ymax;
63 mycxx . . $ `melder/melder.h:44:9`! ny = ny;
64 mycxx . . $ `melder/melder.h:44:9`! dy = dy;
65 mycxx . . $ `melder/melder.h:44:9`! y1 = y1;
66 }
67
68 integercxx . . $ integer# SampledXY_getWindowSamplesYcxx . . $ SampledXY_getWindowSamplesY(4302ed892b02b0fc). (
69 const constSampledXY me,
70 const double fromY,
71 const double toY,
72 integercxx . . $ integer# *const iymin,
73 integercxx . . $ integer# *const iymax
74 ) {
75 const double riymin = 1.0 + Melder_roundUpcxx . . $ Melder_roundUp(447c67c6676f75c3). ((fromY - mycxx . . $ `melder/melder.h:44:9`! y1) / mycxx . . $ `melder/melder.h:44:9`! dy);
76 const double riymax = 1.0 + Melder_roundDowncxx . . $ Melder_roundDown(447c67c6676f75c3). ((toY - mycxx . . $ `melder/melder.h:44:9`! y1) / mycxx . . $ `melder/melder.h:44:9`! dy); // could be above 32-bit LONG_MAX
77 *iymin = ( riymin < 1.0 ? 1 : (integercxx . . $ integer#) riymin );
78 *iymax = ( riymax > double (mycxx . . $ `melder/melder.h:44:9`! ny) ? mycxx . . $ `melder/melder.h:44:9`! ny : (integercxx . . $ integer#) riymax );
79 if (*iymin > *iymax)
80 return 0;
81 return *iymax - *iymin + 1;
82 }
83
84 void SampledXY_unidirectionalAutowindowYcxx . . $ SampledXY_unidirectionalAutowindowY(b6a531eed30bf40e). (
85 const constSampledXY me,
86 double *const ymin,
87 double *const ymax
88 ) {
89 if (*ymin >= *ymax) {
90 *ymin = mycxx . . $ `melder/melder.h:44:9`! ymin;
91 *ymax = mycxx . . $ `melder/melder.h:44:9`! ymax;
92 }
93 }
94 void SampledXY_bidirectionalAutowindowYcxx . . $ SampledXY_bidirectionalAutowindowY(b6a531eed30bf40e). (
95 const constSampledXY me,
96 double *const y1,
97 double *const y2
98 ) {
99 if (*y1 == *y2) {
100 *y1 = mycxx . . $ `melder/melder.h:44:9`! ymin;
101 *y2 = mycxx . . $ `melder/melder.h:44:9`! ymax;
102 }
103 }
104
105 /* End of file SampledXY.cpp */