7 int gstmm(
double **V,
int n,
int m,
int id0,
int l, fftw_complex *T_fft,
8 int lambda, fftw_complex *V_fft,
double *V_rfft, fftw_plan plan_f,
9 fftw_plan plan_b,
int blocksize,
int nfft,
int *id0gap,
int *lgap,
14 int idf = id0 + l - 1;
17 int clast_1 = (idf + 1) / n;
18 int m_eff = clast - cfirst + 1;
36 nfullcol = (l - (n - id0 % n) - (id0 + l) % n)
39 int ifirstgap, ilastgap;
49 for (k = 0; k < ngap; k++) {
50 if (lgap[k] != 0 && id0col < id0gap[k] + lgap[k])
break;
54 for (k = ngap - 1; k >= 0; k--) {
55 if (lgap[k] != 0 && id0gap[k] <= id0col)
break;
60 for (i = 0; i < ngap; i++) printf(
"id0gap[%d]=%d\n", i, id0gap[i]);
61 for (i = 0; i < ngap; i++) printf(
"lgap[%d]=%d\n", i, lgap[i]);
65 printf(
"lcol=%d\n", lcol);
66 for (i = 0; i < lcol; i++) printf(
"Vcol[%d]=%f\n", i, Vcol[i]);
69 gap_reduce(&Vcol, id0col, lcol, lambda, id0gap, lgap, ngap, &lcolnew,
76 for (i = 0; i < lcol; i++) printf(
"Vcolout[%d]=%f\n", i, Vcol[i]);
81 for (i = 0; i < l; i++) printf(
"(*V)[%d]=%f\n", i, (*V)[i]);
85 for (icol = 0; icol < nfullcol; icol++) {
92 gap_reduce(&Vcol, id0col, lcol, lambda, id0gap, lgap, ngap, &lcolnew,
103 if (idf % n != n && m > 1) {
107 Vcol = (*V) + id0col;
113 for (k = ngap - 1; k >= 0; k--) {
114 if (lgap[k] != 0 && id0gap[k] <= id0col)
break;
119 gap_reduce(&Vcol, id0col, lcol, lambda, id0gap, lgap, ngap, &lcolnew,
126 for (igap = 0; igap < ngap; igap++)
127 nnew += id0gap[igap] - min(id0gap[igap], lambda);
130 for (i = nnew * m; i < n * m; i++) (*V)[i] = 0;
133 for (i = 0; i < l; i++) printf(
"(*V)[%d]=%f\n", i, (*V)[i]);
162 int gap_reduce(
double **V,
int id0,
int l,
int lambda,
int *id0gap,
int *lgap,
163 int ngap,
int *newl,
int id0out) {
172 Vout = (*V) - (id0 - id0out);
175 if (id0gap[0] > id0) {
176 lg = id0gap[0] - id0;
177 printf(
"lg=%d\n", lg);
178 memmove(&(Vout)[0], &(*V)[0], lg *
sizeof(
double));
182 int offset_first = id0gap[0] - id0 + min(lambda, lgap[0]);
183 offset_first = max(0, offset_first);
189 printf(
"offset_first=%d\n", offset_first);
191 for (i = 0; i < l; i++) printf(
"(Vout)[%d]=%f\n", i, (Vout)[i]);
197 for (i = 0; i < (ngap - 1); i++) {
198 lg = id0gap[i + 1] - id0 - (id0gap[i] - id0 + lgap[i]);
199 printf(
"lg=%d\n", lg);
200 memmove(&(Vout)[offset_first], &(*V)[id0gap[i] - id0 + lgap[i]],
201 lg *
sizeof(
double));
203 for (ii = 0; ii < l; ii++) printf(
"(Vout)[%d]=%f\n", ii, (Vout)[ii]);
205 newid0gap_ip1 = offset_first + lg;
206 newlgap_ip1 = min(lambda, lgap[i + 1]);
207 for (k = newid0gap_ip1; k < newid0gap_ip1 + newlgap_ip1; k++)
210 printf(
"lg=%d ; lambda=%d ; lgap[i+1]=%d\n", lg, lambda, lgap[i + 1]);
211 offset_first += lg + min(lambda, lgap[i + 1]);
215 printf(
"offset_first=%d\n", offset_first);
216 for (i = 0; i < l; i++) printf(
"(Vout)[%d]=%f\n", i, (Vout)[i]);
220 if (id0gap[i] - id0 + lgap[i] < l) {
222 lg = l - (id0gap[i] - id0 + lgap[i]);
223 memmove(&(Vout)[offset_first], &(*V)[id0gap[i] - id0 + lgap[i]],
224 lg *
sizeof(
double));
226 *newl = offset_first;
228 *newl = offset_first - min(lambda, lgap[ngap - 1])
229 + min(lambda, (id0 + l - id0gap[ngap - 1]));
233 printf(
"l=%d, *newl=%d, offset_first=%d\n", l, *newl, offset_first);
235 for (i = offset_first; i < l; i++) (Vout)[i] = 0;
237 printf(
"*newl=%d\n", *newl);
252 int gap_masking(
double **V,
int l,
int *id0gap,
int *lgap,
int ngap) {
257 int offset_first = id0gap[0];
258 for (i = 0; i < (ngap - 1); i++) {
259 lg = id0gap[i + 1] - (id0gap[i] + lgap[i]);
260 memmove(&(*V)[offset_first], &(*V)[id0gap[i] + lgap[i]],
261 lg *
sizeof(
double));
266 lg = l - (id0gap[i] + lgap[i]);
268 memmove(&(*V)[offset_first], &(*V)[id0gap[i] + lgap[i]],
269 lg *
sizeof(
double));
273 for (i = offset_first; i < l; i++) (*V)[i] = 0;
290 int gap_filling(
double **V,
int l,
int *id0gap,
int *lgap,
int ngap) {
296 for (i = 0; i < ngap; i++) lgaptot += lgap[i];
301 id0_Vmv = id0gap[ngap - 1] + lgap[ngap - 1];
302 offset_last = id0_Vmv - lgaptot;
306 memmove(&(*V)[id0_Vmv], &(*V)[offset_last], lg *
sizeof(
double));
308 for (i = ngap - 2; i >= 0; i--) {
309 id0_Vmv = id0gap[i] + lgap[i];
310 lg = id0gap[i + 1] - id0_Vmv;
313 memmove(&(*V)[id0_Vmv], &(*V)[offset_last], lg *
sizeof(
double));
316 for (i = 0; i < ngap; i++)
317 for (k = 0; k < lgap[i]; k++) (*V)[id0gap[i] + k] = 0;
325 int *id0gap,
int *lgap,
int ngap) {
332 for (i = 0; i < local_V_size; i++) {
333 icol = (i + id0) % nrow;
335 if (icol < id0gap[k]) {
336 (*V)[offsetV] = (*V)[i];
337 offsetV = offsetV + 1;
338 }
else if (icol >= id0gap[k] + lgap[k]) {
int print_error_message(int error_number, char const *file, int line)
Prints error message corresponding to an error number.
int gap_masking(double **V, int l, int *id0gap, int *lgap, int ngap)
Reduce the vector and mask the defined gaps.
int gap_reduce(double **V, int id0, int l, int lambda, int *id0gap, int *lgap, int ngap, int *newl, int id0out)
int gap_masking_naive(double **V, int id0, int local_V_size, int m, int nrow, int *id0gap, int *lgap, int ngap)
int gstmm(double **V, int n, int m, int id0, int l, fftw_complex *T_fft, int lambda, fftw_complex *V_fft, double *V_rfft, fftw_plan plan_f, fftw_plan plan_b, int blocksize, int nfft, int *id0gap, int *lgap, int ngap)
int gap_filling(double **V, int l, int *id0gap, int *lgap, int ngap)
Extend the vector and add zeros on the gaps locations.