Reference documentation for deal.II version 9.6.0
\(\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\}}\)
Loading...
Searching...
No Matches
symengine_utilities.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2019 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_differentiation_sd_symengine_utilities_h
16#define dealii_differentiation_sd_symengine_utilities_h
17
18#include <deal.II/base/config.h>
19
20#ifdef DEAL_II_WITH_SYMENGINE
21
24
25# include <symengine/basic.h>
26# include <symengine/dict.h>
27
29
30namespace Differentiation
31{
32 namespace SD
33 {
34 namespace Utilities
35 {
39 SymEngine::map_basic_basic
41 const SD::types::substitution_map &substitution_map);
42
48 const SymEngine::map_basic_basic &substitution_map);
49
53 SymEngine::vec_basic
55 const SD::types::symbol_vector &symbol_vector);
56
62 const SymEngine::vec_basic &symbol_vector);
63
68 std::vector<std::pair<Expression, Expression>>
70 const SymEngine::vec_pair &symbol_value_vector);
71
82 extract_symbols(const SD::types::substitution_map &substitution_values);
83
95 template <typename NumberType, typename ExpressionType = SD::Expression>
96 std::vector<NumberType>
97 extract_values(const SD::types::substitution_map &substitution_values);
98
102 template <typename StreamType>
103 StreamType &
105 StreamType &stream,
106 const SD::types::substitution_map &symbol_value_map);
107
108 } // namespace Utilities
109
110 } // namespace SD
111} // namespace Differentiation
112
113
114/* -------------------- inline and template functions ------------------ */
115
116
117# ifndef DOXYGEN
118
119
120namespace Differentiation
121{
122 namespace SD
123 {
124 namespace Utilities
125 {
126 template <typename NumberType, typename ExpressionType>
127 std::vector<NumberType>
128 extract_values(const SD::types::substitution_map &substitution_values)
129 {
130 std::vector<NumberType> values;
131 values.reserve(substitution_values.size());
132
133 for (const auto &entry : substitution_values)
134 values.push_back(
135 static_cast<NumberType>(ExpressionType(entry.second)));
136
137 return values;
138 }
139
140
141 template <typename StreamType>
142 StreamType &
144 StreamType &stream,
145 const SD::types::substitution_map &symbol_value_map)
146 {
147 for (const auto &entry : symbol_value_map)
148 stream << entry.first << " = " << entry.second << '\n';
149
150 stream << std::flush;
151 return stream;
152 }
153
154 } // namespace Utilities
155
156 } // namespace SD
157} // namespace Differentiation
158
159
160# endif // DOXYGEN
161
162
164
165#endif // DEAL_II_WITH_SYMENGINE
166
167#endif // dealii_differentiation_sd_symengine_utilities_h
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
Point< 2 > second
Definition grid_out.cc:4624
Point< 2 > first
Definition grid_out.cc:4623
std::vector< NumberType > extract_values(const SD::types::substitution_map &substitution_values)
SD::types::symbol_vector extract_symbols(const SD::types::substitution_map &substitution_values)
StreamType & print_substitution_map(StreamType &stream, const SD::types::substitution_map &symbol_value_map)
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::map< SD::Expression, SD::Expression, internal::ExpressionKeyLess > substitution_map
std::vector< SD::Expression > symbol_vector