// allocates memory void setup() { int i; double sc = 0, sm = 0; C = pow(2., L/2.); // constant U = (1ul<<L)-1; // universe mask for (i = 256; i--; W[i] = ((ones(i)&1) ? -1. : 1.)/C); // allocate memory and calculate crossover and mutation Chi = calloc((1ul<<L),sizeof(double)); Mu = calloc((1ul<<L),sizeof(double)); Cr = allocdist((1ul<<L)); M = allocdist((1ul<<L)); initOneCount(); P0 = malloc((1ul<<L)*sizeof(double)); P1 = malloc((1ul<<L)*sizeof(double)); P2 = malloc((1ul<<L)*sizeof(double)); P3 = malloc((1ul<<L)*sizeof(double)); chiDist(12); muDist(12); // initialize distributions for Mu and Chi with g = 12 for(i = 0; i < 1ul<<L; i++){ // copy mutation and crossover distributions to Cr and M distributions Cr->p[i] = Chi[i]; sc += Chi[i]; M->p[i] = Mu[i]; sm += Mu[i]; } initdist(Cr, sc); // initialize Cr distribution initdist(M, sm); // initialize M distribution Mh = malloc((1ul<<L)*sizeof(double *)); for (i = 1ul<<L; i--;) Mh[i] = malloc((1ul<<L)*sizeof(double)); walsh(Mh); // calculate and install values in mixing matrix in walsh basis (Mhat) GZ = malloc((1ul<<L)*sizeof(double)); GW = malloc((1ul<<L)*sizeof(double)); }
int main_walsh(int argc, char* argv[]) { long bsize[3] = { 20, 20, 20 }; long calsize[3] = { 24, 24, 24 }; const struct opt_s opts[] = { { 'r', true, opt_vec3, &calsize, " cal_size\tLimits the size of the calibration region." }, { 'R', true, opt_vec3, &calsize, NULL }, { 'b', true, opt_vec3, &bsize, " block_size\tBlock size." }, { 'B', true, opt_vec3, &bsize, NULL }, }; cmdline(&argc, argv, 2, 2, usage_str, help_str, ARRAY_SIZE(opts), opts); long dims[DIMS]; complex float* in_data = load_cfl(argv[1], DIMS, dims); assert((dims[0] == 1) || (calsize[0] < dims[0])); assert((dims[1] == 1) || (calsize[1] < dims[1])); assert((dims[2] == 1) || (calsize[2] < dims[2])); assert(1 == dims[MAPS_DIM]); long caldims[DIMS]; complex float* cal_data = extract_calib(caldims, calsize, dims, in_data, false); unmap_cfl(DIMS, dims, in_data); debug_printf(DP_INFO, "Calibration region %ldx%ldx%ld\n", caldims[0], caldims[1], caldims[2]); dims[COIL_DIM] = dims[COIL_DIM] * (dims[COIL_DIM] + 1) / 2; complex float* out_data = create_cfl(argv[2], DIMS, dims); walsh(bsize, dims, out_data, caldims, cal_data); debug_printf(DP_INFO, "Done.\n"); md_free(cal_data); unmap_cfl(DIMS, dims, out_data); exit(0); }