43 #include "Numbering_dh.h"
45 #include "Hash_i_dh.h"
47 #include "shellSort_dh.h"
48 #include "Parser_dh.h"
52 #define __FUNC__ "Numbering_dhCreate"
69 tmp->idx_extLo = NULL;
70 tmp->idx_extHi = NULL;
72 tmp->debug = Parser_dhHasSwitch (parser_dh,
"-debug_Numbering");
76 #define __FUNC__ "Numbering_dhDestroy"
80 START_FUNC_DH
if (numb->global_to_local != NULL)
82 Hash_i_dhDestroy (numb->global_to_local);
85 if (numb->idx_ext != NULL)
87 FREE_DH (numb->idx_ext);
103 #define __FUNC__ "Numbering_dhSetup"
107 START_FUNC_DH
int i, len, *cval = mat->cval;
108 int num_ext, num_extLo, num_extHi;
109 int m = mat->m, size;
111 int first = mat->beg_row, last = first + m;
124 numb->size = size = m;
125 Hash_i_dhCreate (&(numb->global_to_local), m);
128 global_to_local_hash = numb->global_to_local;
129 idx_ext = numb->idx_ext = (
int *) MALLOC_DH (size *
sizeof (
int));
136 num_ext = num_extLo = num_extHi = 0;
137 for (i = 0; i < len; i++)
142 if (index < first || index >= last)
146 data = Hash_i_dhLookup (global_to_local_hash, cval[i]);
156 if (m + num_ext >= size)
158 int newSize = size * 1.5;
159 int *tmp = (
int *) MALLOC_DH (newSize *
sizeof (
int));
161 memcpy (tmp, idx_ext, size *
sizeof (size));
164 size = numb->size = newSize;
165 numb->idx_ext = idx_ext = tmp;
166 SET_INFO (
"reallocated ext_idx[]");
170 Hash_i_dhInsert (global_to_local_hash, index, num_ext);
172 idx_ext[num_ext] = index;
187 numb->num_ext = num_ext;
188 numb->num_extLo = num_extLo;
189 numb->num_extHi = num_extHi;
190 numb->idx_extLo = idx_ext;
191 numb->idx_extHi = idx_ext + num_extLo;
197 shellSort_int (num_ext, idx_ext);
199 Hash_i_dhReset (global_to_local_hash);
201 for (i = 0; i < num_ext; i++)
203 Hash_i_dhInsert (global_to_local_hash, idx_ext[i], i + m);
209 #define __FUNC__ "Numbering_dhGlobalToLocal"
212 int *global,
int *local)
215 int first = numb->first;
216 int last = first + numb->m;
218 Hash_i_dh global_to_local = numb->global_to_local;
220 for (i = 0; i < len; i++)
222 int idxGlobal = global[i];
223 if (idxGlobal >= first && idxGlobal < last)
225 local[i] = idxGlobal - first;
230 data = Hash_i_dhLookup (global_to_local, idxGlobal);
234 sprintf (msgBuf_dh,
"global index %i not found in map\n",
236 SET_V_ERROR (msgBuf_dh);