*/
SparseMatrix (const SparsityPattern &InputSparsityPattern);
+ /**
+ * Move constructor. Create a new sparse matrix by stealing the internal
+ * data.
+ */
+ SparseMatrix (SparseMatrix &&other);
+
+ /**
+ * Copy constructor is deleted.
+ */
+ SparseMatrix (const SparseMatrix &) = delete;
+
+ /**
+ * operator= is deleted.
+ */
+ SparseMatrix &operator = (const SparseMatrix &) = delete;
+
/**
* Destructor. Made virtual so that one can use pointers to this class.
*/
private:
- /**
- * Copy constructor is disabled.
- */
- SparseMatrix (const SparseMatrix &);
- /**
- * operator= is disabled.
- */
- SparseMatrix &operator = (const SparseMatrix &);
-
/**
* Pointer to the user-supplied Epetra Trilinos mapping of the matrix
* columns that assigns parts of the matrix to the individual processes.
+ SparseMatrix::SparseMatrix (SparseMatrix &&other)
+ :
+ column_space_map(std::move(other.column_space_map)),
+ matrix(std::move(other.matrix)),
+ nonlocal_matrix(std::move(other.nonlocal_matrix)),
+ nonlocal_matrix_exporter(std::move(other.nonlocal_matrix_exporter)),
+ last_action(other.last_action),
+ compressed(other.compressed)
+ {
+ other.last_action = Zero;
+ other.compressed = false;
+ }
+
+
+
void
SparseMatrix::copy_from (const SparseMatrix &rhs)
{
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// Test move constructor
+
+#include "../tests.h"
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/trilinos_sparse_matrix.h>
+#include <deal.II/lac/trilinos_sparsity_pattern.h>
+#include <iostream>
+
+int main (int argc,char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, testing_max_num_threads());
+
+ IndexSet partitioning (3);
+
+ partitioning.add_range(0, 3);
+
+ // Add element (2,1) to the matrix
+ TrilinosWrappers::SparsityPattern sp (partitioning);
+ sp.add (2,1);
+ sp.compress();
+
+ TrilinosWrappers::SparseMatrix A (sp);
+ A.add (2, 1, 2.0);
+ A.compress(VectorOperation::add);
+
+ TrilinosWrappers::SparseMatrix B(std::move(A));
+
+ for (unsigned int i=0; i<3; ++i)
+ for (unsigned int j=0; j<3; ++j)
+ {
+ if ((i == 2) && (j == 1))
+ {
+ AssertThrow(B.el(i,j) == 2, ExcInternalError());
+ }
+ else
+ {
+ AssertThrow(B.el(i,j) == 0, ExcInternalError());
+ }
+ }
+
+ deallog << "OK" << std::endl;
+}