| 1 | /* Roots_to_Spectrum.cpp |
| 2 | * |
| 3 | * Copyright (C) 2020 David Weenink |
| 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. See the GNU |
| 13 | * 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 "Roots_to_Spectrum.h"cxx . . $ `<file>/dwtools/Roots_to_Spectrum.h`/ |
| 20 | |
| 21 | autoSpectrumcxx . . $ autoSpectrum# Roots_to_Spectrumcxx . . $ Roots_to_Spectrum(e778858f9325d8b2). (constRootscxx . . $ constRoots# me, double nyquistFrequency, integercxx . . $ integer# numberOfFrequencies, double radius) { |
| 22 | try { |
| 23 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (numberOfFrequencies > 1, |
| 24 | U"Number of frequencies should be greater than 1."); |
| 25 | autoSpectrumcxx . . $ autoSpectrum# thee = Spectrum_createcxx . . $ Spectrum_create(a338b9c326abb5ed). (nyquistFrequency, numberOfFrequencies); |
| 26 | |
| 27 | const double phi = NUMpicxx . . $ NUMpi. / (numberOfFrequencies - 1); |
| 28 | dcomplexcxx . . $ dcomplex# zcxx . . $ std/complex#complex(bc12c9ec15586e6a).; |
| 29 | for (integercxx . . $ integer# i = 1; i <= numberOfFrequencies; i ++) { |
| 30 | z. realcxx . . $ std/complex#real(ba8836b59fb42830). (radius * coscxx . . $ cos(fee4f1d22bc8e617). ((i - 1) * phi)); |
| 31 | z. imagcxx . . $ std/complex#imag(ba8836b59fb42830). (radius * sincxx . . $ sin(fee4f1d22bc8e617). ((i - 1) * phi)); |
| 32 | const dcomplexcxx . . $ dcomplex# s = Roots_evaluate_zcxx . . $ Roots_evaluate_z(4c9654220d6c2563). (me, zcxx . . $ std/complex#complex(20ef1611af677bca).); |
| 33 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = s.realcxx . . $ std/complex#real(21b6c25e127938e2).(); |
| 34 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).2] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = s.imagcxx . . $ std/complex#imag(21b6c25e127938e2).(); |
| 35 | } |
| 36 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 37 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 38 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Spectrum calculated."); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /* End of file Roots.cpp */ |