]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement functions to make symbol maps
authorJean-Paul Pelteret <jppelteret@gmail.com>
Sat, 4 May 2019 19:56:38 +0000 (21:56 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Sat, 4 May 2019 21:24:30 +0000 (23:24 +0200)
include/deal.II/differentiation/sd/symengine_scalar_operations.h

index 69adbca82ffbd6715eca6b07a3c72d658b76f341..a2e6a87b1feedd2ca71d7e74eb463fdf46d0b0e2 100644 (file)
@@ -148,6 +148,44 @@ namespace Differentiation
       is_valid_substitution_symbol(const SymEngine::Basic &entry);
     } // namespace internal
 
+    /**
+     * Return a symbolic map that has the entry key given by @p symbol.
+     * It is expected that all entries be valid symbols or symbolic expressions.
+     *
+     * @tparam SymbolicType Any symbolic type that is understood by the
+     *         add_to_symbol_map() functions. This includes individual
+     *         Expression, std::vector<Expression>, as well as
+     *         Tensors and SymmetricTensors of Expressions.
+     */
+    template <typename SymbolicType>
+    types::substitution_map
+    make_symbol_map(const SymbolicType &symbol);
+
+    /**
+     * Return a symbolic map that has the entry keys given by @p symbol and all
+     * @p other_symbols. It is expected that all entries be valid symbols or
+     * symbolic expressions.
+     *
+     * With this function it is possible to construct a symbolic map from
+     * different types. An example may be as follows:
+     *
+     * @code
+     *   const types::substitution_map symbol_map
+     *     = make_symbol_map(
+     *         Expression(...),
+     *         Tensor<1,dim,Expression>(...),
+     *         SymmetricTensor<2,dim,Expression>(...));
+     * @endcode
+     *
+     * @tparam SymbolicType Any symbolic type that is understood by the
+     *         add_to_symbol_map() functions. This includes individual
+     *         Expression, std::vector<Expression>, as well as
+     *         Tensors and SymmetricTensors of Expressions.
+     */
+    template <typename SymbolicType, typename... Args>
+    types::substitution_map
+    make_symbol_map(const SymbolicType &symbol, const Args &... other_symbols);
+
     /**
      * A convenience function for an adding empty entry, with the key value
      * given by @p symbol, to the symbolic map @p substitution_map.
@@ -753,6 +791,26 @@ namespace Differentiation
     /* ---------------- Symbol map creation and manipulation --------------*/
 
 
+    template <typename SymbolicType>
+    types::substitution_map
+    make_symbol_map(const SymbolicType &symbol)
+    {
+      types::substitution_map symbol_map;
+      add_to_symbol_map(symbol_map, symbol);
+      return symbol_map;
+    }
+
+
+    template <typename SymbolicType, typename... Args>
+    types::substitution_map
+    make_symbol_map(const SymbolicType &symbol, const Args &... other_symbols)
+    {
+      types::substitution_map symbol_map;
+      add_to_symbol_map(symbol_map, symbol, other_symbols...);
+      return symbol_map;
+    }
+
+
     template <bool ignore_invalid_symbols, typename ValueType>
     void
     add_to_symbol_map(types::substitution_map &symbol_map,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.