From 1ee3038506fb08ff731340b9047f58bb5b5c1aca Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Thu, 27 Oct 2016 15:20:42 +0200 Subject: [PATCH] Add test for diagonal matrix --- tests/lac/diagonal_matrix.cc | 105 +++++++++++++++++++++++++++++++ tests/lac/diagonal_matrix.output | 8 +++ 2 files changed, 113 insertions(+) create mode 100644 tests/lac/diagonal_matrix.cc create mode 100644 tests/lac/diagonal_matrix.output diff --git a/tests/lac/diagonal_matrix.cc b/tests/lac/diagonal_matrix.cc new file mode 100644 index 0000000000..b4b4211585 --- /dev/null +++ b/tests/lac/diagonal_matrix.cc @@ -0,0 +1,105 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 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. +// +// --------------------------------------------------------------------- + + +// Tests DiagonalMatrix + + +#include "../tests.h" +#include +#include +#include + + + +void +check() +{ + const unsigned int size = 10; + Vector vec(size); + for (unsigned int i=0; i > mat; + mat.reinit(vec); + + Vector in (size), out(size), exact(size); + for (unsigned int i=0; i > &>(mat)(i,i); + mat(i,i) = in(i); + in(i) = mat_entry; + } + mat.vmult(out, in); + out -= exact; + deallog << "Error vmult set 3: " << out.linfty_norm() << std::endl; +} + + +int main() +{ + std::ofstream logfile("output"); + deallog << std::fixed; + deallog << std::setprecision(2); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + check(); + + return 0; +} diff --git a/tests/lac/diagonal_matrix.output b/tests/lac/diagonal_matrix.output new file mode 100644 index 0000000000..97ce615a67 --- /dev/null +++ b/tests/lac/diagonal_matrix.output @@ -0,0 +1,8 @@ + +DEAL::Error vmult: 0 +DEAL::Error Tvmult: 0 +DEAL::Error vmult_add: 0 +DEAL::Error Tvmult_add: 0 +DEAL::Error vmult set 1: 0 +DEAL::Error vmult set 2: 0 +DEAL::Error vmult set 3: 0 -- 2.39.5