{
return mat_mat_operator([](std::complex<T> &c_lhs, const std::complex<T> &c_rhs) { c_lhs *= c_rhs; }, rhs);
}
+
+ComplexMat_ ComplexMat_::mat_mat_operator(void (*op)(std::complex<ComplexMat_::T> &, const std::complex<ComplexMat_::T> &), const ComplexMat_ &mat_rhs) const
+{
+ assert(mat_rhs.n_channels == n_channels/n_scales && mat_rhs.cols == cols && mat_rhs.rows == rows);
+
+ ComplexMat_ result = *this;
+ for (uint s = 0; s < n_scales; ++s) {
+ auto lhs = result.p_data.hostMem() + (s * n_channels/n_scales * rows * cols);
+ auto rhs = mat_rhs.p_data.hostMem();
+ for (uint i = 0; i < n_channels/n_scales * rows * cols; ++i)
+ op(*(lhs + i), *(rhs + i));
+ }
+
+ return result;
+}
+
+ComplexMat_ ComplexMat_::matn_mat1_operator(void (*op)(std::complex<ComplexMat_::T> &, const std::complex<ComplexMat_::T> &), const ComplexMat_ &mat_rhs) const
+{
+ assert(mat_rhs.n_channels == 1 && mat_rhs.cols == cols && mat_rhs.rows == rows);
+
+ ComplexMat_ result = *this;
+ for (uint i = 0; i < n_channels; ++i) {
+ auto lhs = result.p_data.hostMem() + i * rows * cols;
+ auto rhs = mat_rhs.p_data.hostMem();
+ for (; lhs != result.p_data.hostMem() + (i + 1) * rows * cols; ++lhs, ++rhs)
+ op(*lhs, *rhs);
+ }
+
+ return result;
+}
+
+ComplexMat_ ComplexMat_::matn_mat2_operator(void (*op)(std::complex<ComplexMat_::T> &, const std::complex<ComplexMat_::T> &), const ComplexMat_ &mat_rhs) const
+{
+ assert(mat_rhs.n_channels == n_channels / n_scales && mat_rhs.cols == cols && mat_rhs.rows == rows);
+
+ int n_channels_per_scale = n_channels / n_scales;
+ int scale_offset = n_channels_per_scale * rows * cols;
+ ComplexMat_ result = *this;
+ for (uint i = 0; i < n_scales; ++i) {
+ for (int j = 0; j < n_channels_per_scale; ++j) {
+ auto lhs = result.p_data.hostMem() + (j * rows * cols) + (i * scale_offset);
+ auto rhs = mat_rhs.p_data.hostMem() + (j * rows * cols);
+ for (; lhs != result.p_data.hostMem() + ((j + 1) * rows * cols) + (i * scale_offset); ++lhs, ++rhs)
+ op(*lhs, *rhs);
+ }
+ }
+
+ return result;
+}
+
+ComplexMat_ ComplexMat_::mat_const_operator(const std::function<void (std::complex<ComplexMat_::T> &)> &op) const
+{
+ ComplexMat_ result = *this;
+ for (uint i = 0; i < n_channels; ++i) {
+ for (auto lhs = result.p_data.hostMem() + i * rows * cols;
+ lhs != result.p_data.hostMem() + (i + 1) * rows * cols; ++lhs)
+ op(*lhs);
+ }
+ return result;
+}
#include <algorithm>
#include <functional>
#include "dynmem.hpp"
+#include "pragmas.h"
#ifdef CUFFT
#include <cufft.h>
}
ComplexMat_ mat_mat_operator(void (*op)(std::complex<T> &c_lhs, const std::complex<T> &c_rhs),
- const ComplexMat_ &mat_rhs) const
- {
- assert(mat_rhs.n_channels == n_channels/n_scales && mat_rhs.cols == cols && mat_rhs.rows == rows);
-
- ComplexMat_ result = *this;
- for (uint s = 0; s < n_scales; ++s) {
- auto lhs = result.p_data.hostMem() + (s * n_channels/n_scales * rows * cols);
- auto rhs = mat_rhs.p_data.hostMem();
- for (uint i = 0; i < n_channels/n_scales * rows * cols; ++i)
- op(*(lhs + i), *(rhs + i));
- }
-
- return result;
- }
+ const ComplexMat_ &mat_rhs) const;
ComplexMat_ matn_mat1_operator(void (*op)(std::complex<T> &c_lhs, const std::complex<T> &c_rhs),
- const ComplexMat_ &mat_rhs) const
- {
- assert(mat_rhs.n_channels == 1 && mat_rhs.cols == cols && mat_rhs.rows == rows);
-
- ComplexMat_ result = *this;
- for (uint i = 0; i < n_channels; ++i) {
- auto lhs = result.p_data.hostMem() + i * rows * cols;
- auto rhs = mat_rhs.p_data.hostMem();
- for (; lhs != result.p_data.hostMem() + (i + 1) * rows * cols; ++lhs, ++rhs)
- op(*lhs, *rhs);
- }
-
- return result;
- }
+ const ComplexMat_ &mat_rhs) const;
ComplexMat_ matn_mat2_operator(void (*op)(std::complex<T> &c_lhs, const std::complex<T> &c_rhs),
- const ComplexMat_ &mat_rhs) const
- {
- assert(mat_rhs.n_channels == n_channels / n_scales && mat_rhs.cols == cols && mat_rhs.rows == rows);
-
- int n_channels_per_scale = n_channels / n_scales;
- int scale_offset = n_channels_per_scale * rows * cols;
- ComplexMat_ result = *this;
- for (uint i = 0; i < n_scales; ++i) {
- for (int j = 0; j < n_channels_per_scale; ++j) {
- auto lhs = result.p_data.hostMem() + (j * rows * cols) + (i * scale_offset);
- auto rhs = mat_rhs.p_data.hostMem() + (j * rows * cols);
- for (; lhs != result.p_data.hostMem() + ((j + 1) * rows * cols) + (i * scale_offset); ++lhs, ++rhs)
- op(*lhs, *rhs);
- }
- }
-
- return result;
- }
- ComplexMat_ mat_const_operator(const std::function<void(std::complex<T> &c_rhs)> &op) const
- {
- ComplexMat_ result = *this;
- for (uint i = 0; i < n_channels; ++i)
- for (auto lhs = result.p_data.hostMem() + i * rows * cols;
- lhs != result.p_data.hostMem() + (i + 1) * rows * cols; ++lhs)
- op(*lhs);
- return result;
- }
+ const ComplexMat_ &mat_rhs) const;
+ ComplexMat_ mat_const_operator(const std::function<void(std::complex<T> &c_rhs)> &op) const;
cv::Mat channel_to_cv_mat(int channel_id) const
{