Skip to content

Commit

Permalink
Refactor: Remove Dependency on Custom Class const_nums in david (#4950)
Browse files Browse the repository at this point in the history
* Refactor: Remove Dependency on Custom Class const_nums in david

* Refactor: use object one,zero,neg_one instead of new T*
  • Loading branch information
Cstandardlib authored Aug 12, 2024
1 parent 563eca1 commit a15a6f6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
6 changes: 3 additions & 3 deletions source/module_hsolver/diago_david.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ DiagoDavid<T, Device>::DiagoDavid(const Real* precondition_in,
this->device = base_device::get_device_type<Device>(this->ctx);
this->precondition = precondition_in;

this->one = &this->cs.one;
this->zero = &this->cs.zero;
this->neg_one = &this->cs.neg_one;
this->one = &one_;
this->zero = &zero_;
this->neg_one = &neg_one_;

test_david = 2;
// 1: check which function is called and which step is executed
Expand Down
5 changes: 2 additions & 3 deletions source/module_hsolver/diago_david.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "diagh.h"
#include "module_hsolver/diag_comm_info.h"
#include "module_hsolver/diag_const_nums.h"

namespace hsolver
{
Expand Down Expand Up @@ -197,8 +196,8 @@ class DiagoDavid : public DiagH<T, Device>

using hpsi_info = typename hamilt::Operator<T, Device>::hpsi_info;

const_nums<T> cs;
const T* one = nullptr, * zero = nullptr, * neg_one = nullptr;
const T *one = nullptr, *zero = nullptr, *neg_one = nullptr;
const T one_ = static_cast<T>(1.0), zero_ = static_cast<T>(0.0), neg_one_ = static_cast<T>(-1.0);
};
} // namespace hsolver

Expand Down
10 changes: 0 additions & 10 deletions source/module_hsolver/test/hsolver_pw_sup.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ FFT::~FFT() {}
#include "module_hsolver/diago_david.h"
#include "module_hsolver/diago_iter_assist.h"

template <typename T>
const_nums<T>::const_nums()
{
}
template class const_nums<std::complex<float>>;
template class const_nums<std::complex<double>>;

namespace hsolver {

Expand Down Expand Up @@ -138,10 +132,6 @@ DiagoDavid<T, Device>::DiagoDavid(const Real* precondition_in,
this->device = base_device::get_device_type<Device>(this->ctx);
this->precondition = precondition_in;

this->one = &this->cs.one;
this->zero = &this->cs.zero;
this->neg_one = &this->cs.neg_one;

test_david = 2;
// 1: check which function is called and which step is executed
// 2: check the eigenvalues of the result of each iteration
Expand Down

0 comments on commit a15a6f6

Please sign in to comment.