diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-14 10:35:25 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-16 11:40:23 -0800 |
commit | 967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch) | |
tree | 8a24954b54d1546dc8049a17e485adb0a605f74f /host/examples/wavetable.hpp | |
parent | aafe4e8b742a0e21d3818f21f34e3c8613132530 (diff) | |
download | uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.gz uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.bz2 uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.zip |
uhd: mpm: apply clang-format to all files
Applying formatting changes to all .cpp and .hpp files in the following
directories:
```
find host/examples/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/tests/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/utils/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find mpm/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
```
Also formatted host/include/, except Cpp03 was used as a the language
standard instead of Cpp11.
```
sed -i 's/ Cpp11/ Cpp03/g' .clang-format
find host/include/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
```
Formatting style was designated by the .clang-format file.
Diffstat (limited to 'host/examples/wavetable.hpp')
-rw-r--r-- | host/examples/wavetable.hpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/host/examples/wavetable.hpp b/host/examples/wavetable.hpp index 8fdc8db30..2a1d13f48 100644 --- a/host/examples/wavetable.hpp +++ b/host/examples/wavetable.hpp @@ -5,55 +5,51 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include <string> #include <cmath> #include <complex> -#include <vector> #include <stdexcept> +#include <string> +#include <vector> static const size_t wave_table_len = 8192; -class wave_table_class{ +class wave_table_class +{ public: - wave_table_class(const std::string &wave_type, const float ampl): - _wave_table(wave_table_len) + wave_table_class(const std::string& wave_type, const float ampl) + : _wave_table(wave_table_len) { - //compute real wave table with 1.0 amplitude + // compute real wave table with 1.0 amplitude std::vector<float> real_wave_table(wave_table_len); - if (wave_type == "CONST"){ + if (wave_type == "CONST") { for (size_t i = 0; i < wave_table_len; i++) real_wave_table[i] = 1.0; - } - else if (wave_type == "SQUARE"){ + } else if (wave_type == "SQUARE") { for (size_t i = 0; i < wave_table_len; i++) - real_wave_table[i] = (i < wave_table_len/2)? 0.0 : 1.0; - } - else if (wave_type == "RAMP"){ + real_wave_table[i] = (i < wave_table_len / 2) ? 0.0 : 1.0; + } else if (wave_type == "RAMP") { for (size_t i = 0; i < wave_table_len; i++) - real_wave_table[i] = 2.0*i/(wave_table_len-1) - 1.0; - } - else if (wave_type == "SINE"){ - static const double tau = 2*std::acos(-1.0); + real_wave_table[i] = 2.0 * i / (wave_table_len - 1) - 1.0; + } else if (wave_type == "SINE") { + static const double tau = 2 * std::acos(-1.0); for (size_t i = 0; i < wave_table_len; i++) - real_wave_table[i] = std::sin((tau*i)/wave_table_len); - } - else throw std::runtime_error("unknown waveform type: " + wave_type); + real_wave_table[i] = std::sin((tau * i) / wave_table_len); + } else + throw std::runtime_error("unknown waveform type: " + wave_type); - //compute i and q pairs with 90% offset and scale to amplitude - for (size_t i = 0; i < wave_table_len; i++){ - const size_t q = (i+(3*wave_table_len)/4)%wave_table_len; - _wave_table[i] = std::complex<float>( - ampl*real_wave_table[i], - ampl*real_wave_table[q] - ); + // compute i and q pairs with 90% offset and scale to amplitude + for (size_t i = 0; i < wave_table_len; i++) { + const size_t q = (i + (3 * wave_table_len) / 4) % wave_table_len; + _wave_table[i] = + std::complex<float>(ampl * real_wave_table[i], ampl * real_wave_table[q]); } } - inline std::complex<float> operator()(const size_t index) const{ + inline std::complex<float> operator()(const size_t index) const + { return _wave_table[index % wave_table_len]; } private: - std::vector<std::complex<float> > _wave_table; + std::vector<std::complex<float>> _wave_table; }; - |