# include # include "./common.hh" DiscSignal *get_from_file(char *str) { FILE *f = fopen(str, "r"); int d; fscanf(f, "%d\n", &d); double *tmp = (double*)malloc(d*sizeof(double)); for (int i = 0; i < d; i++) { fscanf(f, "%lf ", &(tmp[i])); } fclose(f); return new DiscSignal(tmp, d); } void print_to_file(DiscSignal *sig, char *file) { FILE *f = fopen(file, "w"); fprintf(f, "%d\n", sig->length()); for (int i = 0; i < sig->length(); i++) { fprintf(f, "%3.4lf ", (*sig)[i]); } fclose(f); }