SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ scan_intervals()

Int scan_intervals ( char  type,
Int  ja,
Int  jb,
Int  n,
MDESC ma,
MDESC mb,
Int  q0,
Int  q1,
Int  col0,
Int  col1,
IDESC result 
)

Definition at line 232 of file pitrmr2.c.

238{
239 Int offset, j0, j1, templatewidth0, templatewidth1, nbcol0, nbcol1;
240 Int l; /* local indice on the beginning of the interval */
241 assert(type == 'c' || type == 'r');
242 nbcol0 = (type == 'c' ? ma->nbcol : ma->nbrow);
243 nbcol1 = (type == 'c' ? mb->nbcol : mb->nbrow);
244 templatewidth0 = q0 * nbcol0;
245 templatewidth1 = q1 * nbcol1;
246 {
247 Int sp0 = (type == 'c' ? ma->spcol : ma->sprow);
248 Int sp1 = (type == 'c' ? mb->spcol : mb->sprow);
249 j0 = SHIFT(col0, sp0, q0) * nbcol0 - ja;
250 j1 = SHIFT(col1, sp1, q1) * nbcol1 - jb;
251 }
252 offset = 0;
253 l = 0;
254 /* a small check to verify that the submatrix begin inside the first block
255 * of the original matrix, this done by a sort of coordinate change at the
256 * beginning of the Cpitrmr2d */
257 assert(j0 + nbcol0 > 0);
258 assert(j1 + nbcol1 > 0);
259 while ((j0 < n) && (j1 < n)) {
260 Int end0, end1;
261 Int start, end;
262 end0 = j0 + nbcol0;
263 end1 = j1 + nbcol1;
264 if (end0 <= j1) {
265 j0 += templatewidth0;
266 l += nbcol0;
267 continue;
268 }
269 if (end1 <= j0) {
270 j1 += templatewidth1;
271 continue;
272 }
273 /* compute the raw intersection */
274 start = max(j0, j1);
275 start = max(start, 0);
276 /* the start is correct now, update the corresponding fields */
277 result[offset].gstart = start;
278 end = min(end0, end1);
279 if (end0 == end) {
280 j0 += templatewidth0;
281 l += nbcol0;
282 }
283 if (end1 == end)
284 j1 += templatewidth1;
285 /* throw the limit if they go out of the matrix */
286 end = min(end, n);
287 assert(end > start);
288 /* it is a bit tricky to see why the length is always positive after all
289 * this min and max, first we have the property that every interval
290 * considered is at least partly into the submatrix, second we arrive
291 * here only if the raw intersection is non-void, if we remove a limit
292 * that means the corresponding frontier is in both intervals which
293 * proove the final interval is non-void, clear ?? */
294 result[offset].len = end - start;
295 offset += 1;
296 } /* while */
297 return offset;
298}
#define Int
Definition Bconfig.h:22
#define SHIFT(row, sprow, nbrow)
Definition pitrmr2.c:41
#define max(A, B)
Definition pitrmr2.c:42
#define min(A, B)
Definition pitrmr2.c:43
Int len
Definition pcgemr.c:177
Int gstart
Definition pctrmr.c:191
Int spcol
Definition pcgemr.c:171
Int nbcol
Definition pcgemr.c:169
Int sprow
Definition pcgemr.c:170
Int nbrow
Definition pcgemr.c:168