示例#1
0
文件: io.c 项目: mrG7/hpg-libs
void save_ref_vector(ref_vector *vector, const char *directory, const char *name) {

  size_t err=0;
  FILE *fp;

  char path[500];

  path[0]='\0';
  strcat(path, directory);
  strcat(path, "/");
  strcat(path, name);
  strcat(path, ".vec");

  fp  = fopen(path,  "wb+");
  check_file_open(fp, path);

  err = fwrite(&vector->n,      sizeof(uint64_t), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(&vector->dollar, sizeof(uint64_t), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(vector->vector, sizeof(uint8_t), vector->n, fp);
  check_file_write(err, vector->n, path);

  fclose(fp);

}
示例#2
0
void save_comp_vector(comp_vector *vector, const char *directory, const char *name) {

  size_t err=0;
  FILE *fp;

  char path[500];

  path[0]='\0';
  strcat(path, directory);
  strcat(path, "/");
  strcat(path, name);
  strcat(path, ".vec");

  fp  = fopen(path,  "wb+");
  check_file_open(fp, path);

  err = fwrite(&vector->siz,   sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(&vector->n,     sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(&vector->ratio, sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(vector->vector, sizeof(SA_TYPE), vector->n, fp);
  check_file_write(err, vector->n, path);

  fclose(fp);

}
示例#3
0
void save_comp_matrix(comp_matrix *matrix, const char *directory, const char *name) {

  size_t err=0;
  FILE *fp;

  char path[500];

  path[0]='\0';
  strcat(path, directory);
  strcat(path, "/");
  strcat(path, name);
  strcat(path, ".desp");

  fp  = fopen(path,  "wb+");
  check_file_open(fp, path);

  err = fwrite(&matrix->siz,    sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(&matrix->n_desp, sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(&matrix->m_desp, sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  for (SA_TYPE i=0; i<matrix->n_desp; i++) {
    err = fwrite(matrix->desp[i], sizeof(SA_TYPE), matrix->m_desp, fp);
    check_file_write(err, matrix->m_desp, path);
  }

  fclose(fp);

#if defined FM_COMP_32 || FM_COMP_64

  path[0]='\0';
  strcat(path, directory);
  strcat(path, "/");
  strcat(path, name);
  strcat(path, ".count");

  fp  = fopen(path,  "wb+");
  check_file_open(fp, path);

  err = fwrite(&matrix->n_count, sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  err = fwrite(&matrix->m_count, sizeof(SA_TYPE), 1, fp);
  check_file_write(err, 1, path);

  for (SA_TYPE i=0; i<matrix->n_count; i++) {
    err = fwrite(matrix->count[i], sizeof(FM_COMP_TYPE), matrix->m_count, fp);
    check_file_write(err, matrix->m_count, path);
  }

  fclose(fp);

#endif

}