28 int i, j, sum = dim * connections_per_row;
35 for (i = 1; i <= size; i++)
37 I[i] = I[i-1] + connections_per_row;
38 for (j = I[i-1]; j < I[i]; j++) { J[j] = -1; }
49 for (
int i = 0; i < size; i++)
52 J[i] = partitioning[i];
61 for (
int i = 0; i <= nrows; i++)
69 for (k = i = 0; i < size; i++)
70 j = I[i], I[i] = k, k += j;
72 J =
new int[I[size]=k];
79 for (
int i = 0; i < nc; i++)
86 for (
int i = size; i > 0; i--)
93 SetDims (dim, dim * connections_per_row);
98 for (
int i = 0, j = 0; i < size; i++)
100 int end = I[i] + connections_per_row;
102 for ( ; j < end; j++) J[j] = -1;
111 j = (I) ? (I[size]) : (0);
116 I = (rows >= 0) ? (
new int[rows+1]) : (NULL);
122 J = (nnz > 0) ? (
new int[nnz]) : (NULL);
134 if ( i>=size || i<0 )
139 for(k=I[i]; k<end; k++)
150 const int *jp = GetRow(i), n = RowSize(i);
153 for(
int i = 0; i < n; i++)
169 MFEM_ASSERT( i >=0 && i<size,
"Index out of bounds. i = "<<i);
171 for(
int k = I[i], end = I[i+1]; k < end; k++)
180 MFEM_ABORT(
"Reached end of loop unexpectedly: (i,j) = (" << i <<
", " << j
188 int i, j, end, sum = 0, n = 0, newI = 0;
190 for(i=0; i<I[size]; i++)
195 int *NewJ =
new int[sum];
197 for(i=0; i<size; i++){
199 for(j=I[i]; j<end; j++){
200 if (J[j] == -1)
break;
212 MFEM_ASSERT(sum == n,
"sum = " << sum <<
", n = " << n);
218 int width = -1, nnz = I[size];
219 for (
int k = 0; k < nnz; k++)
220 if (J[k] > width) width = J[k];
228 for (i = 0; i < size; i++)
230 out <<
"[row " << i <<
"]\n";
231 for (j = I[i]; j < I[i+1]; j++)
233 out << setw(5) << J[j];
234 if ( !((j+1-I[i]) % width) )
237 if ((j-I[i]) % width)
246 for (i = 0; i < size; i++)
247 for (j = I[i]; j < I[i+1]; j++)
248 out << i <<
" " << J[j] <<
" 1. \n";
259 for (i = 0; i <= size; i++)
261 for (i = 0; i < I[size]; i++)
275 int * i_copy =
new int[size+1];
276 int * j_copy =
new int[I[size]];
278 memcpy(i_copy, I,
sizeof(
int)*(size+1) );
279 memcpy(j_copy, J,
sizeof(
int)*size);
281 copy.
SetIJ(i_copy, j_copy, size);
288 int size_backup = size;
296 other.
size = size_backup;
307 const int *i_A = A.
GetI();
308 const int *j_A = A.
GetJ();
309 const int nrows_A = A.
Size();
310 const int ncols_A = (_ncols_A < 0) ? A.
Width() : _ncols_A;
311 const int nnz_A = i_A[nrows_A];
315 int *i_At = At.
GetI();
316 int *j_At = At.
GetJ();
318 for (
int i = 0; i <= ncols_A; i++)
320 for (
int i = 0; i < nnz_A; i++)
322 for (
int i = 1; i < ncols_A; i++)
323 i_At[i+1] += i_At[i];
325 for (
int i = 0; i < nrows_A; i++)
326 for (
int j = i_A[i]; j < i_A[i+1]; j++)
327 j_At[i_At[j_A[j]]++] = i;
328 for (
int i = ncols_A; i > 0; i--)
342 At.
MakeI((_ncols_A < 0) ? (A.
Max() + 1) : _ncols_A);
343 for (
int i = 0; i < A.
Size(); i++)
346 for (
int i = 0; i < A.
Size(); i++)
354 const int *i_A = A.
GetI();
355 const int *j_A = A.
GetJ();
356 const int *i_B = B.
GetI();
357 const int *j_B = B.
GetJ();
358 const int nrows_A = A.
Size();
359 const int nrows_B = B.
Size();
360 const int ncols_A = A.
Width();
361 const int ncols_B = B.
Width();
363 MFEM_VERIFY( ncols_A <= nrows_B,
"Table size mismatch: ncols_A = " << ncols_A
364 <<
", nrows_B = " << nrows_B);
368 for (i = 0; i < ncols_B; i++)
372 for (i = 0; i < nrows_A; i++)
374 for (j = i_A[i]; j < i_A[i+1]; j++)
377 for (l = i_B[k]; l < i_B[k+1]; l++)
380 if (B_marker[m] != i)
391 for (i = 0; i < ncols_B; i++)
397 for (i = 0; i < nrows_A; i++)
400 for (j = i_A[i]; j < i_A[i+1]; j++)
403 for (l = i_B[k]; l < i_B[k+1]; l++)
406 if (B_marker[m] != i)
426 Table(dim, connections_per_row)
447 Rows =
new Node*[nrows];
448 for (
int i = 0; i < nrows; i++)
456 int DSTable::Push_(
int r,
int c)
458 MFEM_ASSERT(r >= 0 && r < NumRows,
459 "Row out of bounds: r = " << r <<
", NumRows = " << NumRows);
461 for (n = Rows[r]; n != NULL; n = n->Prev)
468 #ifdef MFEM_USE_MEMALLOC
469 n = NodesMem.
Alloc ();
474 n->Index = NumEntries;
477 return(NumEntries++);
480 int DSTable::Index(
int r,
int c)
const
482 MFEM_ASSERT( r>=0,
"Row index must be non-negative, not "<<r);
485 for (Node *n = Rows[r]; n != NULL; n = n->Prev)
497 #ifdef MFEM_USE_MEMALLOC
500 for (
int i = 0; i < NumRows; i++)
502 Node *na, *nb = Rows[i];
int Size() const
Logical size of the array.
void SetSize(int dim, int connections_per_row)
Set the size and the number of connections for the table.
int operator()(int i, int j) const
void MakeI(int nrows)
Next 7 methods are used together with the default constructor.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void SetDims(int rows, int nnz)
void GetRow(int i, Array< int > &row) const
Return row i in array row (the Table must be finalized)
void Save(std::ostream &out) const
void AddConnections(int r, const int *c, int nc)
int Width() const
Returns the number of TYPE II elements (after Finalize() is called).
void Print(std::ostream &out=std::cout, int width=4) const
Prints the table to stream out.
int operator()(int i, int j) const
void AddConnection(int r, int c)
void Transpose(const Table &A, Table &At, int _ncols_A)
Transpose a Table.
int Size() const
Returns the number of TYPE I elements.
void PrintMatlab(std::ostream &out) const
STable(int dim, int connections_per_row=3)
Creates table with fixed number of connections.
int size
size is the number of TYPE I elements.
void AddAColumnInRow(int r)
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
void SetIJ(int *newI, int *newJ, int newsize=-1)
void Copy(Table ©) const
Table()
Creates an empty table.