1 #ifndef CNTR_HERM_TIMESTEP_VIEW_IMPL_H 2 #define CNTR_HERM_TIMESTEP_VIEW_IMPL_H 10 #define CPLX std::complex<T> 60 element_size_ = size1_ * size1_;
97 assert(size1>=0 && tstp>=-1 && ntau>=0);
104 element_size_=size1*size2;
132 template <
typename T>
142 element_size_ = size1_ * size1_;
171 template <
typename T>
178 element_size_ = size1_ * size2_;
185 }
else if (tstp_ >= 0) {
217 template <
typename T>
220 if(check_assert) assert(tstp==g.tstp_);
226 element_size_ = size1_ * size2_;
233 }
else if (tstp_ >= 0) {
262 template <
typename T>
265 assert(tstp == g.tstp_);
271 element_size_ = size1_ * size1_;
304 template <
typename T>
308 if(check_assert) assert(tstp>=-1 && tstp <=g.
nt());
313 element_size_ = size1_ * size2_;
320 }
else if (tstp_ >= 0) {
322 ret_ = g.retptr(tstp_, 0);
323 les_ = g.lesptr(0, tstp_);
324 tv_ = g.tvptr(tstp_, 0);
334 #define herm_matrix_SET_ELEMENT_MATRIX \ 337 for (r = 0; r < size1_; r++) \ 338 for (s = 0; s < size2_; s++) \ 339 x[r * size2_ + s] = M(r, s); \ 367 herm_matrix_SET_ELEMENT_MATRIX
391 template<
typename T>
template <
class Matrix>
void herm_matrix_timestep_view<T>::set_les(
int i,
int j, Matrix &M){
395 herm_matrix_SET_ELEMENT_MATRIX
419 template<
typename T>
template <
class Matrix>
void herm_matrix_timestep_view<T>::set_tv(
int i,
int j, Matrix &M){
423 herm_matrix_SET_ELEMENT_MATRIX
445 template<
typename T>
template <
class Matrix>
void herm_matrix_timestep_view<T>::set_mat(
int i,Matrix &M){
448 herm_matrix_SET_ELEMENT_MATRIX
456 #define herm_matrix_READ_ELEMENT \ 458 int r, s, dim = size1_; \ 459 M.resize(dim, dim); \ 460 for (r = 0; r < dim; r++) \ 461 for (s = 0; s < dim; s++) \ 462 M(r, s) = x[r * dim + s]; \ 464 #define herm_matrix_READ_ELEMENT_MINUS_CONJ \ 467 int r, s, dim = size1_; \ 468 M.resize(dim, dim); \ 469 for (r = 0; r < dim; r++) \ 470 for (s = 0; s < dim; s++) { \ 471 w = x[s * dim + r]; \ 472 M(r, s) = std::complex<T>(-w.real(), w.imag()); \ 497 template <
typename T>
template <
class Matrix>
498 void herm_matrix_timestep_view<T>::get_les(
int i,
int j, Matrix &M){
499 assert(j == tstp_ && i <= tstp_);
502 herm_matrix_READ_ELEMENT
526 template <
typename T>
527 template <
class Matrix>
528 void herm_matrix_timestep_view<T>::get_ret(
int i,
int j, Matrix &M) {
529 assert(i == tstp_ && j <= tstp_);
532 herm_matrix_READ_ELEMENT
556 template <
typename T>
557 template <
class Matrix>
558 void herm_matrix_timestep_view<T>::get_tv(
int i,
int j, Matrix &M) {
561 herm_matrix_READ_ELEMENT
583 template <
typename T>
584 template <
class Matrix>
585 void herm_matrix_timestep_view<T>::get_mat(
int i, Matrix &M) {
587 herm_matrix_READ_ELEMENT
612 template <
typename T>
613 template <
class Matrix>
614 void herm_matrix_timestep_view<T>::get_matminus(
int i, Matrix &M) {
615 cplx *x = matptr(ntau_ - i);
616 herm_matrix_READ_ELEMENT
if (sig_ == -1) M = -M;
638 template <
typename T>
640 assert(tstp == tstp_);
643 memset(matptr(0), 0,
sizeof(
cplx) * (ntau_ + 1) * element_size_);
645 memset(retptr(0), 0,
sizeof(
cplx) * (tstp + 1) * element_size_);
646 memset(tvptr(0), 0,
sizeof(
cplx) * (ntau_ + 1) * element_size_);
647 memset(lesptr(0), 0,
sizeof(
cplx) * (tstp + 1) * element_size_);
674 template <
typename T>
676 assert(tstp == tstp_);
677 assert(tstp >= -1 && tstp <= g1.
nt() &&
"tstp >= -1 && tstp <= g1.nt()");
678 assert(g1.
size1() == size1_ &&
"g1.size1() == size1_");
679 assert(g1.
ntau() == ntau_ &&
"g1.ntau() == ntau_");
681 memcpy(matptr(0), g1.matptr(0),
sizeof(
cplx) * (ntau_ + 1) * element_size_);
683 memcpy(retptr(0), g1.retptr(tstp, 0),
684 sizeof(
cplx) * (tstp + 1) * element_size_);
685 memcpy(tvptr(0), g1.tvptr(tstp, 0),
686 sizeof(
cplx) * (ntau_ + 1) * element_size_);
687 memcpy(lesptr(0), g1.lesptr(0, tstp),
688 sizeof(
cplx) * (tstp + 1) * element_size_);
714 template <
typename T>
716 assert(tstp == tstp_);
717 assert(tstp == g1.
tstp());
718 assert(tstp >= -1 && tstp <= g1.nt() &&
"tstp >= -1 && tstp <= g1.nt()");
719 assert(g1.
size1() == size1_ &&
"g1.size1() == size1_");
720 assert(g1.
ntau() == ntau_ &&
"g1.ntau() == ntau_");
722 memcpy(matptr(0), g1.
matptr(0),
sizeof(
cplx) * (ntau_ + 1) * element_size_);
724 memcpy(retptr(0), g1.
retptr(0),
725 sizeof(
cplx) * (tstp + 1) * element_size_);
726 memcpy(tvptr(0), g1.
tvptr(0),
727 sizeof(
cplx) * (ntau_ + 1) * element_size_);
728 memcpy(lesptr(0), g1.
lesptr(0),
729 sizeof(
cplx) * (tstp + 1) * element_size_);
755 template <
typename T>
757 assert(tstp == tstp_);
758 assert( ft.
nt() >= tstp_);
760 this->left_multiply(ft.
ptr(-1), ft.
ptr(0), weight);
788 template <
typename T>
790 std::complex<T> *ft, T weight) {
792 cplx *xtemp, *ftemp, *x0;
793 xtemp =
new cplx[element_size_];
794 assert(tstp >= -1 &&
"tstp >= -1");
797 for (m = 0; m <= ntau_; m++) {
798 element_mult<T, LARGESIZE>(size1_, xtemp, f0,
799 x0 + m * element_size_);
800 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
801 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
804 ftemp = ft + tstp * element_size_;
805 x0 = retptr(tstp, 0);
806 for (m = 0; m <= tstp; m++) {
807 element_mult<T, LARGESIZE>(size1_, xtemp, ftemp,
808 x0 + m * element_size_);
809 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
810 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
813 for (m = 0; m <= ntau_; m++) {
814 element_mult<T, LARGESIZE>(size1_, xtemp, ftemp,
815 x0 + m * element_size_);
816 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
817 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
819 x0 = lesptr(0, tstp);
820 for (m = 0; m <= tstp; m++) {
821 element_mult<T, LARGESIZE>(size1_, xtemp, ft + m * element_size_,
822 x0 + m * element_size_);
823 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
824 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
851 template <
typename T>
853 assert(tstp == tstp_);
854 assert( ft.
nt() >= tstp_);
856 this->right_multiply(ft.
ptr(-1), ft.
ptr(0), weight);
884 template <
typename T>
886 std::complex<T> *ft, T weight) {
888 cplx *xtemp, *ftemp, *x0;
889 xtemp =
new cplx[element_size_];
890 assert(tstp >= -1 &&
"tstp >= -1");
893 for (m = 0; m <= ntau_; m++) {
894 element_mult<T, LARGESIZE>(size1_, xtemp, x0 + m * element_size_,
896 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
897 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
900 x0 = retptr(tstp, 0);
901 for (m = 0; m <= tstp; m++) {
902 element_mult<T, LARGESIZE>(size1_, xtemp, x0 + m * element_size_,
903 ft + m * element_size_);
904 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
905 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
908 for (m = 0; m <= ntau_; m++) {
909 element_mult<T, LARGESIZE>(size1_, xtemp, x0 + m * element_size_,
911 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
912 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
914 ftemp = ft + tstp * element_size_;
915 x0 = lesptr(0, tstp);
916 for (m = 0; m <= tstp; m++) {
917 element_mult<T, LARGESIZE>(size1_, xtemp, x0 + m * element_size_,
919 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
920 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
952 template <
typename T>
956 cplx *xtemp, *ftemp, *x0, *f0, *fcc;
957 xtemp =
new cplx[element_size_];
958 fcc =
new cplx[element_size_];
959 assert(tstp >= -1 && ft.
nt() >= tstp &&
960 ft.
size1() == size1_ && ft.
size2() == size2_ &&
961 "tstp >= -1 && ft.nt() >= tstp && ft.size1() == size1_ && ft.size2() == size2_");
964 element_conj<T, LARGESIZE>(size1_, fcc, f0);
967 for (m = 0; m <= ntau_; m++) {
968 element_mult<T, LARGESIZE>(size1_, xtemp, fcc,
969 x0 + m * element_size_);
970 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
971 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
974 ftemp = ft.
ptr(tstp);
975 element_conj<T, LARGESIZE>(size1_, fcc, ftemp);
976 x0 = retptr(tstp, 0);
977 for (m = 0; m <= tstp; m++) {
978 element_mult<T, LARGESIZE>(size1_, xtemp, fcc,
979 x0 + m * element_size_);
980 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
981 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
984 for (m = 0; m <= ntau_; m++) {
985 element_mult<T, LARGESIZE>(size1_, xtemp, fcc,
986 x0 + m * element_size_);
987 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
988 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
990 x0 = lesptr(0, tstp);
991 for (m = 0; m <= tstp; m++) {
992 element_conj<T, LARGESIZE>(size1_, fcc, ft.
ptr(m));
993 element_mult<T, LARGESIZE>(size1_, xtemp, fcc,
994 x0 + m * element_size_);
995 element_smul<T, LARGESIZE>(size1_, xtemp, weight);
996 element_set<T, LARGESIZE>(size1_, x0 + m * element_size_, xtemp);
1037 template <
typename T>
1039 int size,
int sig) {
1044 element_size_ = size1_ * size2_;
1051 }
else if (tstp >= 0) {
1054 tv_ = data + (tstp_ + 1) * element_size_;
1055 les_ = data + (tstp_ + 1 + ntau_ + 1) * element_size_;
1082 template <
typename T>
1084 assert(tstp>=-1 && tstp<=g.
nt());
1089 element_size_ = size1_ * size2_;
1096 }
else if (tstp >= 0) {
1098 ret_ = g.retptr(tstp, 0);
1099 tv_ = g.tvptr(tstp, 0);
1100 les_ = g.lesptr(0, tstp);
1125 template <
typename T>
1131 element_size_ = size1_ * size2_;
1138 }
else if (tstp_ >= 0) {
1169 template <
typename T>
1173 memcpy(mat_, mat,
sizeof(CPLX) * (ntau_ + 1) * element_size_);
1177 }
else if (tstp_ >= 0) {
1179 memcpy(ret_, ret,
sizeof(CPLX) * (tstp_ + 1) * element_size_);
1180 memcpy(les_, les,
sizeof(CPLX) * (tstp_ + 1) * element_size_);
1181 memcpy(tv_, tv,
sizeof(CPLX) * (ntau_ + 1) * element_size_);
1203 template <
typename T>
1205 assert(tstp_==g.tstp_ && size1_ == g.
size1() && size2_ == g.
size2() && ntau_ == g.
ntau());
1207 get_data(NULL, NULL, NULL, g.mat_);
1209 get_data(g.ret_, g.les_, g.tv_, NULL);
1231 template <
typename T>
1257 template <
typename T>
1260 int len = (2 * (tstp + 1) + ntau_ + 1) * element_size_;
1262 assert(tstp_ == tstp);
1263 if (timestep.total_size_ < len)
1264 timestep.
resize(tstp, ntau_, size1_);
1266 timestep.tstp_ = tstp;
1267 timestep.ntau_ = ntau_;
1268 timestep.size1_ = size1_;
1270 memcpy(x, mat_,
sizeof(
cplx) * (ntau_ + 1) * element_size_);
1272 memcpy(x, ret_,
sizeof(
cplx) * (tstp + 1) * element_size_);
1273 memcpy(x + (tstp + 1) * element_size_, tv_,
1274 sizeof(
cplx) * (ntau_ + 1) * element_size_);
1275 memcpy(x + (tstp + 1 + ntau_ + 1) * element_size_, les_,
1276 sizeof(
cplx) * (tstp + 1) * element_size_);
1308 template <
typename T>
1311 int i, sij = i1 * size2_ + i2, tij = j1 * g.
size2() + j2;
1312 assert(tstp_==g.tstp_ && ntau_ == g.ntau_);
1314 assert(i1>=0 && i1 <=size1_ -1);
1315 assert(i2>=0 && i2 <=size2_ -1);
1316 assert(j1>=0 && j1 <=g.size1_-1);
1317 assert(j2>=0 && j2 <=g.size2_-1);
1320 for (i = 0; i <= ntau_; i++)
1321 matptr(i)[sij] = g.matptr(i)[tij];
1323 for (i = 0; i <= tstp_; i++)
1324 retptr(i)[sij] = g.retptr(i)[tij];
1325 for (i = 0; i <= ntau_; i++)
1326 tvptr(i)[sij] = g.tvptr(i)[tij];
1327 for (i = 0; i <= tstp_; i++)
1328 lesptr(i)[sij] = g.lesptr(i)[tij];
1360 template <
typename T>
1365 set_matrixelement(i1, i2, tmp, j1, j2);
1369 #define HERM_MATRIX_INCR_TSTP \ 1370 if (alpha == CPLX(1.0, 0.0)) { \ 1371 for (i = 0; i < len; i++) \ 1374 for (i = 0; i < len; i++) \ 1375 x0[i] += alpha * x[i]; \ 1401 template <
typename T>
1405 assert(tstp_==g.tstp_ && ntau_ ==g.ntau_ && size1_ == g.size1_ && size2_ == g.size2_);
1410 len = (ntau_ + 1) * element_size_;
1413 HERM_MATRIX_INCR_TSTP
1415 len = (tstp_ + 1) * element_size_;
1418 HERM_MATRIX_INCR_TSTP
1421 HERM_MATRIX_INCR_TSTP
1422 len = (ntau_ + 1) * element_size_;
1425 HERM_MATRIX_INCR_TSTP
1428 #undef HERM_MATRIX_INCR_TSTP 1453 template <
typename T>
1457 incr_timestep(tmp, alpha);
1459 #define HERM_MATRIX_INCR_TSTP \ 1460 if (alpha == 1.0) { \ 1461 for (i = 0; i < len; i++) \ 1464 for (i = 0; i < len; i++) \ 1465 x0[i] += alpha * x[i]; \ 1491 template <
typename T>
1495 assert(tstp_==g.tstp_ && ntau_ == g.ntau_ && size1_ == g.size1_ && size2_ == g.size2_);
1500 len = (ntau_ + 1) * element_size_;
1503 HERM_MATRIX_INCR_TSTP
1505 len = (tstp_ + 1) * element_size_;
1508 HERM_MATRIX_INCR_TSTP
1511 HERM_MATRIX_INCR_TSTP
1512 len = (ntau_ + 1) * element_size_;
1515 HERM_MATRIX_INCR_TSTP
1518 #undef HERM_MATRIX_INCR_TSTP 1542 template <
typename T>
1546 incr_timestep(tmp, alpha);
1568 template <
typename T>
1574 for (m = 0; m <= ntau_; m++) {
1575 element_smul<T, LARGESIZE>(size1_, x0 + m * element_size_,
1580 for (m = 0; m <= tstp_; m++) {
1581 element_smul<T, LARGESIZE>(size1_, x0 + m * element_size_,
1585 for (m = 0; m <= ntau_; m++) {
1586 element_smul<T, LARGESIZE>(size1_, x0 + m * element_size_,
1590 for (m = 0; m <= tstp_; m++) {
1591 element_smul<T, LARGESIZE>(size1_, x0 + m * element_size_,
1598 #if CNTR_USE_MPI == 1 1601 template <
typename T>
1602 void my_mpi_reduce(std::complex<T> *data,
int len,
int root) {
1603 std::cerr << __PRETTY_FUNCTION__ <<
", LEN=" << len
1604 <<
" ... NOT DEFINED FOR THIS TYPE " << std::endl;
1611 inline void my_mpi_reduce<double>(std::complex<double> *data,
int len,
int root) {
1613 MPI_Comm_rank(MPI_COMM_WORLD, &tid);
1614 MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
1615 assert(root>=0 && root <= ntasks -1);
1618 MPI_Reduce(MPI_IN_PLACE, (
double *)data, 2 * len,
1619 MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
1621 MPI_Reduce((
double *)data, (
double *)data, 2 * len,
1622 MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
1646 template <
typename T>
1647 void herm_matrix_timestep_view<T>::MPI_Reduce(
int root) {
1649 my_mpi_reduce<T>(mat_, (ntau_ + 1) * element_size_, root);
1651 my_mpi_reduce<T>(les_, (tstp_ + 1) * element_size_, root);
1652 my_mpi_reduce<T>(ret_, (tstp_ + 1) * element_size_, root);
1653 my_mpi_reduce<T>(tv_, (ntau_ + 1) * element_size_, root);
1679 template <
typename T>
1681 assert(tstp == tstp_);
1683 my_mpi_reduce<T>(mat_, (ntau_ + 1) * element_size_, root);
1685 my_mpi_reduce<T>(les_, (tstp_ + 1) * element_size_, root);
1686 my_mpi_reduce<T>(ret_, (tstp_ + 1) * element_size_, root);
1687 my_mpi_reduce<T>(tv_, (ntau_ + 1) * element_size_, root);
1710 template <
typename T>
1712 int numtasks,taskid;
1713 MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
1714 MPI_Comm_rank(MPI_COMM_WORLD, &taskid);
1716 assert(tstp == tstp_);
1717 if (
sizeof(T) ==
sizeof(
double)){
1719 MPI_Bcast(mat_, (ntau_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, MPI_COMM_WORLD);
1721 MPI_Bcast(les_, (tstp_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, MPI_COMM_WORLD);
1722 MPI_Bcast(ret_, (tstp_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, MPI_COMM_WORLD);
1723 MPI_Bcast(tv_, (ntau_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, MPI_COMM_WORLD);
1727 MPI_Bcast(mat_, (ntau_ + 1) * element_size_, MPI_COMPLEX, root, MPI_COMM_WORLD);
1729 MPI_Bcast(les_, (tstp_ + 1) * element_size_, MPI_COMPLEX, root, MPI_COMM_WORLD);
1730 MPI_Bcast(ret_, (tstp_ + 1) * element_size_, MPI_COMPLEX, root, MPI_COMM_WORLD);
1731 MPI_Bcast(tv_, (ntau_ + 1) * element_size_, MPI_COMPLEX, root, MPI_COMM_WORLD);
1756 template <
typename T>
1759 MPI_Comm_rank(MPI_COMM_WORLD, &taskid);
1760 assert(tstp == tstp_);
1761 if (!(taskid == dest)) {
1762 if (
sizeof(T) ==
sizeof(
double)){
1764 MPI_Send(mat_, (ntau_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, dest, tag, MPI_COMM_WORLD);
1766 MPI_Send(les_, (tstp_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, dest, tag, MPI_COMM_WORLD);
1767 MPI_Send(ret_, (tstp_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, dest, tag, MPI_COMM_WORLD);
1768 MPI_Send(tv_, (ntau_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, dest, tag, MPI_COMM_WORLD);
1773 MPI_Send(mat_, (ntau_ + 1) * element_size_, MPI_COMPLEX, dest, tag, MPI_COMM_WORLD);
1775 MPI_Send(les_, (tstp_ + 1) * element_size_, MPI_COMPLEX, dest, tag, MPI_COMM_WORLD);
1776 MPI_Send(ret_, (tstp_ + 1) * element_size_, MPI_COMPLEX, dest, tag, MPI_COMM_WORLD);
1777 MPI_Send(tv_, (ntau_ + 1) * element_size_, MPI_COMPLEX, dest, tag, MPI_COMM_WORLD);
1804 template <
typename T>
1807 MPI_Comm_rank(MPI_COMM_WORLD, &taskid);
1808 assert(tstp == tstp_);
1809 if (!(taskid == root)) {
1810 if (
sizeof(T) ==
sizeof(
double))
1812 MPI_Recv(mat_, (ntau_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, tag, MPI_COMM_WORLD);
1814 MPI_Recv(les_, (tstp_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, tag, MPI_COMM_WORLD);
1815 MPI_Recv(ret_, (tstp_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, tag, MPI_COMM_WORLD);
1816 MPI_Recv(tv_, (ntau_ + 1) * element_size_, MPI_DOUBLE_COMPLEX, root, tag, MPI_COMM_WORLD);
1820 MPI_Recv(mat_, (ntau_ + 1) * element_size_, MPI_COMPLEX, root, tag, MPI_COMM_WORLD);
1822 MPI_Recv(les_, (tstp_ + 1) * element_size_, MPI_COMPLEX, root, tag, MPI_COMM_WORLD);
1823 MPI_Recv(ret_, (tstp_ + 1) * element_size_, MPI_COMPLEX, root, tag, MPI_COMM_WORLD);
1824 MPI_Recv(tv_, (ntau_ + 1) * element_size_, MPI_COMPLEX, root, tag, MPI_COMM_WORLD);
1852 #if CNTR_USE_HDF5 == 1 1853 template <
typename T>
1855 store_int_attribute_to_hid(group_id, std::string(
"ntau"), ntau_);
1856 store_int_attribute_to_hid(group_id, std::string(
"tstp"), tstp_);
1857 store_int_attribute_to_hid(group_id, std::string(
"sig"), sig_);
1858 store_int_attribute_to_hid(group_id, std::string(
"size1"), size1_);
1859 store_int_attribute_to_hid(group_id, std::string(
"size2"), size2_);
1860 store_int_attribute_to_hid(group_id, std::string(
"element_size"),
1862 hsize_t len_shape = 3, shape[3];
1866 shape[0] = ntau_ + 1;
1867 store_cplx_array_to_hid(group_id, std::string(
"mat"), matptr(0),
1869 }
else if (tstp_ > -1) {
1870 shape[0] = (tstp_ + 1);
1872 store_cplx_array_to_hid(group_id, std::string(
"ret"), retptr(0),
1874 store_cplx_array_to_hid(group_id, std::string(
"les"), lesptr(0),
1876 shape[0] = (ntau_ + 1);
1877 store_cplx_array_to_hid(group_id, std::string(
"tv"), tvptr(0), shape,
1903 template <
typename T>
1905 const char *groupname) {
1906 hid_t sub_group_id = create_group(group_id, groupname);
1907 this->write_to_hdf5(sub_group_id);
1908 close_group(sub_group_id);
1932 template <
typename T>
1934 const char *groupname) {
1935 hid_t file_id = open_hdf5_file(filename);
1936 this->write_to_hdf5(file_id, groupname);
1937 close_hdf5_file(file_id);
1959 template <
typename T>
1962 int tstp = read_primitive_type<int>(group_id,
"tstp");
1963 int ntau = read_primitive_type<int>(group_id,
"ntau");
1964 int sig = read_primitive_type<int>(group_id,
"sig");
1965 int size1 = read_primitive_type<int>(group_id,
"size1");
1966 int size2 = read_primitive_type<int>(group_id,
"size2");
1967 int element_size = read_primitive_type<int>(group_id,
"element_size");
1969 assert(element_size == element_size_ && size1 == size1_ && size2 == size2_ && tstp == tstp_ && ntau ==ntau_);
1973 hsize_t mat_size = (ntau + 1) * element_size;
1974 read_primitive_type_array(group_id,
"mat", mat_size, matptr(0));
1975 }
else if (tstp_ > -1) {
1976 hsize_t ret_size = (tstp_ + 1) * element_size;
1977 read_primitive_type_array(group_id,
"ret", ret_size, retptr(0));
1978 hsize_t les_size = (tstp_ + 1) * element_size;
1979 read_primitive_type_array(group_id,
"les", les_size, lesptr(0));
1980 hsize_t tv_size = (ntau_ + 1) * element_size;
1981 read_primitive_type_array(group_id,
"tv", tv_size, tvptr(0));
2006 template <
typename T>
2008 const char *groupname) {
2009 hid_t sub_group_id = open_group(group_id, groupname);
2010 this->read_from_hdf5(sub_group_id);
2011 close_group(sub_group_id);
2034 template <
typename T>
2036 const char *groupname) {
2037 hid_t file_id = read_hdf5_file(filename);
2038 this->read_from_hdf5(file_id, groupname);
2039 close_hdf5_file(file_id);
2061 template <
typename T>
2063 assert(tstp==tstp_);
2067 x1 = *matptr(ntau_);
2070 x1 = *lesptr(tstp_);
2071 return CPLX(0.0, sig_) * x1;
2095 template <
typename T>
2097 assert(tstp==tstp_);
2099 M = -(*matptr(ntau_));
2101 M = CPLX(0.0, sig_)*(*lesptr(tstp_));
2124 template <
typename T>
2125 template <
class Matrix>
2127 assert(tstp == tstp_);
2132 herm_matrix_READ_ELEMENT M *= (-1.0);
2135 herm_matrix_READ_ELEMENT M *= CPLX(0.0, 1.0 * sig_);
2139 #undef herm_matrix_READ_ELEMENT 2140 #undef herm_matrix_READ_ELEMENT_MINUS_CONJ 2145 #endif // CNTR_HERM_TIMESTEP_VIEW_IMPL_H void incr_timestep(herm_matrix_timestep_view< T > &g, std::complex< T > alpha)
Class herm_matrix_timestep_view serves for interfacing with class herm_matrix_timestep without copyi...
Class herm_matrix_timestep deals with contour objects at a particular timestep .
void smul(T alpha)
Multiply herm_matrix_timestep_view with scalar weight.
herm_matrix_timestep_view()
void Recv_timestep(int tstp, int root, int tag)
Recevies the herm_matrix_timestep_view at a given time step from a specific task.
void resize(int nt, int ntau, int size1)
Resizes herm_matrix_timestep object with respect to the number of points on the Matsubara branch and...
std::complex< double > cplx
herm_matrix_timestep_view & operator=(const herm_matrix_timestep_view &g)
Copy assignment operator for herm_matrix_timestep_view g class.
void set_matrixelement(int i1, int i2, herm_matrix_timestep_view< T > &g, int j1, int j2)
Set the matrix element of for each component from
Class function for objects with time on real axis.
void set_timestep(int tstp, herm_matrix< T > &g1)
Sets all components of herm_matrix_timestep_view to the components of a given herm_matrix at time st...
void get_timestep(int tstp, herm_matrix_timestep< T > ×tep)
Get timestep into herm_matrix_timestep
~herm_matrix_timestep_view()
void get_data(herm_matrix_timestep_view< T > &g)
Return the data into herm_matrix_timestep_view
void Reduce_timestep(int tstp, int root)
MPI reduce for the herm_matrix_timestep_view.
void read_from_hdf5(hid_t group_id, const char *groupname)
Read herm_matrix_timestep_view from hdf5 group given by group ID group_id and group name groupname...
Class herm_matrix for two-time contour objects with hermitian symmetry.
void Send_timestep(int tstp, int dest, int tag)
Sends the herm_matrix_timestep_view at a given time step to a specific task.
void set_timestep_zero(int tstp)
Sets all components at time step tstp to zero.
void Bcast_timestep(int tstp, int root)
Broadcasts the herm_matrix_timestep_view at a given time step to all ranks.
void write_to_hdf5(hid_t group_id)
Write herm_matrix_timestep_view to hdf5 group given by group_id.
void set_to_data(std::complex< T > *data, int tstp, int ntau, int size, int sig)
void left_multiply_hermconj(int tstp, function< T > &ft, T weight=1.0)
Left-multiplies the herm_matrix_timestep_view with the hermitian conjugate of a contour function...