libMesh::SparsityPattern Namespace Reference
Classes | |
| class | Graph |
| class | NonlocalGraph |
| class | Build |
Typedefs | |
| typedef std::vector < dof_id_type, Threads::scalable_allocator < dof_id_type > > | Row |
Functions | |
| template<typename BidirectionalIterator > | |
| static void | sort_row (const BidirectionalIterator begin, BidirectionalIterator middle, const BidirectionalIterator end) |
| void | _dummy_function (void) |
Detailed Description
This defines the sparsity pattern, or graph, of a sparse matrix. The format is quite simple -- the global indices of the nonzero entries in each row are packed into a vector. The global indices (i,j) of the nth nonzero entry of row i are given by j = sparsity_pattern[i][n];
Typedef Documentation
| typedef std::vector<dof_id_type, Threads::scalable_allocator<dof_id_type> > libMesh::SparsityPattern::Row |
Definition at line 48 of file sparsity_pattern.h.
Function Documentation
| void libMesh::SparsityPattern::_dummy_function | ( | void | ) |
Dummy function that does nothing but can be used to prohibit compiler optimization in some situations where some compilers have optimization bugs.
Definition at line 2146 of file dof_map.C.
Referenced by sort_row().
| void libMesh::SparsityPattern::sort_row | ( | const BidirectionalIterator | begin, | |
| BidirectionalIterator | middle, | |||
| const BidirectionalIterator | end | |||
| ) | [inline, static] |
Splices the two sorted ranges [begin,middle) and [middle,end) into one sorted range [begin,end). This method is much like std::inplace_merge except it assumes the intersection of the two sorted ranges is empty and that any element in each range occurs only once in that range. Additionally, this sort occurs in-place, while std::inplace_merge may use a temporary buffer.
Definition at line 147 of file sparsity_pattern.h.
References _dummy_function(), and swap().
Referenced by libMesh::SparsityPattern::Build::operator()().
00150 { 00151 if ((begin == middle) || (middle == end)) return; 00152 00153 libmesh_assert_greater (std::distance (begin, middle), 0); 00154 libmesh_assert_greater (std::distance (middle, end), 0); 00155 libmesh_assert (std::unique (begin, middle) == middle); 00156 libmesh_assert (std::unique (middle, end) == end); 00157 00158 while (middle != end) 00159 { 00160 BidirectionalIterator 00161 b = middle, 00162 a = b-1; 00163 00164 // Bubble-sort the middle value downward 00165 while (!(*a < *b)) // *a & *b are less-than comparable, so use < 00166 { 00167 std::swap (*a, *b); 00168 00169 #if defined(__GNUC__) && (__GNUC__ < 4) && !defined(__INTEL_COMPILER) 00170 /* Prohibit optimization at this point since gcc 3.3.5 seems 00171 to have a bug. */ 00172 SparsityPattern::_dummy_function(); 00173 #endif 00174 00175 if (a == begin) break; 00176 00177 b=a; 00178 --a; 00179 } 00180 00181 ++middle; 00182 } 00183 00184 // Assure the algorithm worked if we are in DEBUG mode 00185 #ifdef DEBUG 00186 { 00187 // SGI STL extension! 00188 // libmesh_assert (std::is_sorted(begin,end)); 00189 00190 BidirectionalIterator 00191 prev = begin, 00192 first = begin; 00193 00194 for (++first; first != end; prev=first, ++first) 00195 if (*first < *prev) 00196 libmesh_assert(false); 00197 } 00198 #endif 00199 00200 // Make sure the two ranges did not contain any common elements 00201 libmesh_assert (std::unique (begin, end) == end); 00202 }
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:49 UTC
Hosted By: