Skip to content

Commit

Permalink
CompFunction destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
gitpeterwind committed Jul 20, 2024
1 parent 9ce1b76 commit 3057d0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/utils/CompFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace mrcpp {

template <int D, typename T>
template <int D_, typename std::enable_if<D_ == 3, int>::type>
CompFunction<D, T>::CompFunction(T value, ComplexFunction cplxfunc)
: Ncomp(1){
CompFunction<D, T>::CompFunction(ComplexFunction cplxfunc){
Ncomp = 1;
defaultCompMRA<3> = cplxfunc.funcMRA;
//we always copy real part
Comp[0] = new FunctionTree<D, T>(*cplxfunc.funcMRA);
Expand Down Expand Up @@ -41,6 +41,7 @@ namespace mrcpp {
Comp[2]=nullptr;
Comp[3]=nullptr;
}

template <int D, typename T>
double CompFunction<D, T>::norm() {
double norm = squaredNorm();
Expand Down
8 changes: 7 additions & 1 deletion src/utils/CompFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ template <int D, typename T> class CompFunction {

// ComplexFunctions are only defined for D=3
template <int D_ = D, typename std::enable_if<D_ == 3, int>::type = 0>
CompFunction(T value, ComplexFunction cplxfunc);
CompFunction(ComplexFunction cplxfunc);
// CompFunction destructor
~CompFunction() {
for (int i = 0; i < Ncomp; i++) {
delete Comp[i];
}
}

double norm();
double squaredNorm();
Expand Down

0 comments on commit 3057d0a

Please sign in to comment.