void ancestrymap2lfmm (char *input_file, char* output_file, int *N, int *M) { int *data; int nb; double tmp; // number of lines and columns *N = nb_ind_ancestrymap(input_file); nb = nb_lines(input_file, 1000); tmp = (double)nb / (double)(*N); if (tmp != floor(tmp)) { printf("Error: incorrect number of lines in %s.\n",input_file); exit(1); } *M = (int)tmp; // allocate memory data = (int *) malloc((*N)*(*M) * sizeof(int)); // read in ancestrymap format read_ancestrymap(input_file, *N, *M, data); // write in lfmm format write_data_int(output_file, *N, *M, data); // free memory free(data); }
void option_case(char *name, int opt) { t_data e; char **buf; if (opt != 2 && opt != 1) put_usage_error("./fdf"); open_check(name); buf = get_data(name); e.opt = opt; if (opt == 1) { e.para = 0; e.iso = 1; } if (opt == 2) { e.para = 1; e.iso = 0; } e.y_max = nb_lines(buf); e.x_max = nb_points(buf, e.y_max); e.data = read_map(buf, e.x_max, e.y_max); e.cal_data = NULL; init_t_m(&e); create_img(&e); free_tab(&e); }
int build_comm(char *filename,double ***pcomm){ int i; int N; double **comm; N=nb_lines(filename); comm=(double**)malloc(N*sizeof(double*)); for(i=0;i<N;i++) comm[i]=(double*)malloc(N*sizeof(double)); init_comm(filename,N,comm); *pcomm=comm; return N; }
int build_comm(char *filename,double ***pcomm) { double **comm = NULL; int i,N; if(get_verbose_level() >= INFO) printf("Reading communication matrix file: %s\n",filename); N = nb_lines(filename); comm = (double**)MALLOC(N*sizeof(double*)); for( i = 0 ; i < N ; i++) /* the last column stores the sum of the line*/ comm[i] = (double*)MALLOC((N+1)*sizeof(double)); init_comm(filename,N,comm); *pcomm = comm; if(get_verbose_level() >= INFO) printf("Communication matrix built from %s!\n",filename); return N; }