Reference documentation for deal.II version 9.3.3
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
symengine_utilities.cc
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2019 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE at
12// the top level of the deal.II distribution.
13//
14// ---------------------------------------------------------------------
15
16#include <deal.II/base/config.h>
17
18#ifdef DEAL_II_WITH_SYMENGINE
19
22
24
25namespace Differentiation
26{
27 namespace SD
28 {
29 namespace SE = ::SymEngine;
30
31 namespace Utilities
32 {
33# ifndef DOXYGEN
34
35 SE::map_basic_basic
38 {
39 SE::map_basic_basic sub_map;
40 for (const auto &entry : substitution_map)
41 sub_map[entry.first.get_RCP()] = entry.second.get_RCP();
42 return sub_map;
43 }
44
45
46
49 const SymEngine::map_basic_basic &substitution_map)
50 {
52 for (const auto &entry : substitution_map)
53 sub_map[Expression(entry.first)] = SD::Expression(entry.second);
54 return sub_map;
55 }
56
57
58
59 SE::vec_basic
62 {
63 SE::vec_basic symb_vec;
64 symb_vec.reserve(symbol_vector.size());
65 for (const auto &entry : symbol_vector)
66 symb_vec.push_back(entry.get_RCP());
67 return symb_vec;
68 }
69
70
71
74 const SE::vec_basic &symbol_vector)
75 {
77 symb_vec.reserve(symbol_vector.size());
78 for (const auto &entry : symbol_vector)
79 symb_vec.push_back(SD::Expression(entry));
80 return symb_vec;
81 }
82
83
84
86 extract_symbols(const SD::types::substitution_map &substitution_values)
87 {
89 symbols.reserve(substitution_values.size());
90
91 for (const auto &substitution : substitution_values)
92 symbols.push_back(substitution.first);
93
94 return symbols;
95 }
96
97
98
99 std::vector<std::pair<SD::Expression, SD::Expression>>
101 const SymEngine::vec_pair &symbol_value_vector)
102 {
103 std::vector<std::pair<SD::Expression, SD::Expression>> symb_val_vec;
104 symb_val_vec.reserve(symbol_value_vector.size());
105 for (const auto &entry : symbol_value_vector)
106 symb_val_vec.push_back(std::make_pair(SD::Expression(entry.first),
107 SD::Expression(entry.second)));
108 return symb_val_vec;
109 }
110
111# endif // DOXYGEN
112
113 } // namespace Utilities
114
115 } // namespace SD
116} // namespace Differentiation
117
118
120
121#endif // DEAL_II_WITH_SYMENGINE
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
SD::types::symbol_vector extract_symbols(const SD::types::substitution_map &substitution_values)
std::vector< std::pair< Expression, Expression > > convert_basic_pair_vector_to_expression_pair_vector(const SymEngine::vec_pair &symbol_value_vector)
SD::types::substitution_map convert_basic_map_to_expression_map(const SymEngine::map_basic_basic &substitution_map)
SD::types::symbol_vector convert_basic_vector_to_expression_vector(const SymEngine::vec_basic &symbol_vector)
SymEngine::map_basic_basic convert_expression_map_to_basic_map(const SD::types::substitution_map &substitution_map)
SymEngine::vec_basic convert_expression_vector_to_basic_vector(const SD::types::symbol_vector &symbol_vector)
std::vector< SD::Expression > symbol_vector
std::map< SD::Expression, SD::Expression, internal::ExpressionKeyLess > substitution_map