| 1 | /* Praat_tests.cpp |
| 2 | * |
| 3 | * Copyright (C) 2001-2007,2009,2011-2026 Paul Boersma, David Weenink 2025 |
| 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 | /* December 10, 2006: MelderInfo */ |
| 20 | /* November 5, 2007: wchar */ |
| 21 | /* 21 March 2009: modern enums */ |
| 22 | /* 24 May 2011: C++ */ |
| 23 | /* 5 June 2015: char32 */ |
| 24 | |
| 25 | #include "FileInMemory.h"cxx . . $ `<file>/dwsys/FileInMemory.h`/ |
| 26 | #include "NUMselect.h"cxx . . $ `<file>/dwsys/NUMselect.h`/ |
| 27 | #include "SlopeSelector.h"cxx . . $ `<file>/dwsys/SlopeSelector.h`/ |
| 28 | #include "Praat_tests.h"cxx . . $ `<file>/fon/Praat_tests.h`/ |
| 29 | |
| 30 | #include "Graphics.h"cxx . . $ `<file>/sys/Graphics.h`/ |
| 31 | #include "praat.h"cxx . . $ `<file>/sys/praat.h`/ |
| 32 | #include "NUM2.h"cxx . . $ `<file>/dwsys/NUM2.h`/ |
| 33 | #include "Sound.h"cxx . . $ `<file>/fon/Sound.h`/ |
| 34 | |
| 35 | #include "enums_getText.h"cxx . . $ `<file>/melder/enums_getText.h`/ |
| 36 | #include "Praat_tests_enums.h"cxx . . $ `<file>/fon/Praat_tests_enums.h`/ |
| 37 | #include "enums_getValue.h"cxx . . $ `<file>/melder/enums_getValue.h`/ |
| 38 | #include "Praat_tests_enums.h"cxx . . $ `<file>/fon/Praat_tests_enums.h`/ |
| 39 | #include <string> |
| 40 | |
| 41 | #include "Gui.h"cxx . . $ `<file>/sys/Gui.h`/ |
| 42 | |
| 43 | static void testAutoDatacxx . . $ testAutoData(90806586bd778ea4). (autoDaatacxx . . $ autoDaata# data) { |
| 44 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "testAutoData: %p %p\n", data.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), data ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 45 | } |
| 46 | static void testAutoDataRefcxx . . $ testAutoDataRef(c2a0858c211a52c). (autoDaatacxx . . $ autoDaata#& data) { |
| 47 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "testAutoDataRef: %p %p\n", data.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), data ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 48 | } |
| 49 | static void testDatacxx . . $ testData(fde123624714e72). (Daatacxx . . $ Daata# data) { |
| 50 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "testData: %p %s\n", data, Melder_peek32to8 (data -> namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).())); |
| 51 | } |
| 52 | static autoDaatacxx . . $ autoDaata# newAutoDatacxx . . $ newAutoData(3481808043203226). () { |
| 53 | autoDaatacxx . . $ autoDaata# data (Thing_newcxx . . $ `sys/Thing.h:514:9`! (Daata)); |
| 54 | return datacxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 55 | } |
| 56 | static integercxx . . $ integer# lengthcxx . . $ length(c94c67ff4219bf83). (conststring32cxx . . $ conststring32# s) { |
| 57 | const integercxx . . $ integer# result = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (s); |
| 58 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (s); |
| 59 | return result; |
| 60 | } |
| 61 | |
| 62 | static autoMATcxx . . $ autoMAT# constantHHcxx . . $ constantHH(a0e6b03cd16b106f). (integercxx . . $ integer# nrow, integercxx . . $ integer# ncol, double value) { |
| 63 | autoMATcxx . . $ autoMAT# result = raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (nrow, ncol); |
| 64 | result.allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(50b469ae42a42f64). value; |
| 65 | return resultcxx . . $ automatrix#automatrix(a69681c49ef9c9eb).; |
| 66 | } |
| 67 | |
| 68 | int Praat_testscxx . . $ Praat_tests(ffd623fe04640280). (kPraatTests itest, conststring32cxx . . $ conststring32# arg1, conststring32cxx . . $ conststring32# arg2, conststring32cxx . . $ conststring32# arg3, conststring32cxx . . $ conststring32# arg4) { |
| 69 | int64cxx . . $ int64# n = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg1); |
| 70 | double t = 0.0; |
| 71 | (void) arg1; |
| 72 | (void) arg2; |
| 73 | (void) arg3; |
| 74 | (void) arg4; |
| 75 | Melder_clearInfocxx . . $ Melder_clearInfo(49f6e7a06ebc5aa8). (); |
| 76 | Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 77 | switch (itest) { |
| 78 | case kPraatTests::UNDEFINED: |
| 79 | case kPraatTests::_: |
| 80 | case kPraatTests::CHECK_RANDOM_1009_2009: { |
| 81 | } break; |
| 82 | case kPraatTests::TIME_RANDOM_FRACTION: { |
| 83 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) |
| 84 | (void) NUMrandomFractioncxx . . $ NUMrandomFraction(31fa7155c10fdd13). (); |
| 85 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 86 | } break; |
| 87 | case kPraatTests::TIME_RANDOM_GAUSS: { |
| 88 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) |
| 89 | (void) NUMrandomGausscxx . . $ NUMrandomGauss(d8e7e0733fa41c87). (0.0, 1.0); |
| 90 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 91 | } break; |
| 92 | case kPraatTests::TIME_SORT: { |
| 93 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 94 | autoVECcxx . . $ autoVEC# array = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (size); |
| 95 | Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 96 | for (int64cxx . . $ int64# iteration = 1; iteration <= n; iteration ++) { |
| 97 | for (int64cxx . . $ int64# i = 1; i <= size; i ++) |
| 98 | array [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = NUMrandomFractioncxx . . $ NUMrandomFraction(31fa7155c10fdd13). (); |
| 99 | sort_e_VEC_inoutcxx . . $ sort_e_VEC_inout(e75f7985a5e05502). (array.getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 100 | } |
| 101 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / (size * log2cxx . . $ log2(7759b11ec49fe502). (size)); |
| 102 | } break; |
| 103 | case kPraatTests::TIME_INTEGER: { |
| 104 | int64cxx . . $ int64# sum = 0; |
| 105 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) |
| 106 | sum += i * (i - 1) * (i - 2); |
| 107 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 108 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 109 | } break; |
| 110 | case kPraatTests::TIME_FLOAT: { |
| 111 | double sum = 0.0, fn = n; |
| 112 | for (double fi = 1.0; fi <= fn; fi += 1.0) |
| 113 | sum += fi * (fi - 1.0) * (fi - 2.0); |
| 114 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 2.02 ns |
| 115 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 116 | } break; |
| 117 | case kPraatTests::TIME_FLOAT_TO_UNSIGNED_BUILTIN: { |
| 118 | uint64cxx . . $ uint64# sum = 0; |
| 119 | double fn = n; |
| 120 | for (double fi = 1.0; fi <= fn; fi += 1.0) |
| 121 | sum += (uint32cxx . . $ uint32#) fi; |
| 122 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 1.45 ns |
| 123 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 124 | } break; |
| 125 | case kPraatTests::TIME_FLOAT_TO_UNSIGNED_EXTERN: { |
| 126 | uint64cxx . . $ uint64# sum = 0; |
| 127 | double fn = n; |
| 128 | for (double fi = 1.0; fi <= fn; fi += 1.0) |
| 129 | sum += (uint32cxx . . $ uint32#) ((int32cxx . . $ int32#) (fi - 2147483648.0) + 2147483647L + 1); |
| 130 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 1.47 ns |
| 131 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 132 | } break; |
| 133 | case kPraatTests::TIME_UNSIGNED_TO_FLOAT_BUILTIN: { |
| 134 | double sum = 0.0; |
| 135 | uint32cxx . . $ uint32# nu = (uint32cxx . . $ uint32#) n; |
| 136 | for (uint32cxx . . $ uint32# iu = 1; iu <= nu; iu ++) |
| 137 | sum += (double) iu; |
| 138 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 0.88 ns |
| 139 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 140 | } break; |
| 141 | case kPraatTests::TIME_UNSIGNED_TO_FLOAT_EXTERN: { |
| 142 | double sum = 0.0; |
| 143 | uint32cxx . . $ uint32# nu = (uint32cxx . . $ uint32#) n; |
| 144 | for (uint32cxx . . $ uint32# iu = 1; iu <= nu; iu ++) |
| 145 | sum += (double) (int32cxx . . $ int32#) (iu - 2147483647L - 1) + 2147483648.0; |
| 146 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 0.87 ns |
| 147 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 148 | } break; |
| 149 | case kPraatTests::TIME_STRING_MELDER_32: { |
| 150 | autoMelderStringcxx . . $ autoMelderString# stringcxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).; |
| 151 | char32cxx . . $ char32# word [] { U"abc" }; |
| 152 | word [2] = char32cxx . . $ char32# (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (U'a', U'z')); |
| 153 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 154 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& string, word); |
| 155 | for (int j = 1; j <= 30; j ++) |
| 156 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& string, word); |
| 157 | } |
| 158 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 159 | } break; |
| 160 | case kPraatTests::TIME_STRING_MELDER_32_ALLOC: { |
| 161 | char32cxx . . $ char32# word [] { U"abc" }; |
| 162 | word [2] = char32cxx . . $ char32# (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (U'a', U'z')); |
| 163 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 164 | autoMelderStringcxx . . $ autoMelderString# stringcxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).; |
| 165 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& string, word); |
| 166 | for (int j = 1; j <= 30; j ++) |
| 167 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& string, word); |
| 168 | } |
| 169 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 170 | } break; |
| 171 | case kPraatTests::TIME_STRING_CPP_S: { |
| 172 | stdcxx . . $ std/::stringcxx . . $ std/string# s = ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 173 | char word [] { "abc" }; |
| 174 | word [2] = char (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). ('a', 'z')); |
| 175 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 176 | s =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). word; |
| 177 | for (int j = 1; j <= 30; j ++) |
| 178 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). word; |
| 179 | } |
| 180 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 181 | } break; |
| 182 | case kPraatTests::TIME_STRING_CPP_C: { |
| 183 | stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<char> s = ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 184 | char word [] { "abc" }; |
| 185 | word [2] = char (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). ('a', 'z')); |
| 186 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 187 | s =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). word; |
| 188 | for (int j = 1; j <= 30; j ++) |
| 189 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). word; |
| 190 | } |
| 191 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 192 | } break; |
| 193 | case kPraatTests::TIME_STRING_CPP_WS: { |
| 194 | stdcxx . . $ std/::wstringcxx . . $ std/wstring# s = L""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 195 | wchar_t word [] { L"abc" }; |
| 196 | word [2] = wchar_t (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (L'a', L'z')); |
| 197 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 198 | s =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). word; |
| 199 | for (int j = 1; j <= 30; j ++) |
| 200 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). word; |
| 201 | } |
| 202 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 203 | } break; |
| 204 | case kPraatTests::TIME_STRING_CPP_WC: { |
| 205 | stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<wchar_t> s = L""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 206 | wchar_t word [] { L"abc" }; |
| 207 | word [2] = wchar_t (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (L'a', L'z')); |
| 208 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 209 | s =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). word; |
| 210 | for (int j = 1; j <= 30; j ++) |
| 211 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). word; |
| 212 | } |
| 213 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 214 | } break; |
| 215 | case kPraatTests::TIME_STRING_CPP_32: { |
| 216 | stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<char32_t> s = U""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 217 | char32cxx . . $ char32# word [] { U"abc" }; |
| 218 | word [2] = char32cxx . . $ char32# (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (U'a', U'z')); |
| 219 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 220 | s =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). word; |
| 221 | for (int j = 1; j <= 30; j ++) |
| 222 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). word; |
| 223 | } |
| 224 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 225 | } break; |
| 226 | case kPraatTests::TIME_STRING_CPP_U32STRING: { |
| 227 | stdcxx . . $ std/::u32stringcxx . . $ std/u32string# s = U""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 228 | char32cxx . . $ char32# word [] { U"abc" }; |
| 229 | word [2] = char32cxx . . $ char32# (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (U'a', U'z')); |
| 230 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 231 | s =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). word; |
| 232 | for (int j = 1; j <= 30; j ++) |
| 233 | s +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). word; |
| 234 | } |
| 235 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 236 | } break; |
| 237 | case kPraatTests::TIME_STRCPY: { |
| 238 | char buffer [100]; |
| 239 | char word [] { "abc" }; |
| 240 | word [2] = (char) NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). ('a', 'z'); |
| 241 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 242 | strcpy (buffer, word); |
| 243 | for (int j = 1; j <= 30; j ++) |
| 244 | strcpy (buffer + strlen (buffer), word); |
| 245 | } |
| 246 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 247 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (Melder_peek8to32_u (buffer)); |
| 248 | } break; |
| 249 | case kPraatTests::TIME_WCSCPY: { |
| 250 | wchar_t buffer [100]; |
| 251 | wchar_t word [] { L"abc" }; |
| 252 | word [2] = wchar_t (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (L'a', L'z')); |
| 253 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 254 | wcscpy (buffer, word); |
| 255 | for (int j = 1; j <= 30; j ++) |
| 256 | wcscpy (buffer + wcslen (buffer), word); |
| 257 | } |
| 258 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 259 | } break; |
| 260 | case kPraatTests::TIME_STR32CPY: { |
| 261 | char32cxx . . $ char32# buffer [100]; |
| 262 | char32cxx . . $ char32# word [] { U"abc" }; |
| 263 | word [2] = char32cxx . . $ char32# (NUMrandomIntegercxx . . $ NUMrandomInteger(d0a0e4c270da0eca). (U'a', U'z')); |
| 264 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 265 | str32cpycxx . . $ str32cpy(6ab934322573b179). (buffer, word); |
| 266 | for (int j = 1; j <= 30; j ++) |
| 267 | str32cpycxx . . $ str32cpy(6ab934322573b179). (buffer + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (buffer), word); |
| 268 | } |
| 269 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 270 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (buffer); |
| 271 | } break; |
| 272 | case kPraatTests::TIME_GRAPHICS_TEXT_TOP: { |
| 273 | autoPraatPictureOpencxx . . $ autoPraatPictureOpen# picturecxx . . $ autoPraatPictureOpen#autoPraatPictureOpen(49f6e7a06ebc5aa8).; |
| 274 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 275 | Graphics_textTopcxx . . $ Graphics_textTop(48cf1f690ec61203). (GRAPHICScxx . . $ `sys/praat.h:204:9`!, false, U"hello world"); |
| 276 | } |
| 277 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 278 | } break; |
| 279 | case kPraatTests::TIME_UNDEFINED_NUMUNDEFINED: { |
| 280 | bool isAllDefined = true; |
| 281 | double x = 0.0; |
| 282 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 283 | x += (double) i; |
| 284 | isAllDefined &= ( x != undefinedcxx . . $ undefined. ); |
| 285 | } |
| 286 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 0.86 ns |
| 287 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (isAllDefined, U" ", x); |
| 288 | } break; |
| 289 | case kPraatTests::TIME_UNDEFINED_ISINF_OR_ISNAN: { |
| 290 | bool isAllDefined = true; |
| 291 | double x = 0.0; |
| 292 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 293 | x += (double) i; |
| 294 | isAllDefined &= ! isinfcxx . . $ isinf(f8197d536af80c96). (x) && ! isnancxx . . $ isnan(f8197d536af80c96). (x); |
| 295 | //isAllDefined &= ! isfinite (x); // same |
| 296 | } |
| 297 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 1.29 ns |
| 298 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (isAllDefined, U" ", x); |
| 299 | } break; |
| 300 | case kPraatTests::TIME_UNDEFINED_0x7FF: { |
| 301 | bool isAllDefined = true; |
| 302 | double x = 0.0; |
| 303 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 304 | x += (double) i; |
| 305 | isAllDefined &= ((* (uint64cxx . . $ uint64# *) & x) & 0x7FF0'0000'0000'0000) != 0x7FF0'0000'0000'0000; |
| 306 | } |
| 307 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 0.90 ns |
| 308 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (isAllDefined, U" ", x); |
| 309 | } break; |
| 310 | case kPraatTests::TIME_INNER: { |
| 311 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 312 | autoVECcxx . . $ autoVEC# x = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (size, 0.0, 1.0); |
| 313 | autoVECcxx . . $ autoVEC# y = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (size, 0.0, 1.0); |
| 314 | double z = 0.0; |
| 315 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) |
| 316 | z += NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), ycxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 317 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; // 2.9 Gops = 5.8 Gflops (multiplication-addition pair) |
| 318 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (z); |
| 319 | } break; |
| 320 | case kPraatTests::TIME_OUTER_NUMMAT: { |
| 321 | integercxx . . $ integer# nrow = 100, ncol = 100; |
| 322 | autoVECcxx . . $ autoVEC# x = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (nrow, 0.0, 1.0); |
| 323 | autoVECcxx . . $ autoVEC# y = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (ncol, 0.0, 1.0); |
| 324 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) |
| 325 | const autoMATcxx . . $ autoMAT# mat = outer_MATcxx . . $ outer_MAT(aaaa557e9be1882f). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), ycxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 326 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / nrow / ncol; // 6.1 Gops, i.e. less than one clock cycle per cell |
| 327 | } break; |
| 328 | case kPraatTests::CHECK_INVFISHERQ: { |
| 329 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (NUMinvFisherQcxx . . $ NUMinvFisherQ(7678bba071383ab). (0.003, 1, 100000)); |
| 330 | } break; |
| 331 | case kPraatTests::TIME_AUTOSTRING: { |
| 332 | conststring32cxx . . $ conststring32# strings [6] = { U"ghdg", U"jhd", U"hkfjjd", U"fhfj", U"jhksfd", U"hfjs" }; |
| 333 | int64cxx . . $ int64# sumOfLengths = 0; |
| 334 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 335 | int istring = i % 6; |
| 336 | autostring32cxx . . $ autostring32# s = Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (strings [istring]); |
| 337 | sumOfLengths += lengthcxx . . $ length(c94c67ff4219bf83). (s.transfercxx . . $ _autostring#transfer(155dc7f103cdb9db).()); |
| 338 | } |
| 339 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 72 ns (but 152 bytes more) |
| 340 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sumOfLengths); |
| 341 | } break; |
| 342 | case kPraatTests::TIME_CHAR32: { |
| 343 | conststring32cxx . . $ conststring32# strings [6] = { U"ghdg", U"jhd", U"hkfjjd", U"fhfj", U"jhksfd", U"hfjs" }; |
| 344 | int64cxx . . $ int64# sumOfLengths = 0; |
| 345 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 346 | int istring = i % 6; |
| 347 | char32cxx . . $ char32# *s = Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (strings [istring]).transfercxx . . $ _autostring#transfer(155dc7f103cdb9db).(); |
| 348 | sumOfLengths += lengthcxx . . $ length(c94c67ff4219bf83). (s); |
| 349 | } |
| 350 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // 72 ns |
| 351 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sumOfLengths); |
| 352 | } break; |
| 353 | case kPraatTests::TIME_SUM: { |
| 354 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 355 | autoVECcxx . . $ autoVEC# x = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (size, 0.0, 1.0); |
| 356 | double z = 0.0; |
| 357 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 358 | double sum = NUMsumcxx . . $ NUMsum(4bb9c3e3a8dd5442). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 359 | z += sum; |
| 360 | } |
| 361 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; // for size == 100: 0.31 ns |
| 362 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (z); |
| 363 | } break; |
| 364 | case kPraatTests::TIME_MEAN: { |
| 365 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 366 | autoVECcxx . . $ autoVEC# x = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (size, 0.0, 1.0); |
| 367 | double z = 0.0; |
| 368 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 369 | double sum = NUMmeancxx . . $ NUMmean(4bb9c3e3a8dd5442). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 370 | z += sum; |
| 371 | } |
| 372 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; // for size == 100: 0.34 ns |
| 373 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (z); |
| 374 | } break; |
| 375 | case kPraatTests::TIME_STDEV: { |
| 376 | integercxx . . $ integer# size = 10000; |
| 377 | autoVECcxx . . $ autoVEC# x = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (size, 0.0, 1.0); |
| 378 | double z = 0.0; |
| 379 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) { |
| 380 | double stdev = NUMstdevcxx . . $ NUMstdev(4bb9c3e3a8dd5442). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 381 | z += stdev; |
| 382 | } |
| 383 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; |
| 384 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (z); |
| 385 | } break; |
| 386 | case kPraatTests::TIME_ALLOC: { |
| 387 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 388 | for (int64cxx . . $ int64# iteration = 1; iteration <= n; iteration ++) { |
| 389 | autoVECcxx . . $ autoVEC# result = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (size); |
| 390 | for (integercxx . . $ integer# i = 1; i <= size; i ++) |
| 391 | result [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = 0.0; |
| 392 | } |
| 393 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; // 10^0..7: 70/6.9/1.08 / 0.074/0.0074/0.0091 / 0.51/0.00026 ns |
| 394 | } break; |
| 395 | case kPraatTests::TIME_ALLOC0: { |
| 396 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 397 | for (int64cxx . . $ int64# iteration = 1; iteration <= n; iteration ++) |
| 398 | autoVECcxx . . $ autoVEC# result = zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (size); |
| 399 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; // 10^0..7: 76/7.7/1.23 / 0.165/0.24/0.25 / 1.30/1.63 ns |
| 400 | } break; |
| 401 | case kPraatTests::TIME_ZERO: { |
| 402 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 403 | autoVECcxx . . $ autoVEC# result = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (size); |
| 404 | double z = 0.0; |
| 405 | for (int64cxx . . $ int64# iteration = 1; iteration <= n; iteration ++) { |
| 406 | for (integercxx . . $ integer# i = 1; i <= size; i ++) |
| 407 | result [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = (double) i; |
| 408 | z += result [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).size - 1]; |
| 409 | } |
| 410 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; |
| 411 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (z); |
| 412 | } break; |
| 413 | case kPraatTests::TIME_MALLOC: { |
| 414 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 415 | double value = Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (arg3); |
| 416 | double z = 0.0; |
| 417 | for (int64cxx . . $ int64# iteration = 1; iteration <= n; iteration ++) { |
| 418 | double *result = (double *) malloccxx . . $ malloc(9f008b2a9698428b). (sizeof (double) * (size_t) size); |
| 419 | for (integercxx . . $ integer# i = 0; i < size; i ++) |
| 420 | result [i] = value; |
| 421 | z += result [size / 2]; |
| 422 | freecxx . . $ free(bd21765a0afc8e3c). (result); |
| 423 | } |
| 424 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; |
| 425 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (z); |
| 426 | } break; |
| 427 | case kPraatTests::TIME_CALLOC: { |
| 428 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 429 | double z = 0.0; |
| 430 | for (integercxx . . $ integer# iteration = 1; iteration <= n; iteration ++) { |
| 431 | double *result = (double *) calloccxx . . $ calloc(95acc9b79bb49189). (sizeof (double), (size_t) size); |
| 432 | z += result [size / 2]; |
| 433 | freecxx . . $ free(bd21765a0afc8e3c). (result); |
| 434 | } |
| 435 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; |
| 436 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (z); |
| 437 | } break; |
| 438 | case kPraatTests::TIME_ADD: { |
| 439 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 440 | autoMATcxx . . $ autoMAT# result = randomGauss_MATcxx . . $ randomGauss_MAT(58e174d0e2ab475a). (size, size, 0.0, 1.0); |
| 441 | Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 442 | for (integercxx . . $ integer# iteration = 1; iteration <= n; iteration ++) |
| 443 | result.allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(50b469ae42a42f64). 5.0; |
| 444 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size / size; // 10^0..4: 2.7/0.16/0.24 / 0.38/0.98 |
| 445 | double sum = NUMsumcxx . . $ NUMsum(98ed2a492958fa8a). (resultcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 446 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 447 | } break; |
| 448 | case kPraatTests::TIME_SIN: { |
| 449 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 450 | autoMATcxx . . $ autoMAT# result = randomGauss_MATcxx . . $ randomGauss_MAT(58e174d0e2ab475a). (size, size, 0.0, 1.0); |
| 451 | Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 452 | for (integercxx . . $ integer# iteration = 1; iteration <= n; iteration ++) |
| 453 | sin_MAT_inoutcxx . . $ sin_MAT_inout(5dd9f6ea610bc98c). (resultcxx . . $ matrixview#matrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 454 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size / size; // 10^0..4: 18/5.3/5.2 / 5.3/12 |
| 455 | double sum = NUMsumcxx . . $ NUMsum(98ed2a492958fa8a). (resultcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 456 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 457 | } break; |
| 458 | case kPraatTests::TIME_VECADD: { |
| 459 | integercxx . . $ integer# size = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 460 | autoVECcxx . . $ autoVEC# x = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (size, 0.0, 1.0); |
| 461 | autoVECcxx . . $ autoVEC# y = randomGauss_VECcxx . . $ randomGauss_VEC(7b2b1b50b990c650). (size, 0.0, 1.0); |
| 462 | autoVECcxx . . $ autoVEC# result = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (size); |
| 463 | Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 464 | for (integercxx . . $ integer# iteration = 1; iteration <= n; iteration ++) |
| 465 | //add_VEC_out (result.all(), x.all(), y.all()); |
| 466 | result.allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(6ae1e3b199c5b085). xcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).() +cxx . . $ operator+(5e695a3bee7ea816). ycxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(); |
| 467 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / size; |
| 468 | double sum = NUMsumcxx . . $ NUMsum(4bb9c3e3a8dd5442). (resultcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 469 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum); |
| 470 | } break; |
| 471 | case kPraatTests::TIME_MATMUL: { |
| 472 | const integercxx . . $ integer# size1 = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg2); |
| 473 | integercxx . . $ integer# size2 = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg3); |
| 474 | integercxx . . $ integer# size3 = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (arg4); |
| 475 | if (size2 == 0 || size3 == 0) size3 = size2 = size1; |
| 476 | //autoMAT const x = randomGauss_MAT (size1, size2, 0.0, 1.0); |
| 477 | //autoMAT const y = randomGauss_MAT (size2, size3, 0.0, 1.0); |
| 478 | autoMATcxx . . $ autoMAT# x = constantHHcxx . . $ constantHH(a0e6b03cd16b106f). (size1, size2, 10.0); |
| 479 | autoMATcxx . . $ autoMAT# y = constantHHcxx . . $ constantHH(a0e6b03cd16b106f). (size2, size3, 3.0); |
| 480 | autoMATcxx . . $ autoMAT# const result = raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (size1, size3); |
| 481 | //MAT resultget = result.get(); |
| 482 | //constMAT xget = x.get(), yget = y.get(); |
| 483 | MATVUcxx . . $ MATVU# const result_all = result.allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 484 | constMATVUcxx . . $ constMATVU# const x_all = xcxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58)..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 485 | constMATVUcxx . . $ constMATVU# const y_all = ycxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58)..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 486 | Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); |
| 487 | for (integercxx . . $ integer# iteration = 1; iteration <= n; iteration ++) |
| 488 | //MATmul_forceMetal_ (result_all, x_all, y_all); |
| 489 | _mul_allowAllocation_MAT_outcxx . . $ _mul_allowAllocation_MAT_out(4e78c3c576663480). (result_all, x_all, y_all); |
| 490 | const integercxx . . $ integer# numberOfComputations = size1 * size2 * size3 * 2; |
| 491 | t = Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). () / numberOfComputations; |
| 492 | const double sum = NUMsumcxx . . $ NUMsum(98ed2a492958fa8a). (resultcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 493 | const integercxx . . $ integer# numberOfStores = size1 * size2 + size2 * size3 + size1 * size3 + 10000; |
| 494 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (double (numberOfComputations) / double (numberOfStores), U" computations per store"); |
| 495 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (sum, U" should be ", size1 * size2 * size3 * 30.0); |
| 496 | //Melder_require (NUMequal (result.get(), constantHH (size, size, size * 30.0).get()), U"..."); |
| 497 | } break; |
| 498 | case kPraatTests::THING_AUTO: { |
| 499 | integercxx . . $ integer# numberOfThingsBefore = theTotalNumberOfThingscxx . . $ theTotalNumberOfThings.; |
| 500 | { |
| 501 | Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"1\n"); |
| 502 | autoDaatacxx . . $ autoDaata# data = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Daata); |
| 503 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (data.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"hello"); |
| 504 | Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"2\n"); |
| 505 | testDatacxx . . $ testData(fde123624714e72). (data.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 506 | testAutoDatacxx . . $ testAutoData(90806586bd778ea4). (datacxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 507 | autoDaatacxx . . $ autoDaata# data18 = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Daata); |
| 508 | testAutoDatacxx . . $ testAutoData(90806586bd778ea4). (data18cxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 509 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "3\n"); |
| 510 | autoDaatacxx . . $ autoDaata# data2 = newAutoDatacxx . . $ newAutoData(3481808043203226). (); |
| 511 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "4\n"); |
| 512 | autoDaatacxx . . $ autoDaata# data3 = newAutoDatacxx . . $ newAutoData(3481808043203226). (); |
| 513 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "5\n"); |
| 514 | //data2 = data; // disabled l-value copy assignment from same class |
| 515 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "6\n"); |
| 516 | autoOrderedcxx . . $ autoOrdered# ordered = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Ordered); |
| 517 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "7\n"); |
| 518 | //data = ordered; // disabled l-value copy assignment from subclass |
| 519 | data =cxx . . $ autoSomeThing#`operator=`(ed6a1a4da6aedae3). ordered.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 520 | //ordered = data; // disabled l-value copy assignment from superclass |
| 521 | //ordered = data.move(); // assignment from superclass to subclass is rightfully refused by compiler |
| 522 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "8\n"); |
| 523 | data2 =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). newAutoDatacxx . . $ newAutoData(3481808043203226). (); |
| 524 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "8a\n"); |
| 525 | autoDaatacxx . . $ autoDaata# data5 = newAutoDatacxx . . $ newAutoData(3481808043203226). (); |
| 526 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "8b\n"); |
| 527 | data2 =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). data5.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 528 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "9\n"); |
| 529 | //ordered = data; // rightfully refused by compiler |
| 530 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "10\n"); |
| 531 | //autoOrdered ordered2 = Thing_new (Daata); // rightfully refused by compiler |
| 532 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "11\n"); |
| 533 | autoDaatacxx . . $ autoDaata# data4 = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Ordered); // constructor |
| 534 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "12\n"); |
| 535 | //autoDaata data6 = data4; // disabled l-value copy constructor from same class |
| 536 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "13\n"); |
| 537 | autoDaatacxx . . $ autoDaata# data7 = data4cxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 538 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "14\n"); |
| 539 | autoOrderedcxx . . $ autoOrdered# ordered3 = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Ordered); |
| 540 | autoDaatacxx . . $ autoDaata# data8 = ordered3cxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 541 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "15\n"); |
| 542 | //autoDaata data9 = ordered; // disabled l-value copy constructor from subclass |
| 543 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "16\n"); |
| 544 | autoDaatacxx . . $ autoDaata# data10 = data7cxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 545 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "17\n"); |
| 546 | autoDaatacxx . . $ autoDaata# data11 = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Daata); // constructor, move assignment, null destructor |
| 547 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "18\n"); |
| 548 | data11 =cxx . . $ autoSomeThing#`operator=`(ed6a1a4da6aedae3). Thing_newcxx . . $ `sys/Thing.h:514:9`! (Ordered); |
| 549 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "19\n"); |
| 550 | testAutoDataRefcxx . . $ testAutoDataRef(c2a0858c211a52c). (data11); |
| 551 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "20\n"); |
| 552 | //data11 = nullptr; // disabled implicit assignment of pointer to autopointer |
| 553 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "21\n"); |
| 554 | } |
| 555 | integercxx . . $ integer# numberOfThingsAfter = theTotalNumberOfThingscxx . . $ theTotalNumberOfThings.; |
| 556 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Number of things: before %td, after %td\n", numberOfThingsBefore, numberOfThingsAfter); |
| 557 | #if 0 |
| 558 | MelderCallback<void,structDaata>::FunctionType f; |
| 559 | typedef void (*DataFunc) (Daata); |
| 560 | typedef void (*OrderedFunc) (Ordered); |
| 561 | DataFunc dataFun; |
| 562 | OrderedFunc orderedFun; |
| 563 | MelderCallback<void,structDaata> dataFun2 (dataFun); |
| 564 | MelderCallback<void,structOrdered> orderedFun2 (orderedFun); |
| 565 | MelderCallback<void,structDaata> dataFun3 (orderedFun); |
| 566 | //MelderCallback<void,structOrdered> orderedFun3 (dataFun); // rightfully refused by compiler |
| 567 | autoDaata data = Thing_new (Daata); |
| 568 | dataFun3 (data.get()); |
| 569 | #endif |
| 570 | { |
| 571 | #if 1 |
| 572 | autoMelderAsynchronouscxx . . $ autoMelderAsynchronous# xcxx . . $ autoMelderAsynchronous#autoMelderAsynchronous(49f6e7a06ebc5aa8).; |
| 573 | //autoMelderAsynchronous y = x; // deleted copy constructor |
| 574 | autoMelderAsynchronouscxx . . $ autoMelderAsynchronous# y = xcxx . . $ autoMelderAsynchronous#autoMelderAsynchronous(1d40144796052bd3)..movecxx . . $ autoMelderAsynchronous#move(d73893df1bc7c24c).(); // defined move constructor |
| 575 | //x = y; // deleted copy assignment |
| 576 | x =cxx . . $ autoMelderAsynchronous#`operator=`(ff77b214ffb9dc91). y.movecxx . . $ autoMelderAsynchronous#move(d73893df1bc7c24c).(); // defined move assignment |
| 577 | autoVECcxx . . $ autoVEC# acxx . . $ autovector#autovector(49f6e7a06ebc5aa8).; |
| 578 | autoVECcxx . . $ autoVEC# b = acxx . . $ autovector#autovector(d33c649a3aceae2f)..movecxx . . $ autovector#move(57d90d7d77dfc011).(); |
| 579 | const autoVECcxx . . $ autoVEC# ccxx . . $ autovector#autovector(49f6e7a06ebc5aa8).; |
| 580 | const autoVECcxx . . $ autoVEC# dcxx . . $ autovector#autovector(49f6e7a06ebc5aa8). { }; |
| 581 | #if 0 |
| 582 | double *e; |
| 583 | const autoVEC f { e, 10 }; |
| 584 | #endif |
| 585 | { |
| 586 | autoVECcxx . . $ autoVEC# g = zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (100); |
| 587 | g [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] = 3.0; |
| 588 | VECcxx . . $ VEC# gg = g.getcxx . . $ autovector#get(e8d1da7fe68a6585).(); |
| 589 | gg [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] = 4.0; |
| 590 | constVECcxx . . $ constVEC# ggg = gcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(); |
| 591 | //ggg [3] = 5.0; // should be refused by the compiler |
| 592 | const VECcxx . . $ VEC# gggg = g.getcxx . . $ autovector#get(e8d1da7fe68a6585).(); |
| 593 | //gggg [3] = 6.0; // should be refused by the compiler |
| 594 | //return f; // call to deleted constructor |
| 595 | //gggg. reset(); // should be refused by the compiler |
| 596 | //ggg. reset(); // should be refused by the compiler |
| 597 | //gg. reset(); |
| 598 | } |
| 599 | { |
| 600 | double x [3], *px = & x [0]; |
| 601 | const double *cpx = px; |
| 602 | VECcxx . . $ VEC# vxcxx . . $ vector#vector(3aadefc30ed88664). (px, 2); |
| 603 | constVECcxx . . $ constVEC# cvxcxx . . $ constvector#constvector(be07d762837ca876). (px, 2); |
| 604 | const VECcxx . . $ VEC# c_vxcxx . . $ vector#vector(3aadefc30ed88664). (px, 2); |
| 605 | double a = c_vx [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 606 | const double b = c_vx [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2]; |
| 607 | const double y = 0.0, *py = & y; |
| 608 | //VEC vy (py, 0); // ruled out: "No matching constructor for initialization of VEC" (2021-04-03) |
| 609 | constVECcxx . . $ constVEC# cvycxx . . $ constvector#constvector(be07d762837ca876). { py, 2 }; |
| 610 | //const VEC c_vy = VEC (py, 2); // ruled out: "No matching constructor for initialization of VEC" (2021-04-03) |
| 611 | const VECcxx . . $ VEC# c_vy = (const VECcxx . . $ VEC#) VECcxx . . $ vector#vector(3aadefc30ed88664). (const_cast<double *> (py), 2); |
| 612 | double c = c_vy [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 613 | const double d = c_vy [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2]; |
| 614 | //VEC c_vy2 = VEC (py, 2); // ruled out: "No matching constructor for initialization of VEC" (2021-04-03) |
| 615 | } |
| 616 | { |
| 617 | structSampledcxx . . $ structSampled# sampled {}; |
| 618 | structFunctioncxx . . $ structFunction# function {}; |
| 619 | structFunctioncxx . . $ structFunction# *pFunction = & sampled; |
| 620 | structSampledcxx . . $ structSampled# *pSampled = & sampled; |
| 621 | //structFunction **ppFunction = MelderPointerToPointerCast<structSampled> (& pFunction); // not allowed |
| 622 | structFunctioncxx . . $ structFunction# **ppSampled = MelderPointerToPointerCastcxx . . $ MelderPointerToPointerCast(dbf74c3543ec8cee).<structFunctioncxx . . $ structFunction#> (& pSampled); // allowed |
| 623 | } |
| 624 | { |
| 625 | const structSampledcxx . . $ structSampled# sampled {}; |
| 626 | const structFunctioncxx . . $ structFunction# function {}; |
| 627 | const structFunctioncxx . . $ structFunction# *const pFunction = & sampled; |
| 628 | const structSampledcxx . . $ structSampled# *const pSampled = & sampled; |
| 629 | const structFunctioncxx . . $ structFunction# *const *const ppFunction = & pFunction; |
| 630 | //const structFunction *const *const ppSampled = & pSampled; // forbidden |
| 631 | } |
| 632 | |
| 633 | VECcxx . . $ VEC# hcxx . . $ vector#vector(49f6e7a06ebc5aa8).; |
| 634 | autoVECcxx . . $ autoVEC# jcxx . . $ autovector#autovector(49f6e7a06ebc5aa8).; |
| 635 | //VEC jh = j; // ruled out: "No viable conversion from autoVEC to VEC" (2021-04-03) |
| 636 | //VEC zero = zero_VEC (10); // ruled out: "No viable conversion from autoVEC to VEC" (2021-04-03) |
| 637 | //constVEC zero = zero_VEC (10); // ruled out: "No viable conversion from autoVEC to constVEC" (2021-04-03) |
| 638 | //j = h; // ruled out: "No viable overloaded '='" (2021-04-03) |
| 639 | //h = j; // ruled out: "No viable overloaded '='" (2021-04-03) |
| 640 | //h = VEC (j); // ruled out: "No matching conversion for functional-style cast from autoVEC to VEC" (2021-04-03) |
| 641 | //VEC & jref = j; // ruled out: "Non-const lvalue reference to type VEC cannot bind to a value of unrelated type autoVEC" (2021-04-03) |
| 642 | VECcxx . . $ VEC# *ph = & h; |
| 643 | autoVECcxx . . $ autoVEC# *pj = & j; |
| 644 | //ph = pj; // correctly ruled out: Assigning to 'VEC' from incompatible type 'autoVEC' (2021-04-03) |
| 645 | //pj = ph; // correctly ruled out: "Assigning to 'autoVEC *' from incompatible type 'VEC *' (2021-04-03) |
| 646 | #endif |
| 647 | autoSoundcxx . . $ autoSound# sound = Sound_createcxx . . $ Sound_create(39ab106d6b9a0135). (1, 0.0, 1.0, 10000, 0.0001, 0.0); |
| 648 | sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_createcxx . . $ Sound_create(39ab106d6b9a0135). (1, 0.0, 1.0, 10000, 0.0001, 0.00005); |
| 649 | Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"hello ", sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx.); |
| 650 | autoSTRVECcxx . . $ autoSTRVEC# vcxx . . $ _autostringautovector#_autostringautovector(49f6e7a06ebc5aa8).; |
| 651 | mutablestring32cxx . . $ mutablestring32# *pm = v.peek2cxx . . $ _autostringautovector#peek2(3871cfe815cb200).(); |
| 652 | const mutablestring32cxx . . $ mutablestring32# *pcm = v.peek2cxx . . $ _autostringautovector#peek2(3871cfe815cb200).(); |
| 653 | //conststring32 *pc = v.peek2(); |
| 654 | const conststring32cxx . . $ conststring32# *pcc = v.peek2cxx . . $ _autostringautovector#peek2(3871cfe815cb200).(); |
| 655 | { |
| 656 | vectorcxx . . $ vector#<double> aacxx . . $ vector#vector(49f6e7a06ebc5aa8)., bbcxx . . $ vector#vector(49f6e7a06ebc5aa8).; |
| 657 | vectorcxx . . $ vector#<const double> aaccxx . . $ vector#vector(49f6e7a06ebc5aa8)., bbccxx . . $ vector#vector(49f6e7a06ebc5aa8).; |
| 658 | //aa = aac; |
| 659 | aa =cxx . . $ vector#`operator=`(958c14910af86093). bb; |
| 660 | aac =cxx . . $ vector#`operator=`(ba5876314dfedb9a). bbc; |
| 661 | //aac = aa; |
| 662 | bbc.cellscxx . . $ vector#cells. = bb.cellscxx . . $ vector#cells.; |
| 663 | } |
| 664 | } |
| 665 | } break; |
| 666 | case kPraatTests::FILEINMEMORY_IO: { |
| 667 | //Melder_throw (U"Cannot test FileInMemoryManager directly from Praat."); |
| 668 | test_FileInMemory_iocxx . . $ test_FileInMemory_io(49f6e7a06ebc5aa8). (); |
| 669 | } break; |
| 670 | case kPraatTests::TIME_MEDIAN: { |
| 671 | timeMediancxx . . $ timeMedian(49f6e7a06ebc5aa8). (); |
| 672 | // Gflops is --undefined-- |
| 673 | } break; |
| 674 | case kPraatTests::TIME_SLOPE_SELECTION: { |
| 675 | timeSlopeSelectioncxx . . $ timeSlopeSelection(49f6e7a06ebc5aa8). (); |
| 676 | // Gflops is --undefined-- |
| 677 | } break; |
| 678 | case kPraatTests::TIME_NS_DATE: { |
| 679 | #ifdef macintosh |
| 680 | NSDate *till = [NSDate dateWithTimeIntervalSinceNow: 1.0]; |
| 681 | integer count = 0; |
| 682 | while ([[NSDate date] compare: till] == NSOrderedAscending) |
| 683 | ++ count; |
| 684 | MelderInfo_writeLine (count, U" per second"); |
| 685 | #endif |
| 686 | } break; |
| 687 | case kPraatTests::TIME_MELDER_CLOCK: { |
| 688 | const double till = Melder_clockcxx . . $ Melder_clock(31fa7155c10fdd13).() + 1.0; |
| 689 | integercxx . . $ integer# count = 0; |
| 690 | while (Melder_clockcxx . . $ Melder_clock(31fa7155c10fdd13).() < till) |
| 691 | ++ count; |
| 692 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (count, U" per second"); |
| 693 | } break; |
| 694 | case kPraatTests::TIME_STOPWATCH: { |
| 695 | MelderStopwatchcxx . . $ MelderStopwatch# stopwatchcxx . . $ MelderStopwatch#MelderStopwatch(49f6e7a06ebc5aa8).; |
| 696 | for (int64cxx . . $ int64# i = 1; i <= n; i ++) |
| 697 | Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13).(); |
| 698 | t = stopwatch (cxx . . $ MelderStopwatch#`operator()`(31fa7155c10fdd13).); |
| 699 | } break; |
| 700 | } |
| 701 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (Melder_singlecxx . . $ Melder_single(f05d861d9dbec9b2). (t * 1e9 / n), U" nanoseconds per iteration"); |
| 702 | MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). (); |
| 703 | return 1; |
| 704 | } |
| 705 | |
| 706 | /* More compiler stuff */ |
| 707 | #if 1 |
| 708 | /* |
| 709 | Trying out inheritance without encapsulation... |
| 710 | Advantage: everything is a method; therefore, the Law of Demeter is satisfied idiomatically |
| 711 | Disadvantage: problematic encapsulation |
| 712 | */ |
| 713 | Thing_declarecxx . . $ `sys/Thing.h:51:9`! (Matrix_); |
| 714 | Thing_declarecxx . . $ `sys/Thing.h:51:9`! (Sound_); |
| 715 | Thing_declarecxx . . $ `sys/Thing.h:51:9`! (Pitch_); |
| 716 | |
| 717 | /* |
| 718 | The following two sets of files have to be included |
| 719 | in Pitch_to_Sound.cpp as well as in Sound_to_Pitch.cpp, |
| 720 | but can come in either order: |
| 721 | */ |
| 722 | |
| 723 | /* |
| 724 | Set 1: Pitch.h |
| 725 | */ |
| 726 | struct structPitch_cxx . . $ structPitch_# : structThingcxx . . $ structThing# { |
| 727 | double f0cxx . . $ structPitch_#f0.; |
| 728 | autoSound_cxx . . $ autoSound_# toSoundcxx . . $ structPitch_#toSound(3d253f49253bf08). (); // anti-encapsulation |
| 729 | }; |
| 730 | |
| 731 | /* |
| 732 | Set 2: Matrix.h followed by Sound.h |
| 733 | */ |
| 734 | struct structMatrix_cxx . . $ structMatrix_# : structThingcxx . . $ structThing# { |
| 735 | private: double xcxx . . $ structMatrix_#x., ycxx . . $ structMatrix_#y.; |
| 736 | public: double getXcxx . . $ structMatrix_#getX(31fa7155c10fdd13). () { return xcxx . . $ structMatrix_#x.; } |
| 737 | void setXcxx . . $ structMatrix_#setX(ba8836b59fb42830). (double newX) { xcxx . . $ structMatrix_#x. = newX; } |
| 738 | }; |
| 739 | struct structSound_cxx . . $ structSound_# : public structMatrix_cxx . . $ structMatrix_# { // the definition of structSound_ requires the prior definition of structMatrix_ |
| 740 | autoPitch_cxx . . $ autoPitch_# toPitchcxx . . $ structSound_#toPitch(f8a6c332f3939963). (); // anti-encapsulation |
| 741 | }; |
| 742 | |
| 743 | /* |
| 744 | The following two files are independent of each other: |
| 745 | */ |
| 746 | |
| 747 | /* |
| 748 | Pitch_to_Sound.cpp: |
| 749 | #include "Pitch.h" |
| 750 | #include "Sound.h" |
| 751 | */ |
| 752 | autoSound_cxx . . $ autoSound_# structPitch_cxx . . $ structPitch_#::toSoundcxx . . $ structPitch_#toSound(3d253f49253bf08). () { // this requires the prior definition of structPitch_ and the prior declaration of structSound_ |
| 753 | autoSound_cxx . . $ autoSound_# result = autoSound_cxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8). (); |
| 754 | result ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). setXcxx . . $ structMatrix_#setX(ba8836b59fb42830). (f0cxx . . $ structPitch_#f0.); // this requires the prior definition of structSound_ and structMatrix_ |
| 755 | return resultcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 756 | } |
| 757 | |
| 758 | /* |
| 759 | Sound_to_Pitch.cpp: |
| 760 | #include "Sound.h" |
| 761 | #include "Pitch.h" |
| 762 | */ |
| 763 | autoPitch_cxx . . $ autoPitch_# structSound_cxx . . $ structSound_#::toPitchcxx . . $ structSound_#toPitch(f8a6c332f3939963). () { // this requires the prior definition of structSound_ and the prior declaration of structPitch_ |
| 764 | double x = getXcxx . . $ structMatrix_#getX(31fa7155c10fdd13). (); // this requires the prior definition of structSound_ and structMatrix_ |
| 765 | autoPitch_cxx . . $ autoPitch_# result = autoPitch_cxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8). (); |
| 766 | result ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). f0cxx . . $ structPitch_#f0. = x; // this requires the prior definition of structPitch_ |
| 767 | return resultcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 768 | } |
| 769 | |
| 770 | #endif |
| 771 | |
| 772 | /* |
| 773 | An attempt to not have VEC and constVEC, but VEC and const VEC instead. |
| 774 | */ |
| 775 | |
| 776 | class Veccxx . . $ Vec# { |
| 777 | public: |
| 778 | double *atcxx . . $ Vec#at.; |
| 779 | integercxx . . $ integer# sizecxx . . $ Vec#size.; |
| 780 | const double *const_propagate_atcxx . . $ Vec#const_propagate_at(d06acfa185f8726d). () const { return atcxx . . $ Vec#at.; } |
| 781 | double *const_propagate_atcxx . . $ Vec#const_propagate_at(78c35135705b60d1). () { return atcxx . . $ Vec#at.; } |
| 782 | public: |
| 783 | Veccxx . . $ Vec#Vec(c2475c168577977b). (double *initialAt, integercxx . . $ integer# initialSize) : atcxx . . $ Vec#at. (initialAt), sizecxx . . $ Vec#size. (initialSize) { } |
| 784 | double& operatorcxx . . $ Vec#`operator[]`(1acea0b398ce0d09).[] (integercxx . . $ integer# index) { return atcxx . . $ Vec#at. [index]; } // selected for Vec (1) |
| 785 | const double& operatorcxx . . $ Vec#`operator[]`(25b950f411b6ae4d).[] (integercxx . . $ integer# index) const { return atcxx . . $ Vec#at. [index]; } // selected for const Vec (2) |
| 786 | //Vec (Vec& other) : at (other.const_propagate_at()), size (other.size) { }; // can assign Vec to Vec (3) |
| 787 | //Vec (Vec&& other) : at (other.at), size (other.size) { }; // can assign Vec to Vec (3) |
| 788 | Veccxx . . $ Vec#Vec(4757f803f4e8aefe). (Veccxx . . $ Vec#& other) : atcxx . . $ Vec#at. (other.atcxx . . $ Vec#at.), sizecxx . . $ Vec#size. (other.sizecxx . . $ Vec#size.) { }; // can assign Vec to Vec (3) |
| 789 | Veccxx . . $ Vec#Vec(b5f0e0dfa83c4b20). (const Veccxx . . $ Vec#& other) = delete; // cannot assign const Vec to Vec (4) |
| 790 | /* unfortunately, this also precludes initializing a *const* Vec from a const Vec */ |
| 791 | //Vec (const Vec& other) const = default; // attempt to copy a const Vec to a const Vec, but constructors cannot be const |
| 792 | //const Vec (const Vec& other) = default; // attempt to copy a const Vec to a const Vec, but constructors cannot have a return type |
| 793 | }; |
| 794 | |
| 795 | /*static void tryVec () { |
| 796 | Vec x = Vec (nullptr, 0); |
| 797 | x [1] = 3.0; |
| 798 | double a = x [2]; |
| 799 | const Vec cx = Vec (nullptr, 0); |
| 800 | //cx [1] = 3.0; // should be refused by compiler, because operator[] returns a const value that cannot be assigned to (2) |
| 801 | a = cx [2]; // should be allowed by compiler, because not an assignment (2) |
| 802 | const Vec cy = x; // should be allowed (3) |
| 803 | //Vec y = cx; // should be refused (4) |
| 804 | const Vec cz = copy (x); |
| 805 | //cx.at [1] = 3.0; |
| 806 | ////const Vec ca = cy; // should be allowed |
| 807 | }*/ |
| 808 | |
| 809 | /* End of file Praat_tests.cpp */ |