예제 #1
0
void write_eig_sys_bin(const char* prefix, const int config_i, const int t, const int nb_ev, Eigen::MatrixXcd& V) {
  const int V3 = pars -> get_int("V3");
  std::string path = pars -> get_path("res");
  //set up filename
  char file [200];
  sprintf(file, "%s/%s.%04d.%03d", path.c_str(), prefix, config_i, t);
  //sprintf(file, "%s.%04d.%03d", prefix, config_i, t);
  if(check_trace(V, nb_ev) != true){
    std::cout << "Timeslice: " << t << ": Eigenvectors damaged, abort writing" << std::endl;
    exit(1);
  }
  std::cout << "Writing to file:" << file << std::endl;
  std::ofstream outfile(file, std::ofstream::binary);
  std::streamsize  begin = outfile.tellp();
  std::streamsize eigsys_bytes =2*3*V3*nb_ev*sizeof(double); 
  outfile.write(reinterpret_cast<char*> (V.data()), eigsys_bytes);
  std::streamsize end = outfile.tellp();
  if ( (end - begin)/eigsys_bytes != 1 ){
    std::cout << "Timeslice:  " << t << " Error: write incomplete, exiting" << std::endl;
    std::cout << (end-begin) << " bytes instead of expected "<< eigsys_bytes << " bytes" << std::endl;
    exit(1);
  } 
  //std::cout << end - begin << " bytes written" << std::endl;
  outfile.close();

}
예제 #2
0
파일: utility.cpp 프로젝트: NICTA/obsidian
 std::string cmplxMatrixString(const Eigen::MatrixXcd& m)
 {
   // Make a string from the bytes
   return std::string((char *) m.data(), m.size() * sizeof(m(0, 0)));
 }