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 141 of file pzgemr2.c.

147{
148 Int offset, j0, j1, templatewidth0, templatewidth1, nbcol0, nbcol1;
149 Int l; /* local indice on the beginning of the interval */
150 assert(type == 'c' || type == 'r');
151 nbcol0 = (type == 'c' ? ma->nbcol : ma->nbrow);
152 nbcol1 = (type == 'c' ? mb->nbcol : mb->nbrow);
153 templatewidth0 = q0 * nbcol0;
154 templatewidth1 = q1 * nbcol1;
155 {
156 Int sp0 = (type == 'c' ? ma->spcol : ma->sprow);
157 Int sp1 = (type == 'c' ? mb->spcol : mb->sprow);
158 j0 = SHIFT(col0, sp0, q0) * nbcol0 - ja;
159 j1 = SHIFT(col1, sp1, q1) * nbcol1 - jb;
160 }
161 offset = 0;
162 l = 0;
163 /* a small check to verify that the submatrix begin inside the first block
164 * of the original matrix, this done by a sort of coordinate change at the
165 * beginning of the Cpzgemr2d */
166 assert(j0 + nbcol0 > 0);
167 assert(j1 + nbcol1 > 0);
168 while ((j0 < n) && (j1 < n)) {
169 Int end0, end1;
170 Int start, end;
171 end0 = j0 + nbcol0;
172 end1 = j1 + nbcol1;
173 if (end0 <= j1) {
174 j0 += templatewidth0;
175 l += nbcol0;
176 continue;
177 }
178 if (end1 <= j0) {
179 j1 += templatewidth1;
180 continue;
181 }
182 /* compute the raw intersection */
183 start = max(j0, j1);
184 start = max(start, 0);
185 /* the start is correct now, update the corresponding fields */
186 result[offset].lstart = l + start - j0;
187 end = min(end0, end1);
188 if (end0 == end) {
189 j0 += templatewidth0;
190 l += nbcol0;
191 }
192 if (end1 == end)
193 j1 += templatewidth1;
194 /* throw the limit if they go out of the matrix */
195 end = min(end, n);
196 assert(end > start);
197 /* it is a bit tricky to see why the length is always positive after all
198 * this min and max, first we have the property that every interval
199 * considered is at least partly into the submatrix, second we arrive
200 * here only if the raw intersection is non-void, if we remove a limit
201 * that means the corresponding frontier is in both intervals which
202 * proove the final interval is non-void, clear ?? */
203 result[offset].len = end - start;
204 offset += 1;
205 } /* while */
206 return offset;
207}
#define Int
Definition Bconfig.h:22
#define SHIFT(row, sprow, nbrow)
Definition pzgemr2.c:44
#define max(A, B)
Definition pzgemr2.c:45
#define min(A, B)
Definition pzgemr2.c:46
Int lstart
Definition pcgemr.c:176
Int len
Definition pcgemr.c:177
Int spcol
Definition pcgemr.c:171
Int nbcol
Definition pcgemr.c:169
Int sprow
Definition pcgemr.c:170
Int nbrow
Definition pcgemr.c:168