#include <lac/vector.h>
#include <lac/block_indices.h>
#include <lac/block_vector_base.h>
-#include <lac/trilinos_block_vector.h>
#include <cstdio>
#include <vector>
}
-#ifdef DEAL_II_USE_TRILINOS
-template <typename Number>
-inline
-BlockVector<Number> &
-BlockVector<Number>::operator = (const TrilinosWrappers::BlockVector &v)
-{
- BaseClass::operator = (v);
- return *this;
-}
-#endif
template <typename Number>
void BlockVector<Number>::scale (const value_type factor)
#include <base/config.h>
#include <lac/block_vector.h>
+#include <lac/trilinos_block_vector.h>
#include <cmath>
#include <algorithm>
{}
+#ifdef DEAL_II_USE_TRILINOS
+template <typename Number>
+inline
+BlockVector<Number> &
+BlockVector<Number>::operator = (const TrilinosWrappers::BlockVector &v)
+{
+ BaseClass::operator = (v);
+ return *this;
+}
+#endif
+
template <typename Number>
void BlockVector<Number>::swap (BlockVector<Number> &v)
#include <vector>
#include <algorithm>
+#include <iostream>
DEAL_II_NAMESPACE_OPEN
*/
template <typename ForwardIterator>
void add_entries (ForwardIterator begin,
- ForwardIterator end);
+ ForwardIterator end,
+ const bool indices_are_sorted);
};
inline
void
CompressedSimpleSparsityPattern::Line::add_entries (ForwardIterator begin,
- ForwardIterator end)
+ ForwardIterator end,
+ const bool indices_are_sorted)
{
- if (end - begin <= 0)
+ const int n_elements = end - begin;
+ if (n_elements <= 0)
return;
+ const unsigned int n_cols = static_cast<unsigned int>(n_elements);
+ const unsigned int stop_size = entries.size() + n_cols;
+
+ if (indices_are_sorted == true && n_elements > 3)
+ {
+ if (entries.size() == 0 || entries.back() < *begin)
+ {
+ entries.insert(entries.end(), begin, end);
+ return;
+ }
+
+ // resize vector by just inserting the
+ // list
+ const unsigned int col = *begin;
+ std::vector<unsigned int>::iterator it =
+ std::lower_bound(entries.begin(), entries.end(), col);
+ const unsigned int pos1 = it - entries.begin();
+ entries.insert (it, begin, end);
+ it = entries.begin() + pos1;
+
+ // now merge the two lists.
+ ForwardIterator my_it = begin;
+ std::vector<unsigned int>::iterator it2 = it + n_cols;
+
+ // as long as there are indices both in
+ // the end of the entries list and in the
+ // input list
+ while (my_it != end && it2 != entries.end())
+ {
+ if (*my_it < *it2)
+ *it++ = *my_it++;
+ else if (*my_it == *it2)
+ {
+ *it++ = *it2++;
+ ++my_it;
+ }
+ else
+ *it++ = *it2++;
+ }
+ // in case there are indices left in the
+ // input list
+ while (my_it != end)
+ *it++ = *my_it++;
+
+ // in case there are indices left in the
+ // end of entries
+ while (it2 != entries.end())
+ *it++ = *it2++;
+
+ // resize
+ const unsigned int new_size = it - entries.begin();
+ Assert (new_size <= stop_size, ExcInternalError());
+ entries.resize (new_size);
+ return;
+ }
+
ForwardIterator my_it = begin;
- const unsigned int n_cols = static_cast<unsigned int>(end - begin);
// If necessary, increase the size of the array. In order to avoid
// allocating just a few entries every time, use five elements at a time
// at least.
- const unsigned int stop_size = entries.size() + (n_cols > 5 ? n_cols : 5);
if (stop_size > entries.capacity())
entries.reserve (stop_size);
CompressedSimpleSparsityPattern::add_entries (const unsigned int row,
ForwardIterator begin,
ForwardIterator end,
- const bool /*indices_are_sorted*/)
+ const bool indices_are_sorted)
{
Assert (row < rows, ExcIndexRange (row, 0, rows));
- lines[row].add_entries (begin, end);
+ lines[row].add_entries (begin, end, indices_are_sorted);
}
// into the vector
Threads::ThreadMutex::ScopedLock lock(mutex);
if (col_counter > 0)
- sparsity_pattern.add_entries(row, cols.begin(), cols.begin()+col_counter);
+ sparsity_pattern.add_entries(row, cols.begin(), cols.begin()+col_counter,
+ true);
}
}
if (current_length > 0)
sparsity_pattern.block(row_block.first, i).add_entries(row_block.second,
cols.begin()+col_begins,
- cols.begin()+col_begins+current_length);
+ cols.begin()+col_begins+current_length,
+ true);
col_begins = actual_block_ends[i];
}
}
#include <base/config.h>
#include <base/table.h>
#include <lac/block_matrix_base.h>
-#include <lac/block_sparse_matrix.h>
#include <lac/trilinos_sparse_matrix.h>
#include <lac/trilinos_block_vector.h>
#include <lac/full_matrix.h>
class BlockCompressedSparsityPattern;
class BlockCompressedSetSparsityPattern;
class BlockCompressedSimpleSparsityPattern;
+template <typename number> class BlockSparseMatrix;
namespace TrilinosWrappers
#include <base/config.h>
#include <base/subscriptor.h>
-#include <lac/vector.h>
-#include <lac/sparse_matrix.h>
#include <base/std_cxx0x/shared_ptr.h>
DEAL_II_NAMESPACE_OPEN
+// forward declarations
+template <typename number> class SparseMatrix;
+template <typename number> class Vector;
+
/*! @addtogroup TrilinosWrappers
*@{
*/
#include <base/config.h>
#include <lac/exceptions.h>
-#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_block_sparse_matrix.h>
#include <lac/trilinos_precondition.h>
+#include <lac/trilinos_sparse_matrix.h>
#ifdef DEAL_II_USE_TRILINOS
namespace TrilinosWrappers
{
+ // forward declarations
+ class BlockSparseMatrix;
/**
* This implements an interface class of preconditioners for block
#include <base/config.h>
#include <base/subscriptor.h>
-#include <lac/sparse_matrix.h>
#include <lac/full_matrix.h>
#include <lac/exceptions.h>
#include <lac/trilinos_vector_base.h>
DEAL_II_NAMESPACE_OPEN
+// forward declaration
+template <typename number> class SparseMatrix;
namespace TrilinosWrappers
{
#include <lac/trilinos_block_sparse_matrix.h>
+#include <lac/block_sparse_matrix.h>
#include <lac/block_sparsity_pattern.h>
#ifdef DEAL_II_USE_TRILINOS
//---------------------------------------------------------------------------
+#include <lac/vector.h>
+#include <lac/sparse_matrix.h>
#include <lac/trilinos_precondition.h>
#include <lac/trilinos_vector_base.h>
#include <lac/trilinos_sparse_matrix.h>
#include <lac/trilinos_precondition_block.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/trilinos_block_sparse_matrix.h>
+
#ifdef DEAL_II_USE_TRILINOS
#include <Thyra_EpetraLinearOp.hpp>
#include <lac/trilinos_sparse_matrix.h>
+#include <lac/sparse_matrix.h>
#include <lac/trilinos_sparsity_pattern.h>
#include <lac/sparsity_pattern.h>
#include <lac/compressed_sparsity_pattern.h>