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 243 of file pztrmr2.c.

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