9 #if defined(Add_) || defined(f77IsF2C)
10 #define fortran_mr2d pdtrmr2do_
11 #define fortran_mr2dnew pdtrmr2d_
13 #define fortran_mr2dnew PDTRMR2D
14 #define fortran_mr2d PDTRMR2DO
16 #define dlacpy_ DLACPY
18 #define fortran_mr2d pdtrmr2do
19 #define fortran_mr2dnew pdtrmr2d
21 #define dlacpy_ dlacpy
23 #define Clacpy Cdtrlacpy
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 dtrscanD0
83 #define dispmat dtrdispmat
84 #define setmemory dtrsetmemory
85 #define freememory dtrfreememory
86 #define scan_intervals dtrscan_intervals
117 assert(blocksize >= 0);
118 if (blocksize == 0) {
123 blocksize *
sizeof(
double));
129 double *ptrtobefreed;
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 double **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(
double));
219 (*pptrbuff) += intervalsize;
222 ptrstart = ptrblock +
localindice(start + ib, j + jb,
223 templateheight1, templatewidth1, mb);
224 memcpy((
char *) ptrstart, (
char *) (*pptrbuff),
225 intervalsize *
sizeof(
double));
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,
327 IDESC *v_inter, *h_inter;
328 int vinter_nb, hinter_nb;
335 int templateheight1, templatewidth1;
336 int templateheight0, templatewidth0;
339 templateheight1 = p1 * mb->
nbrow;
340 templateheight0 = p0 * ma->
nbrow;
341 templatewidth1 = q1 * mb->
nbcol;
342 templatewidth0 = q0 * ma->
nbcol;
347 for (h = 0; h < hinter_nb; h++)
348 for (v = 0; v < vinter_nb; v++) {
350 for (j = 0; j < h_inter[h].
len; j++)
351 intersect(uplo, diag, j + h_inter[h].gstart,
352 v_inter[v].gstart, v_inter[v].gstart + v_inter[v].len,
353 action, ptrsizebuff, &ptrbuff, ptrblock, m, n,
354 ma, ia, ja, templateheight0, templatewidth0,
355 mb, ib, jb, templateheight1, templatewidth1);