deal.II version 9.8.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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2019 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_differentiation_sd_symengine_utilities_h
14#define dealii_differentiation_sd_symengine_utilities_h
15
16#include <deal.II/base/config.h>
17
18#ifdef DEAL_II_WITH_SYMENGINE
19
22
23# include <symengine/basic.h>
24# include <symengine/dict.h>
25
26#endif // DEAL_II_WITH_SYMENGINE
27
29
30#ifdef DEAL_II_WITH_SYMENGINE
31namespace Differentiation
32{
33 namespace SD
34 {
35 namespace Utilities
36 {
40 SymEngine::map_basic_basic
42 const SD::types::substitution_map &substitution_map);
43
49 const SymEngine::map_basic_basic &substitution_map);
50
54 SymEngine::vec_basic
56 const SD::types::symbol_vector &symbol_vector);
57
63 const SymEngine::vec_basic &symbol_vector);
64
69 std::vector<std::pair<Expression, Expression>>
71 const SymEngine::vec_pair &symbol_value_vector);
72
83 extract_symbols(const SD::types::substitution_map &substitution_values);
84
96 template <typename NumberType, typename ExpressionType = SD::Expression>
97 std::vector<NumberType>
98 extract_values(const SD::types::substitution_map &substitution_values);
99
103 template <typename StreamType>
104 StreamType &
106 StreamType &stream,
107 const SD::types::substitution_map &symbol_value_map);
108
109 } // namespace Utilities
110
111 } // namespace SD
112} // namespace Differentiation
113
114
115/* -------------------- inline and template functions ------------------ */
116
117
118# ifndef DOXYGEN
119
120
121namespace Differentiation
122{
123 namespace SD
124 {
125 namespace Utilities
126 {
127 template <typename NumberType, typename ExpressionType>
128 std::vector<NumberType>
129 extract_values(const SD::types::substitution_map &substitution_values)
130 {
131 std::vector<NumberType> values;
132 values.reserve(substitution_values.size());
133
134 for (const auto &entry : substitution_values)
135 values.push_back(
136 static_cast<NumberType>(ExpressionType(entry.second)));
137
138 return values;
139 }
140
141
142 template <typename StreamType>
143 StreamType &
145 StreamType &stream,
146 const SD::types::substitution_map &symbol_value_map)
147 {
148 for (const auto &entry : symbol_value_map)
149 stream << entry.first << " = " << entry.second << '\n';
150
151 stream << std::flush;
152 return stream;
153 }
154
155 } // namespace Utilities
156
157 } // namespace SD
158} // namespace Differentiation
159
160
161# endif // DOXYGEN
162
163#endif // DEAL_II_WITH_SYMENGINE
164
166
167#endif // dealii_differentiation_sd_symengine_utilities_h
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
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