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 240 of file pdtrmr2.c.

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