19inline int globalIndex(
int localindex,
int nblk,
int nprocs,
int myproc)
22 iblock = localindex / nblk;
23 gIndex = (iblock * nprocs + myproc) * nblk + localindex % nblk;
30inline T init_value(
typename std::enable_if<!std::is_same<
T, std::complex<float>>::value
31 && !std::is_same<
T, std::complex<double>>::value>::type* =
nullptr)
38inline T init_value(
typename std::enable_if<std::is_same<
T, std::complex<float>>::value
39 || std::is_same<
T, std::complex<double>>::value>::type* =
nullptr)
50 if (std::is_same<T, float>::value)
52 data_type = ct::DataType::DT_FLOAT;
54 else if (std::is_same<T, double>::value)
56 data_type = ct::DataType::DT_DOUBLE;
58 else if (std::is_same<
T, std::complex<float>>::value)
60 data_type = ct::DataType::DT_COMPLEX;
62 else if (std::is_same<
T, std::complex<double>>::value)
64 data_type = ct::DataType::DT_COMPLEX_DOUBLE;
68 static_assert(std::is_same<T, float>::value || std::is_same<T, double>::value
69 || std::is_same<T, std::complex<float>>::value
70 || std::is_same<T, std::complex<double>>::value,
71 "Unsupported data type!");
78 if (device == ct::DeviceType::CpuDevice)
81 T* data_ptr = tensor.
data<
T>();
82 for (
int i = 0; i < n; ++i)
84 data_ptr[i * n + i] = init_value<T>();
88 else if (device == ct::DeviceType::GpuDevice)
91 T* data_ptr = tensor.
data<
T>();
92 for (
int i = 0; i < n; ++i)
94 T value = init_value<T>();
95 ct::kernels::set_memory<T, ct::DEVICE_GPU>()(data_ptr + i * n + i, value, 1);
127 const std::complex<double>* Stmp,
128 const std::complex<double>* Htmp,
129 const std::complex<double>* H_laststep,
130 std::complex<double>* U_operator,
131 std::ofstream& ofs_running,
134 template <
typename Device>
140 std::ofstream& ofs_running,
142 const bool use_lapack)
const;
162 const std::complex<double>* Stmp,
163 const std::complex<double>* Htmp,
164 std::complex<double>* U_operator,
165 std::ofstream& ofs_running,
172 std::ofstream& ofs_running,
175 template <
typename Device>
180 std::ofstream& ofs_running,
194 const std::complex<double>* Stmp,
195 const std::complex<double>* Htmp,
196 std::complex<double>* U_operator,
197 std::ofstream& ofs_running,
199 const int tag)
const;
212 const std::complex<double>* Stmp,
213 const std::complex<double>* Htmp,
214 const std::complex<double>* H_laststep,
215 std::complex<double>* U_operator,
216 std::ofstream& ofs_running,
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:105
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:107
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:501
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
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) const
Definition propagator.cpp:50
double dt
Definition propagator.h:148
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:147
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) const
Definition propagator_cn2.cpp:250
int ptype
Definition propagator.h:146
~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:18
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:11
ct::Tensor create_identity_matrix(const int n, ct::DeviceType device=ct::DeviceType::CpuDevice)
Definition propagator.h:46
int globalIndex(int localindex, int nblk, int nprocs, int myproc)
Definition band_energy.cpp:14
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:30