Simple declarative reflection in C++20

21 December 2022

Almost every real-world application requires a lot of similar operations such as saving its internal state, making API requests, logging events, etc. This leads to writing hundreds of lines of code to convert classes to JSON, serializing to various formats, and so on.

But if we knew the internal structure of classes, then we could write generic functions for all use cases and get the desired features quickly and easily.

Fast Fourier Transform in C++ using KFR

12 September 2016

In this article I’ll show you how to use Fast Fourier Transform in Digital Signal Processing and how to apply forward and inverse FFT on complex and real data using the KFR framework.

How C++14 and C++17 help to write faster (and better) code. Real world examples

29 August 2016
Writing high performance code is always a difficult task. Pure algorithms are not always a good fit for the real world architectures. Once having begun to speed up all these pure algorithms, we quickly find that some implementation is pretty fast on one architecture, but terrible slow on another while second implementation outperform the first one in some contexts losing speed in all the rest. Numerous big and small optimizations for each of supported architectures can quickly bloat our code and waste our time.

Compile-time arguments and function wrappers

24 August 2016

Passing values in C++ as a template arguments has some inflexibilities. For example, if template function has been wrapped into a functor class, there are no ways to pass some value as a template argument.

Example: FIR filter in C++

14 August 2016
The following example shows how to apply FIR filter to audio data using KFR framework. #include <kfr/all.hpp> using namespace kfr; int main(int argc, char** argv) { // static array (like std::array) to hold the taps univector<double, 15> taps; // initialize window function // we pass tap count to window_hann function // window_hann does not calculate window functions // but creates object representing hann window expression_pointer<double> hann = to_pointer(window_hann(taps.size())); // FIR filter design using window method // frequency = 0.

Basic expression tutorial

2 August 2016
The expression is the central entity of KFR framework. Input expressions can be read from and output expressions can be written to. Class can be an input and output expression at same time. univector is an example of such class. Data type of an input expressions can be determined by calling value_type_of. However, not all expressions have their types specified. In such cases value_type_of will return special type generic. Size (length) of an expression also can be specified or not.

Biquad filters in C++ using KFR

25 July 2016

Digital biquad filters and biquad filter design functions are implemented in the KFR framework starting from the first version.

Biquad algorithm uses the Transposed Direct Form II which reduces the quantization errors in the floating point calculations.