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 138 of file pigemr2.c.

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