convolution¶
autocorrelate
function¶
template <typename T, univector_tag Tag1>
univector<T> autocorrelate(const univector<T, Tag1> &src)
Auto-correlation
Source code
template <typename T, univector_tag Tag1>
univector<T> autocorrelate(const univector<T, Tag1>& src)
{
return intrinsics::autocorrelate(src.slice());
}
https://github.com/kfrlib/kfr/blob//include/kfr/dft/convolution.hpp#L74
convolve
function¶
template <typename T, univector_tag Tag1,
univector_tag Tag2>
univector<T> convolve(const univector<T, Tag1> &src1,
const univector<T, Tag2> &src2)
Convolution
Source code
template <typename T, univector_tag Tag1, univector_tag Tag2>
univector<T> convolve(const univector<T, Tag1>& src1, const univector<T, Tag2>& src2)
{
return intrinsics::convolve(src1.slice(), src2.slice());
}
https://github.com/kfrlib/kfr/blob//include/kfr/dft/convolution.hpp#L60
convolve_filter
convolve_filter
class¶
template <typename T> convolve_filter
Convolution using Filter API
Source code
template <typename T>
class convolve_filter : public filter<T>
{
public:
explicit convolve_filter(size_t size, size_t block_size = 1024);
explicit convolve_filter(const univector_ref<const T>& data, size_t block_size = 1024);
void set_data(const univector_ref<const T>& data);
void reset() final;
/// Apply filter to multiples of returned block size for optimal processing efficiency.
size_t input_block_size() const { return block_size; }
protected:
void process_expression(T* dest, const expression_handle<T>& src, size_t size) final
{
univector<T> input = truncate(src, size);
process_buffer(dest, input.data(), input.size());
}
void process_buffer(T* output, const T* input, size_t size) final;
using ST = subtype<T>;
constexpr static bool real_fft = !std::is_same_v<T, complex<ST>>;
using plan_t = internal::dft_conv_plan<T>;
// Length of filter data.
size_t data_size;
// Size of block to process.
const size_t block_size;
// FFT plan for circular convolution.
const plan_t fft;
// Temp storage for FFT.
univector<u8> temp;
// History of input segments after fwd DFT. History is circular relative to position below.
std::vector<univector<complex<ST>>> segments;
// Index into segments of current block.
size_t position;
// Blocks of filter/data after fwd DFT.
std::vector<univector<complex<ST>>> ir_segments;
// Saved input for current block.
univector<T> saved_input;
// Index into saved_input for next input to begin.
size_t input_position;
// Pre-multiplied products of input history and delayed filter blocks.
univector<complex<ST>> premul;
// Scratch buffer for product of filter and input for processing by reverse DFT.
univector<complex<ST>> cscratch;
// Scratch buffers for input and output of fwd and rev DFTs.
univector<T> scratch1, scratch2;
// Overlap saved from previous block to add into current block.
univector<T> overlap;
}
https://github.com/kfrlib/kfr/blob//include/kfr/dft/convolution.hpp#L101
input_block_size
function¶
size_t input_block_size() const
Apply filter to multiples of returned block size for optimal processing efficiency.
Source code
size_t input_block_size() const { return block_size; }
https://github.com/kfrlib/kfr/blob//include/kfr/dft/convolution.hpp#L109
correlate
function¶
template <typename T, univector_tag Tag1,
univector_tag Tag2>
univector<T> correlate(const univector<T, Tag1> &src1,
const univector<T, Tag2> &src2)
Correlation
Source code
template <typename T, univector_tag Tag1, univector_tag Tag2>
univector<T> correlate(const univector<T, Tag1>& src1, const univector<T, Tag2>& src2)
{
return intrinsics::correlate(src1.slice(), src2.slice());
}
https://github.com/kfrlib/kfr/blob//include/kfr/dft/convolution.hpp#L67
dft_conv_plan
dft_conv_plan
class¶
template <typename T> dft_conv_plan
Utility class to abstract real/complex differences
Source code
template <typename T>
struct dft_conv_plan : public dft_plan_real<T>
{
dft_conv_plan(size_t size) : dft_plan_real<T>(size, dft_pack_format::Perm) {}
size_t csize() const { return this->size / 2; }
}
https://github.com/kfrlib/kfr/blob//include/kfr/dft/convolution.hpp#L83
Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/