Debian Codegraph @

fon/Matrix_and_PointProcess.cpp

raw
1 /* Matrix_and_PointProcess.cpp
2 *
3 * Copyright (C) 1992-2005,2011,2015-2018,2026 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 "Matrix_and_PointProcess.h"
20
21 autoMatrix PointProcess_to_Matrix (PointProcess me) {
22 try {
23 if (my nt == 0)
24 Melder_throw (U"No times in PointProcess.");
25 autoMatrix you = Matrix_create (1.0, double (my nt), my nt, 1.0, 1.0, 1.0, 1.0, 1, 1.0, 1.0);
26 for (integer i = 1; i <= my nt; i ++)
27 your z [1] [i] = my t [i];
28 return you;
29 } catch (MelderError) {
30 Melder_throw (me, U": not converted to Matrix.");
31 }
32 }
33
34 autoPointProcess Matrix_to_PointProcess (Matrix me) {
35 try {
36 Melder_pre (my nx > 0);
37 Melder_pre (my ny > 0);
38 autoPointProcess you = PointProcess_create (my z [1] [1], my z [1] [my nx], my nx);
39 PointProcess_addPoints (you.get(), my z.get(). asvector());
40 your xmin = your t [1];
41 your xmax = your t [your nt];
42 // TODO: problematic case: one point only, because then `your xmin == your xmax`
43 // TODO: problematic case: multiple identical times (responsibility of `PointProcess_addPoints`)
44 return you;
45 } catch (MelderError) {
46 Melder_throw (me, U": not converted to PointProcess.");
47 }
48 }
49
50 /* End of file Matrix_and_PointProcess.cpp */