Reference documentation for deal.II version 9.2.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\}}\)
symengine_utilities.h
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 #ifndef dealii_differentiation_sd_symengine_utilities_h
17 #define dealii_differentiation_sd_symengine_utilities_h
18 
19 #include <deal.II/base/config.h>
20 
21 #ifdef DEAL_II_WITH_SYMENGINE
22 
25 
26 # include <symengine/basic.h>
27 # include <symengine/dict.h>
28 
30 
31 namespace Differentiation
32 {
33  namespace SD
34  {
35  namespace Utilities
36  {
40  SymEngine::map_basic_basic
43 
49  const SymEngine::map_basic_basic &substitution_map);
50 
54  SymEngine::vec_basic
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 
121 namespace 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 
165 
166 #endif // DEAL_II_WITH_SYMENGINE
167 
168 #endif // dealii_differentiation_sd_symengine_utilities_h
Differentiation::SD::Utilities::extract_symbols
SD::types::symbol_vector extract_symbols(const SD::types::substitution_map &substitution_values)
Differentiation::SD::Utilities::convert_basic_pair_vector_to_expression_pair_vector
std::vector< std::pair< Expression, Expression > > convert_basic_pair_vector_to_expression_pair_vector(const SymEngine::vec_pair &symbol_value_vector)
Differentiation::SD::Utilities::convert_expression_vector_to_basic_vector
SymEngine::vec_basic convert_expression_vector_to_basic_vector(const SD::types::symbol_vector &symbol_vector)
Differentiation::SD::types::symbol_vector
std::vector< SD::Expression > symbol_vector
Definition: symengine_types.h:71
Differentiation::SD::types::substitution_map
std::map< SD::Expression, SD::Expression, internal::ExpressionKeyLess > substitution_map
Definition: symengine_types.h:62
symengine_number_types.h
symengine_types.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
Differentiation
Definition: numbers.h:645
Differentiation::SD::Utilities::convert_basic_map_to_expression_map
SD::types::substitution_map convert_basic_map_to_expression_map(const SymEngine::map_basic_basic &substitution_map)
Differentiation::SD::Utilities::convert_expression_map_to_basic_map
SymEngine::map_basic_basic convert_expression_map_to_basic_map(const SD::types::substitution_map &substitution_map)
Differentiation::SD::Utilities::convert_basic_vector_to_expression_vector
SD::types::symbol_vector convert_basic_vector_to_expression_vector(const SymEngine::vec_basic &symbol_vector)
Differentiation::SD::Utilities::print_substitution_map
StreamType & print_substitution_map(StreamType &stream, const SD::types::substitution_map &symbol_value_map)
config.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
Differentiation::SD::Utilities::extract_values
std::vector< NumberType > extract_values(const SD::types::substitution_map &substitution_values)
Utilities
Definition: cuda.h:31