NESSi  v1.0.2
The NonEquilibrium Systems Simulation Library

◆ read_from_file() [1/2]

template<typename T >
void cntr::herm_matrix< T >::read_from_file ( const char *  file)

Reads the herm_matrix from file in text format.

Purpose

Reads the herm_matrix to file in plain text format, which happens been created with the corresponding routine herm_matrix::print_to_file.

Parameters
file

The input file name.

Definition at line 1376 of file cntr_herm_matrix_impl.hpp.

1376  {
1377  int i, n, m, j, l, size1, sg, sig;
1378  double real, imag;
1379  std::string s;
1380  std::ifstream out;
1381  out.open(file, std::ios::in);
1382  if (!(out >> s >> n >> m >> size1 >> sig)) {
1383  std::cerr << "read G from file " << file << " error in file"
1384  << std::endl;
1385  abort();
1386  }
1387  if (n > nt_ || m != ntau_ || size1 != size1_)
1388  resize(n, m, size1);
1389  sig_ = sig;
1390  sg = element_size_;
1391  for (j = 0; j <= ntau_; j++) {
1392  out >> s >> s;
1393  for (l = 0; l < sg; l++) {
1394  if (!(out >> real >> imag)) {
1395  std::cerr << "read G from file " << file << " error at mat ("
1396  << j << ")" << std::endl;
1397  abort();
1398  }
1399  matptr(j)[l] = std::complex<T>(real, imag);
1400  }
1401  }
1402  if (n >= 0) {
1403  for (i = 0; i <= n; i++) {
1404  for (j = 0; j <= i; j++) {
1405  out >> s >> s >> s;
1406  for (l = 0; l < sg; l++) {
1407  if (!(out >> real >> imag)) {
1408  std::cerr << "read G from file " << file
1409  << " error at ret (" << i << "," << j << ")"
1410  << std::endl;
1411  abort();
1412  }
1413  retptr(i, j)[l] = std::complex<T>(real, imag);
1414  }
1415  }
1416  }
1417  for (i = 0; i <= n; i++) {
1418  for (j = 0; j <= ntau_; j++) {
1419  out >> s >> s >> s;
1420  for (l = 0; l < sg; l++) {
1421  if (!(out >> real >> imag)) {
1422  std::cerr << "read G from file " << file
1423  << " error at tv (" << i << "," << j << ")"
1424  << std::endl;
1425  abort();
1426  }
1427  tvptr(i, j)[l] = std::complex<T>(real, imag);
1428  }
1429  }
1430  }
1431  for (j = 0; j <= n; j++) {
1432  for (i = 0; i <= j; i++) {
1433  out >> s >> s >> s;
1434  for (l = 0; l < sg; l++) {
1435  if (!(out >> real >> imag)) {
1436  std::cerr << "read G from file " << file
1437  << " error at les (" << i << "," << j << ")"
1438  << std::endl;
1439  abort();
1440  }
1441  lesptr(i, j)[l] = std::complex<T>(real, imag);
1442  }
1443  }
1444  }
1445  }
1446  out.close();
1447 }
void resize(int nt, int ntau, int size1)
Resizes herm_matrix object with respect to the number of time points nt, points on the Matsubara bra...