ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
sto_che.h
Go to the documentation of this file.
1#ifndef STO_CHE_H
2#define STO_CHE_H
6
7template <typename REAL, typename Device = base_device::DEVICE_CPU>
8class StoChe
9{
10 public:
11 StoChe(const int& nche, const int& method, const REAL& emax_sto, const REAL& emin_sto);
12 ~StoChe();
13
14 public:
15 int nche = 0;
16 REAL* spolyv = nullptr;
17 REAL* spolyv_cpu = nullptr;
18 int method_sto = 0;
19
20 // Chebyshev expansion
21 // It stores the plan of FFTW and should be initialized at the beginning of the calculation
23
24 REAL emax_sto = 0.0;
25 REAL emin_sto = 0.0;
26
27 private:
28 Device* ctx = {};
29#ifdef __DSP
30 using resmem_var_op = base_device::memory::resize_memory_op_mt<REAL, Device>;
31 using delmem_var_op = base_device::memory::delete_memory_op_mt<REAL, Device>;
32#else
35#endif
37};
38
47template <typename REAL, typename Device>
48REAL vTMv(const REAL* v, const REAL* M, const int n)
49{
50 Device* ctx = {};
51 base_device::DEVICE_CPU* cpu_ctx = {};
52 using ct_Device = typename container::PsiToContainer<Device>::type;
53 const char normal = 'N';
54 const REAL one = 1;
55 const int inc = 1;
56 const REAL zero = 0;
57 REAL* y = nullptr;
59 ModuleBase::gemv_op<REAL, Device>()(normal, n, n, &one, M, n, v, inc, &zero, y, inc);
60 REAL result = 0;
61 REAL* dot_device = nullptr;
63 container::kernels::blas_dot<REAL, ct_Device>()(n, y, 1, v, 1, dot_device);
65 dot_device,
66 1);
69 return result;
70}
71
72#endif
A class to treat the Chebyshev expansion.
Definition math_chebyshev.h:84
Definition sto_che.h:9
base_device::memory::resize_memory_op< REAL, Device > resmem_var_op
Definition sto_che.h:33
base_device::memory::delete_memory_op< REAL, Device > delmem_var_op
Definition sto_che.h:34
~StoChe()
Definition test_hsolver_sdft.cpp:90
ModuleBase::Chebyshev< REAL, Device > * p_che
Definition sto_che.h:22
Device * ctx
Definition sto_che.h:28
REAL emin_sto
minimum energy for normalization
Definition sto_che.h:25
REAL emax_sto
maximum energy for normalization
Definition sto_che.h:24
int nche
order of Chebyshev expansion
Definition sto_che.h:15
int method_sto
method for the stochastic calculation
Definition sto_che.h:18
REAL * spolyv
[Device] coefficients of Chebyshev expansion
Definition sto_che.h:16
REAL * spolyv_cpu
[CPU] coefficients of Chebyshev expansion
Definition sto_che.h:17
REAL vTMv(const REAL *v, const REAL *M, const int n)
calculate v^T*M*v
Definition sto_che.h:48
Definition math_kernel_op.h:191
Definition memory_op.h:115
Definition memory_op.h:17
T type
Definition tensor_types.h:114
Definition blas.h:33
const std::map< std::string, std::vector< double > > zero
Definition vdwd3_autoset_xcparam.cpp:326