9 #if defined(Add_) || defined(f77IsF2C)
10 #define fortran_mr2d pitrmr2do_
11 #define fortran_mr2dnew pitrmr2d_
13 #define fortran_mr2dnew PITRMR2D
14 #define fortran_mr2d PITRMR2DO
16 #define ilacpy_ ILACPY
18 #define fortran_mr2d pitrmr2do
19 #define fortran_mr2dnew pitrmr2d
21 #define ilacpy_ ilacpy
23 #define Clacpy Citrlacpy
36 #define BLOCK_CYCLIC_2D 1
41 #define SHIFT(row,sprow,nbrow) ((row)-(sprow)+ ((row) >= (sprow) ? 0 : (nbrow)))
42 #define max(A,B) ((A)>(B)?(A):(B))
43 #define min(A,B) ((A)>(B)?(B):(A))
44 #define DIVUP(a,b) ( ((a)-1) /(b)+1)
45 #define ROUNDUP(a,b) (DIVUP(a,b)*(b))
47 #define malloc mymalloc
49 #define realloc myrealloc
82 #define scanD0 itrscanD0
83 #define dispmat itrdispmat
84 #define setmemory itrsetmemory
85 #define freememory itrfreememory
86 #define scan_intervals itrscan_intervals
117 assert(blocksize >= 0);
118 if (blocksize == 0) {
123 blocksize *
sizeof(
int));
131 if (ptrtobefreed == NULL)
133 free((
char *) ptrtobefreed);
147 assert(j >= 0 && j < n);
149 if (toupper(*uplo) ==
'U') {
153 virtualnbline =
max(m - n, 0) + j + (toupper(*diag) ==
'N');
154 nbline =
min(virtualnbline, m);
162 diagcol =
max(n - m, 0);;
163 virtualline = j - diagcol + (toupper(*diag) ==
'U');
164 firstline =
max(0, virtualline);
165 off =
max(firstline - i, 0);
179 ptrsizebuff, pptrbuff, ptrblock,
181 ma, ia, ja, templateheight0, templatewidth0,
182 mb, ib, jb, templateheight1, templatewidth1)
183 int action, *ptrsizebuff;
185 int **pptrbuff, *ptrblock;
186 int templateheight0, templatewidth0;
187 int templateheight1, templatewidth1;
189 int ia, ja, ib, jb, m, n;
201 assert(j >= 0 && j < n);
203 insidemat(uplo, diag, start, j, m, n, &offset);
209 intervalsize =
min(end - start, nbline);
210 (*ptrsizebuff) += intervalsize;
213 ptrstart = ptrblock +
localindice(start + ia, j + ja,
214 templateheight0, templatewidth0, ma);
215 memcpy((
char *) (*pptrbuff), (
char *) ptrstart,
216 intervalsize *
sizeof(
int));
219 (*pptrbuff) += intervalsize;
222 ptrstart = ptrblock +
localindice(start + ib, j + jb,
223 templateheight1, templatewidth1, mb);
224 memcpy((
char *) ptrstart, (
char *) (*pptrbuff),
225 intervalsize *
sizeof(
int));
228 (*pptrbuff) += intervalsize;
233 printf(
"action is %d outside the scope of the case [0..2] !! \n ", action);
243 scan_intervals(type, ja, jb, n, ma, mb, q0, q1, col0, col1,
246 int ja, jb, n, q0, q1, col0, col1;
250 int offset, j0, j1, templatewidth0, templatewidth1, nbcol0, nbcol1;
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;
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;
268 assert(j0 + nbcol0 > 0);
269 assert(j1 + nbcol1 > 0);
270 while ((j0 < n) && (j1 < n)) {
276 j0 += templatewidth0;
281 j1 += templatewidth1;
286 start =
max(start, 0);
288 result[offset].
gstart = start;
289 end =
min(end0, end1);
291 j0 += templatewidth0;
295 j1 += templatewidth1;
305 result[offset].
len = end - start;
313 scanD0(uplo, diag, action, ptrbuff, ptrsizebuff,
326 IDESC *v_inter, *h_inter;
327 int vinter_nb, hinter_nb;
334 int templateheight1, templatewidth1;
335 int templateheight0, templatewidth0;
338 templateheight1 = p1 * mb->
nbrow;
339 templateheight0 = p0 * ma->
nbrow;
340 templatewidth1 = q1 * mb->
nbcol;
341 templatewidth0 = q0 * ma->
nbcol;
346 for (h = 0; h < hinter_nb; h++)
347 for (v = 0; v < vinter_nb; v++) {
349 for (j = 0; j < h_inter[h].
len; j++)
350 intersect(uplo, diag, j + h_inter[h].gstart,
351 v_inter[v].gstart, v_inter[v].gstart + v_inter[v].len,
352 action, ptrsizebuff, &ptrbuff, ptrblock, m, n,
353 ma, ia, ja, templateheight0, templatewidth0,
354 mb, ib, jb, templateheight1, templatewidth1);