43 #include "getRow_dh.h"
45 #include "Euclid_dh.h"
54 #define __FUNC__ "EuclidGetRow"
56 EuclidGetRow (
void *A,
int row,
int *len,
int **ind,
double **val)
58 START_FUNC_DH
int ierr = 0;
60 ierr += ExtractIndicesView (A, row, len, ind);
63 sprintf (msgBuf_dh,
"ExtractIndicesView(row= %i) returned %i", row + 1,
65 SET_V_ERROR (msgBuf_dh);
68 ierr += ExtractValuesView (A, row, len, val);
71 sprintf (msgBuf_dh,
" ExtractValuesView(row= %i) returned %i", row + 1,
73 SET_V_ERROR (msgBuf_dh);
78 #define __FUNC__ "EuclidRestoreRow"
80 EuclidRestoreRow (
void *A,
int row,
int *len,
int **ind,
double **val)
87 #define __FUNC__ "EuclidGetDimensions"
89 EuclidGetDimensions (
void *A,
int *beg_row,
int *rowsLocal,
int *rowsGlobal)
91 START_FUNC_DH
int m, n;
92 int row_start, row_end, col_start, col_end;
94 row_start = MinMaxMyGID (A,
true,
true);
95 row_end = MinMaxMyGID (A,
true,
false);
96 col_start = MinMaxMyGID (A,
false,
true);
97 col_end = MinMaxMyGID (A,
false,
false);
99 m = NumGlobalRowCol (A,
false);
100 n = NumGlobalRowCol (A,
true);
101 *beg_row = row_start;
102 *rowsLocal = (row_end - row_start + 1);
119 #define __FUNC__ "PrintMatUsingGetRow"
121 PrintMatUsingGetRow (
void *A,
int beg_row,
int m,
122 int *n2o_row,
int *n2o_col,
char *filename)
124 START_FUNC_DH FILE *fp;
125 int *o2n_col = NULL, pe, i, j, *cval, len;
132 o2n_col = (
int *) MALLOC_DH (m *
sizeof (
int));
134 for (i = 0; i < m; ++i)
135 o2n_col[n2o_col[i]] = i;
138 for (pe = 0; pe < np_dh; ++pe)
141 MPI_Barrier (comm_dh);
147 fp = fopen (filename,
"w");
151 fp = fopen (filename,
"a");
155 sprintf (msgBuf_dh,
"can't open %s for writing\n", filename);
156 SET_V_ERROR (msgBuf_dh);
159 for (i = 0; i < m; ++i)
164 EuclidGetRow (A, i + beg_row, &len, &cval, &aval);
166 for (j = 0; j < len; ++j)
168 fprintf (fp,
"%i %i %g\n", i + 1, cval[j], aval[j]);
170 EuclidRestoreRow (A, i, &len, &cval, &aval);
175 newRow = n2o_row[i] + beg_row;
176 EuclidGetRow (A, newRow, &len, &cval, &aval);
178 for (j = 0; j < len; ++j)
180 newCol = o2n_col[cval[j] - beg_row] + beg_row;
181 fprintf (fp,
"%i %i %g\n", i + 1, newCol, aval[j]);
183 EuclidRestoreRow (A, i, &len, &cval, &aval);