From 163b0b5e8eec617d73616da480f27d9987a72593 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Wed, 8 Sep 2010 15:38:45 +0000 Subject: [PATCH] Add several tests for collective add operations in sparse matrix. git-svn-id: https://svn.dealii.org/trunk@21888 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/sparse_matrix_add_entries_01.cc | 117 ++++++++++++++++++ .../sparse_matrix_add_entries_01/cmp/generic | 5 + tests/bits/sparse_matrix_add_entries_02.cc | 108 ++++++++++++++++ .../sparse_matrix_add_entries_02/cmp/generic | 2 + tests/bits/sparse_matrix_add_entries_03.cc | 109 ++++++++++++++++ .../sparse_matrix_add_entries_03/cmp/generic | 2 + 6 files changed, 343 insertions(+) create mode 100644 tests/bits/sparse_matrix_add_entries_01.cc create mode 100644 tests/bits/sparse_matrix_add_entries_01/cmp/generic create mode 100644 tests/bits/sparse_matrix_add_entries_02.cc create mode 100644 tests/bits/sparse_matrix_add_entries_02/cmp/generic create mode 100644 tests/bits/sparse_matrix_add_entries_03.cc create mode 100644 tests/bits/sparse_matrix_add_entries_03/cmp/generic diff --git a/tests/bits/sparse_matrix_add_entries_01.cc b/tests/bits/sparse_matrix_add_entries_01.cc new file mode 100644 index 0000000000..8a90d59830 --- /dev/null +++ b/tests/bits/sparse_matrix_add_entries_01.cc @@ -0,0 +1,117 @@ +//---------------------------- sparse_matrix_entries_01.cc ----------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- sparse_matrix_add_entries_01.cc ------------- + + +// check adding elements into a matrix using +// SparseMatrix::add(row, n_cols, col_indices, values, elide_zero_values, +// col_indices_are_sorted) +// need to filter out zeros, indices are sorted and zero values should +// not be elided + +#include "../tests.h" +#include +#include + + +void test () +{ + // set up sparse matrix + SparsityPattern sp (5,5,3); + for (unsigned int i=0; i<5; ++i) + for (unsigned int j=0; j<5; ++j) + if ((i+2*j+1) % 3 == 0) + sp.add (i,j); + sp.compress (); + + SparseMatrix m(sp); + + // prepare structure with indices and values + std::vector indices (m.m()); + for (unsigned int i=0; i values (5); + + // try to add entries from the list. Zeros + // should be filtered out. list is sorted + for (unsigned int i=0; i +#include + + +void test () +{ + // set up sparse matrix + SparsityPattern sp (5,5,3); + for (unsigned int i=0; i<5; ++i) + for (unsigned int j=0; j<5; ++j) + if ((i+2*j+1) % 3 == 0) + sp.add (i,j); + sp.compress (); + + SparseMatrix m(sp); + + // prepare structure with indices and values + std::vector indices (m.m()); + for (unsigned int i=0; i values (5); + + // try to add entries from the list. Zeros + // should be filtered out. list is sorted + for (unsigned int i=0; i +#include + + +void test () +{ + // set up sparse matrix + SparsityPattern sp (5,5,3); + for (unsigned int i=0; i<5; ++i) + for (unsigned int j=0; j<5; ++j) + if ((i+2*j+1) % 3 == 0) + sp.add (i,j); + sp.compress (); + + SparseMatrix m(sp); + + // prepare structure with indices and values + std::vector indices (m.m()); + for (unsigned int i=0; i values (5); + + // try to add entries from the list. Zeros + // need to be filtered out. list is not + // sorted + for (unsigned int i=0; i