32 const int nnz = table.
I[
size];
52 int i, j, sum =
dim * connections_per_row;
59 for (i = 1; i <=
size; i++)
61 I[i] =
I[i-1] + connections_per_row;
62 for (j =
I[i-1]; j <
I[i]; j++) {
J[j] = -1; }
73 for (
int i = 0; i <
size; i++)
76 J[i] = partitioning[i];
85 for (
int i = 0; i <= nrows; i++)
95 for (k = i = 0; i <
size; i++)
97 j =
I[i],
I[i] = k, k += j;
108 for (
int i = 0; i < nc; i++)
117 for (
int i =
size; i > 0; i--)
131 for (
int i = 0, j = 0; i <
size; i++)
133 int end =
I[i] + connections_per_row;
135 for ( ; j < end; j++) {
J[j] = -1; }
144 j = (
I) ? (
I[
size]) : (0);
167 if ( i>=
size || i<0 )
173 for (k =
I[i]; k < end; k++)
189 MFEM_ASSERT(i >= 0 && i <
size,
"Row index " << i <<
" is out of range [0,"
201 for (
int r = 0; r <
size; r++)
203 std::sort(
J +
I[r],
J +
I[r+1]);
222 i<
size,
"Index out of bounds. i = " << i <<
" size " <<
size);
224 for (
int k =
I[i], end =
I[i+1]; k < end; k++)
237 MFEM_ABORT(
"Reached end of loop unexpectedly: (i,j) = (" << i <<
", " << j
245 int i, j, end, sum = 0, n = 0, newI = 0;
247 for (i=0; i<
I[
size]; i++)
259 for (i=0; i<
size; i++)
262 for (j=
I[i]; j<end; j++)
264 if (
J[j] == -1) {
break; }
274 J.
Wrap(NewJ, sum,
true);
276 MFEM_ASSERT(sum == n,
"sum = " << sum <<
", n = " << n);
285 int nnz = list.Size();
290 for (
int i = 0, k = 0; i <=
size; i++)
293 while (k < nnz && list[k].from == i)
303 int width = -1, nnz = (
size >= 0) ?
I[
size] : 0;
304 for (
int k = 0; k < nnz; k++)
306 if (
J[k] > width) { width =
J[k]; }
315 for (i = 0; i <
size; i++)
317 os <<
"[row " << i <<
"]\n";
318 for (j =
I[i]; j <
I[i+1]; j++)
320 os << setw(5) <<
J[j];
321 if ( !((j+1-
I[i]) % width) )
326 if ((j-
I[i]) % width)
337 for (i = 0; i <
size; i++)
339 for (j =
I[i]; j <
I[i+1]; j++)
341 os << i <<
" " <<
J[j] <<
" 1. \n";
352 for (
int i = 0; i <=
size; i++)
356 for (
int i = 0, nnz =
I[
size]; i < nnz; i++)
369 for (
int i = 0; i <=
size; i++)
375 for (
int j = 0; j < nnz; j++)
404 if (
size < 0 ||
I == NULL) {
return 0; }
416 const int *i_A = A.
GetI();
417 const int *j_A = A.
GetJ();
418 const int nrows_A = A.
Size();
419 const int ncols_A = (ncols_A_ < 0) ? A.
Width() : ncols_A_;
420 const int nnz_A = i_A[nrows_A];
424 int *i_At = At.
GetI();
425 int *j_At = At.
GetJ();
427 for (
int i = 0; i <= ncols_A; i++)
431 for (
int i = 0; i < nnz_A; i++)
435 for (
int i = 1; i < ncols_A; i++)
437 i_At[i+1] += i_At[i];
440 for (
int i = 0; i < nrows_A; i++)
442 for (
int j = i_A[i]; j < i_A[i+1]; j++)
444 j_At[i_At[j_A[j]]++] = i;
447 for (
int i = ncols_A; i > 0; i--)
463 At.
MakeI((ncols_A_ < 0) ? (A.
Max() + 1) : ncols_A_);
464 for (
int i = 0; i < A.
Size(); i++)
469 for (
int i = 0; i < A.
Size(); i++)
479 const int *i_A = A.
GetI();
480 const int *j_A = A.
GetJ();
481 const int *i_B = B.
GetI();
482 const int *j_B = B.
GetJ();
483 const int nrows_A = A.
Size();
484 const int nrows_B = B.
Size();
485 const int ncols_A = A.
Width();
486 const int ncols_B = B.
Width();
488 MFEM_VERIFY( ncols_A <= nrows_B,
"Table size mismatch: ncols_A = " << ncols_A
489 <<
", nrows_B = " << nrows_B);
493 for (i = 0; i < ncols_B; i++)
499 for (i = 0; i < nrows_A; i++)
501 for (j = i_A[i]; j < i_A[i+1]; j++)
504 for (l = i_B[k]; l < i_B[k+1]; l++)
507 if (B_marker[m] != i)
518 for (i = 0; i < ncols_B; i++)
526 for (i = 0; i < nrows_A; i++)
529 for (j = i_A[i]; j < i_A[i+1]; j++)
532 for (l = i_B[k]; l < i_B[k+1]; l++)
535 if (B_marker[m] != i)
585 Rows =
new Node*[nrows];
586 for (
int i = 0; i < nrows; i++)
594int DSTable::Push_(
int r,
int c)
596 MFEM_ASSERT(r >= 0 && r < NumRows,
597 "Row out of bounds: r = " << r <<
", NumRows = " << NumRows);
599 for (n = Rows[r]; n != NULL; n = n->Prev)
606#ifdef MFEM_USE_MEMALLOC
607 n = NodesMem.
Alloc ();
612 n->Index = NumEntries;
615 return (NumEntries++);
618int DSTable::Index(
int r,
int c)
const
620 MFEM_ASSERT( r>=0,
"Row index must be non-negative, not "<<r);
625 for (Node *n = Rows[r]; n != NULL; n = n->Prev)
637#ifdef MFEM_USE_MEMALLOC
640 for (
int i = 0; i < NumRows; i++)
642 Node *na, *nb = Rows[i];
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void Assign(const T *)
Copy data from a pointer. 'Size()' elements are copied.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
Class used by MFEM to store pointers to host and/or device memory.
MemoryType GetMemoryType() const
Return a MemoryType that is currently valid. If both the host and the device pointers are currently v...
void CopyFrom(const Memory &src, int size)
Copy size entries from src to *this.
void Reset()
Reset the memory to be empty, ensuring that Delete() will be a no-op.
void Wrap(T *ptr, int size, bool own)
Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryMa...
void Delete()
Delete the owned pointers and reset the Memory object.
void New(int size)
Allocate host memory for size entries with the current host memory type returned by MemoryManager::Ge...
STable(int dim, int connections_per_row=3)
Creates table with fixed number of connections.
int operator()(int i, int j) const
Table & operator=(const Table &rhs)
Assignment operator: deep copy.
void Save(std::ostream &out) const
int size
size is the number of TYPE I elements.
const int * HostReadI() const
void AddConnections(int r, const int *c, int nc)
void PrintMatlab(std::ostream &out) const
void Load(std::istream &in)
int operator()(int i, int j) const
void SetSize(int dim, int connections_per_row)
Set the size and the number of connections for the table.
void GetRow(int i, Array< int > &row) const
Return row i in array row (the Table must be finalized)
void AddConnection(int r, int c)
void MakeI(int nrows)
Next 7 methods are used together with the default constructor.
void Print(std::ostream &out=mfem::out, int width=4) const
Prints the table to stream out.
void SetIJ(int *newI, int *newJ, int newsize=-1)
Replace the I and J arrays with the given newI and newJ arrays.
const int * HostReadJ() const
Table()
Creates an empty table.
int Size() const
Returns the number of TYPE I elements.
int Width() const
Returns the number of TYPE II elements (after Finalize() is called).
std::size_t MemoryUsage() const
void MakeFromList(int nrows, const Array< Connection > &list)
void Copy(Table ©) const
void AddAColumnInRow(int r)
void SortRows()
Sort the column (TYPE II) indices in each row.
void SetDims(int rows, int nnz)
void Swap(Array< T > &, Array< T > &)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void Transpose(const Table &A, Table &At, int ncols_A_)
Transpose a Table.