From 59d0b4e7fe11aa3ba17ce131531c82563cad63ff Mon Sep 17 00:00:00 2001 From: kronbichler Date: Wed, 8 Sep 2010 16:17:16 +0000 Subject: [PATCH] Improved tests. And some more tests. Should now test everything. git-svn-id: https://svn.dealii.org/trunk@21893 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/sparse_matrix_add_entries_01.cc | 12 +- tests/bits/sparse_matrix_add_entries_02.cc | 12 +- tests/bits/sparse_matrix_add_entries_03.cc | 12 +- tests/bits/sparse_matrix_add_entries_04.cc | 107 +++++++++++++++++ .../sparse_matrix_add_entries_04/cmp/generic | 2 + tests/bits/sparse_matrix_add_entries_05.cc | 107 +++++++++++++++++ .../sparse_matrix_add_entries_05/cmp/generic | 2 + tests/bits/sparse_matrix_add_entries_06.cc | 112 ++++++++++++++++++ .../sparse_matrix_add_entries_06/cmp/generic | 2 + 9 files changed, 350 insertions(+), 18 deletions(-) create mode 100644 tests/bits/sparse_matrix_add_entries_04.cc create mode 100644 tests/bits/sparse_matrix_add_entries_04/cmp/generic create mode 100644 tests/bits/sparse_matrix_add_entries_05.cc create mode 100644 tests/bits/sparse_matrix_add_entries_05/cmp/generic create mode 100644 tests/bits/sparse_matrix_add_entries_06.cc create mode 100644 tests/bits/sparse_matrix_add_entries_06/cmp/generic diff --git a/tests/bits/sparse_matrix_add_entries_01.cc b/tests/bits/sparse_matrix_add_entries_01.cc index 8a90d59830..08e4f44972 100644 --- a/tests/bits/sparse_matrix_add_entries_01.cc +++ b/tests/bits/sparse_matrix_add_entries_01.cc @@ -27,8 +27,8 @@ 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) + for (unsigned int i=0; i m(sp); // prepare structure with indices and values - std::vector indices (m.m()); - for (unsigned int i=0; i values (5); + std::vector indices (m.n()); + for (unsigned int j=0; j values (m.n()); // try to add entries from the list. Zeros // should be filtered out. list is sorted diff --git a/tests/bits/sparse_matrix_add_entries_02.cc b/tests/bits/sparse_matrix_add_entries_02.cc index 9a01f44394..a5d8eea5eb 100644 --- a/tests/bits/sparse_matrix_add_entries_02.cc +++ b/tests/bits/sparse_matrix_add_entries_02.cc @@ -27,8 +27,8 @@ 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) + for (unsigned int i=0; i m(sp); // prepare structure with indices and values - std::vector indices (m.m()); - for (unsigned int i=0; i values (5); + std::vector indices (m.n()); + for (unsigned int j=0; j values (m.n()); // try to add entries from the list. Zeros // should be filtered out. list is sorted diff --git a/tests/bits/sparse_matrix_add_entries_03.cc b/tests/bits/sparse_matrix_add_entries_03.cc index d0bd800ab8..acb2b78c01 100644 --- a/tests/bits/sparse_matrix_add_entries_03.cc +++ b/tests/bits/sparse_matrix_add_entries_03.cc @@ -27,8 +27,8 @@ 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) + for (unsigned int i=0; i m(sp); // prepare structure with indices and values - std::vector indices (m.m()); - for (unsigned int i=0; i values (5); + std::vector indices (m.n()); + for (unsigned int j=0; j values (m.n()); // try to add entries from the list. Zeros // need to be filtered out. list is not diff --git a/tests/bits/sparse_matrix_add_entries_04.cc b/tests/bits/sparse_matrix_add_entries_04.cc new file mode 100644 index 0000000000..cc3aeb33f2 --- /dev/null +++ b/tests/bits/sparse_matrix_add_entries_04.cc @@ -0,0 +1,107 @@ +//---------------------------- sparse_matrix_entries_04.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_04.cc ------------- + + +// check adding elements into a matrix using +// SparseMatrix::add(row, n_cols, col_indices, values, elide_zero_values, +// col_indices_are_sorted) +// rectangular case, sorted + +#include "../tests.h" +#include +#include + + +void test () +{ + // set up sparse matrix + SparsityPattern sp (5,7,3); + for (unsigned int i=0; i m(sp); + + // prepare structure with indices and values + std::vector indices (m.n()); + for (unsigned int j=0; j values (m.n()); + + // 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,7,3); + for (unsigned int i=0; i m(sp); + + // prepare structure with indices and values + std::vector indices (m.n()); + for (unsigned int i=0; i values (m.n()); + + // 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 m(sp); + + // prepare structure with indices and values + std::vector indices (m.n()); + for (unsigned int j=0; j values (m.n()); + + // try to add entries from the list. No + // zeros to be filtered. But less than 3 + // elements, so the program takes another + // path + for (unsigned int i=0; i