# include <deal.II/differentiation/sd/symengine_math.h>
# include <deal.II/differentiation/sd/symengine_number_traits.h>
# include <deal.II/differentiation/sd/symengine_number_types.h>
+# include <deal.II/differentiation/sd/symengine_scalar_operations.h>
# include <deal.II/differentiation/sd/symengine_types.h>
# include <deal.II/differentiation/sd/symengine_utilities.h>
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii_differentiation_sd_symengine_scalar_operations_h
+#define dealii_differentiation_sd_symengine_scalar_operations_h
+
+#include <deal.II/base/config.h>
+
+#ifdef DEAL_II_WITH_SYMENGINE
+
+# include <deal.II/base/numbers.h>
+
+# include <deal.II/differentiation/sd/symengine_number_types.h>
+# include <deal.II/differentiation/sd/symengine_types.h>
+
+# include <algorithm>
+# include <type_traits>
+# include <utility>
+# include <vector>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace Differentiation
+{
+ namespace SD
+ {
+ /**
+ * @name Symbolic variable creation
+ */
+ //@{
+
+ /**
+ * Return an Expression representing a scalar symbolic variable
+ * with the identifier specified by @p symbol.
+ *
+ * For example, if the @p symbol is the string `"x"` then the scalar
+ * symbolic variable that is returned represents the scalar $x$.
+ *
+ * @param[in] symbol An indentifier (or name) for the returned symbolic
+ * variable.
+ * @return A scalar symbolic variable with the name @p symbol.
+ *
+ * @warning It is up to the user to ensure that there is no ambiguity in the
+ * symbols used within a section of code.
+ */
+ Expression
+ make_symbol(const std::string &symbol);
+
+ /**
+ * Return an Expression representing a scalar symbolic function
+ * with the identifier specified by @p symbol. The function's symbolic
+ * dependencies are specified by the input @p arguments.
+ *
+ * For example, if the @p symbol is the string `"f"`, and the
+ * arguments to the function that is generated are the
+ * symbolic variable `x` and the symbolic expression `y+z`, then the
+ * generic symbolic function that is returned represents $f(x, y+z)$.
+ *
+ * @param[in] symbol An indentifier (or name) for the returned symbolic
+ * function.
+ * @param[in] arguments A vector of input arguments to the returned
+ * symbolic function.
+ * @return A generic symbolic function with the identifier @p symbolic and
+ * the number of input arguments equal to the length of @p arguments.
+ *
+ * @warning It is up to the user to ensure that there is no ambiguity in the
+ * symbols used within a section of code.
+ */
+ Expression
+ make_symbolic_function(const std::string & symbol,
+ const types::symbol_vector &arguments);
+
+ /**
+ * Return an Expression representing a scalar symbolic function
+ * with the identifier specified by @p symbol. The function's symbolic
+ * dependencies are specified by the keys to the input @p arguments map;
+ * the values stored in the map are ignored.
+ *
+ * For example, if the @p symbol is the string `"f"`, and the
+ * arguments to the function that is generated are the
+ * symbolic variable `x` and the symbolic expression `y+z`, then the
+ * generic symbolic function that is returned represents $f(x, y+z)$.
+ *
+ * @param[in] symbol An indentifier (or name) for the returned symbolic
+ * function.
+ * @param[in] arguments A map of input arguments to the returned
+ * symbolic function.
+ * @return A generic symbolic function with the identifier @p symbolic and
+ * the number of input arguments equal to the length of @p arguments.
+ *
+ * @warning It is up to the user to ensure that there is no ambiguity in the
+ * symbols used within a section of code.
+ */
+ Expression
+ make_symbolic_function(const std::string & symbol,
+ const types::substitution_map &arguments);
+
+ //@}
+
+ } // namespace SD
+} // namespace Differentiation
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif // DEAL_II_WITH_SYMENGINE
+
+#endif
SET(_src
symengine_math.cc
symengine_number_types.cc
+ symengine_scalar_operations.cc
symengine_types.cc
symengine_utilities.cc
)
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/base/config.h>
+
+#ifdef DEAL_II_WITH_SYMENGINE
+
+# include <deal.II/differentiation/sd/symengine_number_types.h>
+# include <deal.II/differentiation/sd/symengine_scalar_operations.h>
+# include <deal.II/differentiation/sd/symengine_types.h>
+# include <deal.II/differentiation/sd/symengine_utilities.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace Differentiation
+{
+ namespace SD
+ {
+ /* ------------------------- Symbol creation -----------------------*/
+
+
+ Expression
+ make_symbol(const std::string &symbol)
+ {
+ return Expression(symbol);
+ }
+
+
+ Expression
+ make_symbolic_function(const std::string & symbol,
+ const SD::types::symbol_vector &arguments)
+ {
+ return Expression(symbol, arguments);
+ }
+
+
+ Expression
+ make_symbolic_function(const std::string & symbol,
+ const SD::types::substitution_map &arguments)
+ {
+ return make_symbolic_function(symbol,
+ SD::Utilities::extract_symbols(arguments));
+ }
+
+
+ } // namespace SD
+} // namespace Differentiation
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif // DEAL_II_WITH_SYMENGINE
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 symbols and symbolic functions can be created using the
+// utility functions
+
+#include <deal.II/differentiation/sd.h>
+
+#include "../tests.h"
+
+using namespace dealii;
+namespace SD = Differentiation::SD;
+
+
+int
+main()
+{
+ initlog();
+
+ using SD_number_t = SD::Expression;
+
+ const SD::types::substitution_map sub_map{
+ {SD_number_t("c"), SD_number_t(1.0)},
+ {SD_number_t("b"), SD_number_t(2)},
+ {SD_number_t("a"), SD_number_t(3.0f)}};
+
+ const SD::types::symbol_vector symbols{SD_number_t("c"),
+ SD_number_t("b"),
+ SD_number_t("a")};
+
+ const SD_number_t symb = SD::make_symbol("d");
+ const SD_number_t symb_func_1 = SD::make_symbolic_function("f", symbols);
+ const SD_number_t symb_func_2 = SD::make_symbolic_function("g", sub_map);
+
+ deallog << "Symbol: " << symb << std::endl;
+ deallog << "Symbolic function (vector of arguments): " << symb_func_1
+ << std::endl;
+ deallog << "Symbolic function (map of arguments): " << symb_func_2
+ << std::endl;
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL::Symbol: d
+DEAL::Symbolic function (vector of arguments): f(c, b, a)
+DEAL::Symbolic function (map of arguments): g(a, b, c)
+DEAL::OK