NESSi  v1.0.2
The NonEquilibrium Systems Simulation Library

◆ read_from_file() [2/2]

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

Reads the herm_matrix up to a given number of time steps 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. The herm_matrix is read up to a given number of time steps nt1.

Parameters
nt1

Read up to this time step.

file

The input file name.

Definition at line 1469 of file cntr_herm_matrix_impl.hpp.

1469  {
1470  int i, n, m, j, l, size1, sg, sig;
1471  double real, imag;
1472  std::string s;
1473  std::ifstream out;
1474  out.open(file, std::ios::in);
1475 
1476  if (!(out >> s >> n >> m >> size1 >> sig)) {
1477  std::cerr << "read G from file " << file << " error in file"
1478  << std::endl;
1479  abort();
1480  }
1481 
1482  assert(nt1 <= nt_ && "nt1 > nt_");
1483  assert(nt1 <= n && "nt1 > n");
1484  assert(m == ntau_ && "m /= ntau_");
1485  assert(size1 == size1_ && "size1 /= size1_");
1486 
1487  sg = size1 * size1;
1488  if (nt1 >= -1) {
1489  for (j = 0; j <= ntau_; j++) {
1490  out >> s >> s;
1491  for (l = 0; l < sg; l++) {
1492  if (!(out >> real >> imag)) {
1493  std::cerr << "read G from file " << file
1494  << " error at mat (" << j << ")" << std::endl;
1495  abort();
1496  }
1497  matptr(j)[l] = std::complex<T>(real, imag);
1498  }
1499  }
1500  }
1501  if (n >= 0) {
1502  for (i = 0; i <= n; i++) {
1503  for (j = 0; j <= i; j++) {
1504  out >> s >> s >> s;
1505  for (l = 0; l < sg; l++) {
1506  if (!(out >> real >> imag)) {
1507  std::cerr << "read G from file " << file
1508  << " error at ret (" << i << "," << j << ")"
1509  << std::endl;
1510  abort();
1511  }
1512  if (i <= nt1)
1513  retptr(i, j)[l] = std::complex<T>(real, imag);
1514  }
1515  }
1516  }
1517  for (i = 0; i <= n; i++) {
1518  for (j = 0; j <= ntau_; j++) {
1519  out >> s >> s >> s;
1520  for (l = 0; l < sg; l++) {
1521  if (!(out >> real >> imag)) {
1522  std::cerr << "read G from file " << file
1523  << " error at tv (" << i << "," << j << ")"
1524  << std::endl;
1525  abort();
1526  }
1527  if (i <= nt1)
1528  tvptr(i, j)[l] = std::complex<T>(real, imag);
1529  }
1530  }
1531  }
1532  for (j = 0; j <= n; j++) {
1533  for (i = 0; i <= j; i++) {
1534  out >> s >> s >> s;
1535  for (l = 0; l < sg; l++) {
1536  if (!(out >> real >> imag)) {
1537  std::cerr << "read G from file " << file
1538  << " error at les (" << i << "," << j << ")"
1539  << std::endl;
1540  abort();
1541  }
1542  if (j <= nt1)
1543  lesptr(i, j)[l] = std::complex<T>(real, imag);
1544  }
1545  }
1546  }
1547  }
1548  out.close();
1549 }