/* Last edited on 2023-03-17 22:33:27 by stolfi */ typedef double complex cmp; /* A complex number in standard form. */ void odt_read_cmp_image(char *name, int32_t *mP, int32_t *nP, cmp **aP); /* Reads a double-valued mask image from file "{name}", stores it into a newly-allocated vector ov complex numbers. Stores the number of rows {m} into {*mP}, the number of columns {n} into {*nP}, and the address of the element vector into {*aP}. The element in row {i} and column {j} is {a[i*n+j]}. The file must contain a line with {m} and {n}, then the elements, one per line, in row-by-row order. */ void odt_read_cmp_image(char *name, int32_t *mP, int32_t *nP, cmp **aP); { FILE *f = open_read(name, TRUE); int32_t m,n; fscanf(f, "%d %d", &m, &n); cmp *a = (cmp *)notnull(malloc(m*n*sizeof(cmp)), "no mem"); int32_t i,j; for (i = 0; i < m; i++) for (j = 0; j < n; j++) { double az = fget_double(f); a[i*n+j] = (cmp){ az, 0 }; } fclose(f); (*mP) = m; (*nP) = n; (*aP) = a; } typedef double complex cmp; /* A complex number in standard form. */ void odt_read_cmp_image(char *name, int32_t *mP, int32_t *nP, cmp **aP); /* Reads a double-valued mask image from file "{name}", stores it into a newly-allocated vector ov complex numbers. Stores the number of rows {m} into {*mP}, the number of columns {n} into {*nP}, and the address of the element vector into {*aP}. The element in row {i} and column {j} is {a[i*n+j]}. The file must contain a line with {m} and {n}, then the elements, one per line, in row-by-row order. */