20inline int globalIndex(
int localindex,
int nblk,
int nprocs,
int myproc)
23 iblock = localindex / nblk;
24 gIndex = (iblock * nprocs + myproc) * nblk + localindex % nblk;
31inline T init_value(
typename std::enable_if<!std::is_same<
T, std::complex<float>>::value
32 && !std::is_same<
T, std::complex<double>>::value>::type* =
nullptr)
39inline T init_value(
typename std::enable_if<std::is_same<
T, std::complex<float>>::value
40 || std::is_same<
T, std::complex<double>>::value>::type* =
nullptr)
51 if (std::is_same<T, float>::value)
53 data_type = ct::DataType::DT_FLOAT;
55 else if (std::is_same<T, double>::value)
57 data_type = ct::DataType::DT_DOUBLE;
59 else if (std::is_same<
T, std::complex<float>>::value)
61 data_type = ct::DataType::DT_COMPLEX;
63 else if (std::is_same<
T, std::complex<double>>::value)
65 data_type = ct::DataType::DT_COMPLEX_DOUBLE;
69 static_assert(std::is_same<T, float>::value || std::is_same<T, double>::value
70 || std::is_same<T, std::complex<float>>::value
71 || std::is_same<T, std::complex<double>>::value,
72 "Unsupported data type!");
79 if (device == ct::DeviceType::CpuDevice)
82 T* data_ptr = tensor.
data<
T>();
83 for (
int i = 0;
i < n; ++
i)
85 data_ptr[
i * n +
i] = init_value<T>();
89 else if (device == ct::DeviceType::GpuDevice)
92 T* data_ptr = tensor.
data<
T>();
93 for (
int i = 0;
i < n; ++
i)
95 T value = init_value<T>();
96 ct::kernels::set_memory<T, ct::DEVICE_GPU>()(data_ptr +
i * n +
i, value, 1);
128 const std::complex<double>* Stmp,
129 const std::complex<double>* Htmp,
130 const std::complex<double>* H_laststep,
131 std::complex<double>* U_operator,
132 std::ofstream& ofs_running,
135 template <
typename Device>
141 std::ofstream& ofs_running,
143 const bool use_lapack,
164 const std::complex<double>* Stmp,
165 const std::complex<double>* Htmp,
166 std::complex<double>* U_operator,
167 std::ofstream& ofs_running,
174 std::ofstream& ofs_running,
178 template <
typename Device>
183 std::ofstream& ofs_running,
197 const std::complex<double>* Stmp,
198 const std::complex<double>* Htmp,
199 std::complex<double>* U_operator,
200 std::ofstream& ofs_running,
202 const int tag)
const;
215 const std::complex<double>* Stmp,
216 const std::complex<double>* Htmp,
217 const std::complex<double>* H_laststep,
218 std::complex<double>* U_operator,
219 std::ofstream& ofs_running,
const std::complex< double > i
Definition cal_pLpR.cpp:46
Definition parallel_orbitals.h:9
A class for representing the shape of a tensor.
Definition tensor_shape.h:13
A multi-dimensional array of elements of a single data type.
Definition tensor.h:32
void * data() const
Get a pointer to the data buffer of the tensor.
Definition tensor.cpp:73
void zero()
Set all elements in current tensor object to zero.
Definition tensor.cpp:97
Definition propagator.h:106
void compute_propagator_etrs(const int nlocal, const std::complex< double > *Stmp, const std::complex< double > *Htmp, const std::complex< double > *H_laststep, std::complex< double > *U_operator, std::ofstream &ofs_running, const int print_matrix) const
compute propagator of method ETRS
Definition propagator_etrs.cpp:15
Propagator(const int ptype, const Parallel_Orbitals *pv, const double &dt)
Definition propagator.h:108
void compute_propagator_cn2_tensor_lapack(const int nlocal, const ct::Tensor &Stmp, const ct::Tensor &Htmp, ct::Tensor &U_operator, std::ofstream &ofs_running, const int print_matrix) const
Definition propagator_cn2.cpp:557
void compute_propagator_tensor(const int nlocal, const ct::Tensor &Stmp, const ct::Tensor &Htmp, const ct::Tensor &H_laststep, ct::Tensor &U_operator, std::ofstream &ofs_running, const int print_matrix, const bool use_lapack, CublasMpResources &cublas_res) const
Definition propagator.cpp:50
void compute_propagator_taylor(const int nlocal, const std::complex< double > *Stmp, const std::complex< double > *Htmp, std::complex< double > *U_operator, std::ofstream &ofs_running, const int print_matrix, const int tag) const
compute propagator of method 4th Taylor
Definition propagator_taylor.cpp:17
double dt
Definition propagator.h:150
void compute_propagator_cn2_tensor(const int nlocal, const ct::Tensor &Stmp, const ct::Tensor &Htmp, ct::Tensor &U_operator, std::ofstream &ofs_running, const int print_matrix, CublasMpResources &cublas_res) const
Definition propagator_cn2.cpp:251
void compute_propagator(const int nlocal, const std::complex< double > *Stmp, const std::complex< double > *Htmp, const std::complex< double > *H_laststep, std::complex< double > *U_operator, std::ofstream &ofs_running, const int print_matrix) const
compute propagator
Definition propagator.cpp:19
const Parallel_Orbitals * ParaV
Definition propagator.h:149
int ptype
Definition propagator.h:148
~Propagator()
Definition propagator.cpp:15
void compute_propagator_cn2(const int nlocal, const std::complex< double > *Stmp, const std::complex< double > *Htmp, std::complex< double > *U_operator, std::ofstream &ofs_running, const int print_matrix) const
compute propagator of method Crank-Nicolson
Definition propagator_cn2.cpp:19
void print_matrix(std::ofstream &fp, T *matrix, int &nrow, int &ncol, bool row_first)
Definition diago_lapack_test.cpp:92
#define T
Definition exp.cpp:237
const double AU_to_FS
Definition constants.h:75
DataType
Enumeration of data types for tensors. The DataType enum lists the supported data types for tensors....
Definition tensor_types.h:50
DeviceType
The type of memory used by an allocator.
Definition tensor_types.h:73
Definition band_energy.cpp:15
ct::Tensor create_identity_matrix(const int n, ct::DeviceType device=ct::DeviceType::CpuDevice)
Definition propagator.h:47
int globalIndex(int localindex, int nblk, int nprocs, int myproc)
Definition band_energy.cpp:18
T init_value(typename std::enable_if<!std::is_same< T, std::complex< float > >::value &&!std::is_same< T, std::complex< double > >::value >::type *=nullptr)
Definition propagator.h:31
Definition cublasmp_context.h:38