From 647988b88a75e87462acd4fb9e93d6571980ec76 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Sat, 27 Apr 2019 19:31:44 +0200 Subject: [PATCH] Add test for creation of SD substitution maps from scalar types --- .../symengine/substitution_maps_scalar_03.cc | 79 +++++++++++++++++++ .../substitution_maps_scalar_03.output | 17 ++++ 2 files changed, 96 insertions(+) create mode 100644 tests/symengine/substitution_maps_scalar_03.cc create mode 100644 tests/symengine/substitution_maps_scalar_03.output diff --git a/tests/symengine/substitution_maps_scalar_03.cc b/tests/symengine/substitution_maps_scalar_03.cc new file mode 100644 index 0000000000..cc4c79e4f8 --- /dev/null +++ b/tests/symengine/substitution_maps_scalar_03.cc @@ -0,0 +1,79 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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. +// +// --------------------------------------------------------------------- + + +// Check that functions to create substitution maps from scalar variables work +// correctly. + +#include + +#include +#include + +#include +#include +#include + +#include "../tests.h" + +using namespace dealii; +namespace SD = Differentiation::SD; +namespace SE = ::SymEngine; + +int +main() +{ + initlog(); + + + const SD::types::substitution_map substitution_map_1 = + SD::make_substitution_map(SD::Expression("x1"), SD::Expression(1)); + const SD::types::substitution_map substitution_map_2 = + SD::make_substitution_map(SD::Expression("x3"), 3.0); + const SD::types::substitution_map substitution_map_3 = + SD::make_substitution_map(SD::types::symbol_vector{SD::Expression("x6"), + SD::Expression("x7")}, + std::vector{6, 7}); + const SD::types::substitution_map substitution_map_4{ + {SD::Expression("x8"), SD::Expression(8.0)}, + {SD::Expression("x9"), SD::Expression(9.0f)}, + {SD::Expression("x10"), SD::Expression(10u)}}; + const SD::types::substitution_map substitution_map_5 = + SD::make_substitution_map(std::make_pair(SD::Expression("x11"), 11)); + const SD::types::substitution_map substitution_map_6 = + SD::make_substitution_map(std::vector>{ + std::make_pair(SD::Expression("x12"), 12), + std::make_pair(SD::Expression("x13"), 13)}); + const SD::types::substitution_map substitution_map_7 = + SD::make_substitution_map(std::make_pair(SD::Expression("x14"), 14.0f), + std::make_pair(SD::Expression("x15"), 15), + std::make_pair(SD::Expression("x16"), 16.0), + SD::types::substitution_map{ + {SD::Expression("x17"), SD::Expression(17.0)}, + {SD::Expression("x18"), + SD::Expression(std::complex(18.0))}}); + const SD::types::substitution_map substitution_map = + SD::merge_substitution_maps(substitution_map_1, + substitution_map_2, + substitution_map_3, + substitution_map_4, + substitution_map_5, + substitution_map_6, + substitution_map_7); + + SD::Utilities::print_substitution_map(deallog, substitution_map); + + deallog << "OK" << std::endl; +} diff --git a/tests/symengine/substitution_maps_scalar_03.output b/tests/symengine/substitution_maps_scalar_03.output new file mode 100644 index 0000000000..061cd9eb35 --- /dev/null +++ b/tests/symengine/substitution_maps_scalar_03.output @@ -0,0 +1,17 @@ + +DEAL::x1 = 1 +x3 = 3.0 +x6 = 6 +x8 = 8.0 +x7 = 7 +x9 = 9.0 +x15 = 15 +x14 = 14.0 +x13 = 13 +x12 = 12 +x11 = 11 +x10 = 10 +x18 = 18.0 + 0.0*I +x17 = 17.0 +x16 = 16.0 +OK -- 2.39.5