From 7953b70dea5cf755510b8511d27b903ca8b77169 Mon Sep 17 00:00:00 2001 From: edinvay Date: Fri, 18 Oct 2024 16:15:11 +0200 Subject: [PATCH 1/2] negative coefficients alpha are possible now in Gausian expansion --- src/operators/ConvolutionOperator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/operators/ConvolutionOperator.cpp b/src/operators/ConvolutionOperator.cpp index 150a176be..26bf44e72 100644 --- a/src/operators/ConvolutionOperator.cpp +++ b/src/operators/ConvolutionOperator.cpp @@ -86,7 +86,7 @@ void ConvolutionOperator::initialize(GaussExp<1> &kernel, double k_prec, doub for (int i = 0; i < kernel.size(); i++) { // Rescale Gaussian for D-dim application auto *k_func = kernel.getFunc(i).copy(); - k_func->setCoef(std::pow(k_func->getCoef(), 1.0/D)); + k_func->setCoef( std::copysign( std::pow(std::abs(k_func->getCoef()), 1.0/D), k_func->getCoef() ) ); FunctionTree<1> k_tree(k_mra); mrcpp::build_grid(k_tree, *k_func); // Generate empty grid to hold narrow Gaussian From d77ca248294aba6c968154ef429070064d4ca4bb Mon Sep 17 00:00:00 2001 From: edinvay Date: Fri, 18 Oct 2024 19:02:11 +0200 Subject: [PATCH 2/2] documentation --- .../ConvolutionOperator.rst | 12 ++++++++ docs/programmers_manual/overview.rst | 1 + src/operators/ConvolutionOperator.h | 30 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 docs/programmers_manual/ConvolutionOperator.rst diff --git a/docs/programmers_manual/ConvolutionOperator.rst b/docs/programmers_manual/ConvolutionOperator.rst new file mode 100644 index 000000000..11ac14420 --- /dev/null +++ b/docs/programmers_manual/ConvolutionOperator.rst @@ -0,0 +1,12 @@ +--------------------- +ConvolutionOperator +--------------------- + +This is an introduction to the ConvolutionOperator class. We write a small overarching summary of the class where we define the +algorithm/equation/structure reasoning for having this class or where it fits with the rest of the code. + +.. doxygenclass:: mrcpp::ConvolutionOperator + :members: + :protected-members: + :private-members: + diff --git a/docs/programmers_manual/overview.rst b/docs/programmers_manual/overview.rst index 27f5aa1be..a649c4a1e 100644 --- a/docs/programmers_manual/overview.rst +++ b/docs/programmers_manual/overview.rst @@ -27,3 +27,4 @@ TODO: maybe add some low level theory/figures/algorithms before showing classes, complex_apply HeatOperator HeatKernel + ConvolutionOperator \ No newline at end of file diff --git a/src/operators/ConvolutionOperator.h b/src/operators/ConvolutionOperator.h index b822ec808..c9879d2a2 100644 --- a/src/operators/ConvolutionOperator.h +++ b/src/operators/ConvolutionOperator.h @@ -29,6 +29,36 @@ namespace mrcpp { +/** @class ConvolutionOperator + * + * @brief Convolution defined by a Gaussian expansion + * + * @details Represents the operator + * \f[ + * T = \sum_{m=1}^M + * \text{sign} (\alpha_m) \bigotimes \limits_{d = 1}^D T_d + * \left( \beta_m, \sqrt[D]{| \alpha_m |} \right) + * , + * \f] + * where each + * \f$ T_d \left( \beta, \alpha \right) \f$ + * is the convolution operator with one-dimensional Gaussian kernel + * \f$ k(x_d) = \alpha \exp \left( - \beta x_d^2 \right) \f$. + * Operator + * \f$ T \f$ + * is obtained from the Gaussian expansion + * \f[ + * \sum_{m=1}^M \alpha_m \exp \left( - \beta_m |x|^2 \right) + * \f] + * which is passed as a parameter to the first two constructors. + * + * @note Every \f$ T_d \left( \beta_m, \sqrt[D]{| \alpha_m |} \right) \f$ is the same + * operator associated with the one-dimensional variable \f$ x_d \f$ for \f$ d = 1, \ldots, D \f$. + * + * \todo: One may want to change the logic so that \f$ D \f$-root is evaluated on the previous step, + * namely, when \f$ \alpha_m, \beta_m \f$ are calculated. + * + */ template class ConvolutionOperator : public MWOperator { public: ConvolutionOperator(const MultiResolutionAnalysis &mra, GaussExp<1> &kernel, double prec);