deal.II version GIT relicensing-1936-ge55124254b 2024-10-04 21:10:00+00:00
\(\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_math.cc
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
16#include <deal.II/base/config.h>
17
18#ifdef DEAL_II_WITH_SYMENGINE
19
21
22# include <symengine/add.h>
23# include <symengine/functions.h>
24# include <symengine/mul.h>
25# include <symengine/pow.h>
26
28
29namespace Differentiation
30{
31 namespace SD
32 {
33 namespace SE = ::SymEngine;
34
35 /* --------------------------- Math functions ------------------------- */
36
37 Expression
38 pow(const Expression &base, const Expression &exponent)
39 {
40 return SE::pow(base.get_RCP(), exponent.get_RCP());
41 }
42
43
44 Expression
45 sqrt(const Expression &x)
46 {
47 return SE::sqrt(x.get_RCP());
48 }
49
50
51 Expression
52 cbrt(const Expression &x)
53 {
54 return SE::cbrt(x.get_RCP());
55 }
56
57
58 Expression
59 exp(const Expression &exponent)
60 {
61 return SE::exp(exponent.get_RCP());
62 }
63
64
65 Expression
66 log(const Expression &x)
67 {
68 return SE::log(x.get_RCP());
69 }
70
71
72 Expression
73 log(const Expression &x, const Expression &base)
74 {
75 return SE::log(x.get_RCP(), base.get_RCP());
76 }
77
78
79 Expression
80 log10(const Expression &x)
81 {
82 return log(x.get_RCP(), Expression(10.0));
83 }
84
85
86 Expression
87 sin(const Expression &x)
88 {
89 return SE::sin(x.get_RCP());
90 }
91
92
93 Expression
94 cos(const Expression &x)
95 {
96 return SE::cos(x.get_RCP());
97 }
98
99
100 Expression
101 tan(const Expression &x)
102 {
103 return SE::tan(x.get_RCP());
104 }
105
106
107 Expression
108 csc(const Expression &x)
109 {
110 return SE::csc(x.get_RCP());
111 }
112
113
114 Expression
115 sec(const Expression &x)
116 {
117 return SE::sec(x.get_RCP());
118 }
119
120
121 Expression
122 cot(const Expression &x)
123 {
124 return SE::cot(x.get_RCP());
125 }
126
127
128 Expression
129 asin(const Expression &x)
130 {
131 return SE::asin(x.get_RCP());
132 }
133
134
135 Expression
136 acos(const Expression &x)
137 {
138 return SE::acos(x.get_RCP());
139 }
140
141
142 Expression
143 atan(const Expression &x)
144 {
145 return SE::atan(x.get_RCP());
146 }
147
148
149 Expression
150 atan2(const Expression &y, const Expression &x)
151 {
152 return SE::atan2(y.get_RCP(), x.get_RCP());
153 }
154
155
156 Expression
157 acsc(const Expression &x)
158 {
159 return SE::acsc(x.get_RCP());
160 }
161
162
163 Expression
164 asec(const Expression &x)
165 {
166 return SE::asec(x.get_RCP());
167 }
168
169
170 Expression
171 acot(const Expression &x)
172 {
173 return SE::acot(x.get_RCP());
174 }
175
176
177 Expression
178 sinh(const Expression &x)
179 {
180 return SE::sinh(x.get_RCP());
181 }
182
183
184 Expression
185 cosh(const Expression &x)
186 {
187 return SE::cosh(x.get_RCP());
188 }
189
190
191 Expression
192 tanh(const Expression &x)
193 {
194 return SE::tanh(x.get_RCP());
195 }
196
197
198 Expression
199 csch(const Expression &x)
200 {
201 return SE::csch(x.get_RCP());
202 }
203
204
205 Expression
206 sech(const Expression &x)
207 {
208 return SE::sech(x.get_RCP());
209 }
210
211
212 Expression
213 coth(const Expression &x)
214 {
215 return SE::coth(x.get_RCP());
216 }
217
218
219 Expression
221 {
222 return SE::asinh(x.get_RCP());
223 }
224
225
226 Expression
228 {
229 return SE::acosh(x.get_RCP());
230 }
231
232
233 Expression
235 {
236 return SE::atanh(x.get_RCP());
237 }
238
239
240 Expression
242 {
243 return SE::acsch(x.get_RCP());
244 }
245
246
247 Expression
249 {
250 return SE::asech(x.get_RCP());
251 }
252
253
254 Expression
256 {
257 return SE::acoth(x.get_RCP());
258 }
259
260
261 Expression
262 abs(const Expression &x)
263 {
264 return SE::abs(x.get_RCP());
265 }
266
267
268 Expression
269 fabs(const Expression &x)
270 {
271 return SE::abs(x.get_RCP());
272 }
273
274
275 Expression
276 sign(const Expression &x)
277 {
278 return SE::sign(x.get_RCP());
279 }
280
281
282 Expression
283 copysign(const Expression &value, const Expression &sign)
284 {
285 return value * Expression(SE::sign(sign.get_RCP()));
286 }
287
288
289 Expression
291 {
292 return SE::floor(x.get_RCP());
293 }
294
295
296 Expression
297 ceil(const Expression &x)
298 {
299 return SE::ceiling(x.get_RCP());
300 }
301
302
303 Expression
304 max(const Expression &a, const Expression &b)
305 {
306 return SE::max({a.get_RCP(), b.get_RCP()});
307 }
308
309
310 Expression
311 min(const Expression &a, const Expression &b)
312 {
313 return SE::min({a.get_RCP(), b.get_RCP()});
314 }
315
316
317 Expression
318 erf(const Expression &x)
319 {
320 return SE::erf(x.get_RCP());
321 }
322
323
324 Expression
325 erfc(const Expression &x)
326 {
327 return SE::erfc(x.get_RCP());
328 }
329
330 } // namespace SD
331} // namespace Differentiation
332
334
335#endif // DEAL_II_WITH_SYMENGINE
const SymEngine::RCP< const SymEngine::Basic > & get_RCP() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
Expression cbrt(const Expression &x)
Expression atanh(const Expression &x)
Expression atan2(const Expression &y, const Expression &x)
Expression asin(const Expression &x)
Expression asinh(const Expression &x)
Expression cosh(const Expression &x)
Expression csc(const Expression &x)
Expression acsch(const Expression &x)
Expression abs(const Expression &x)
Expression fabs(const Expression &x)
Expression ceil(const Expression &x)
Expression coth(const Expression &x)
Expression sinh(const Expression &x)
Expression sec(const Expression &x)
Expression atan(const Expression &x)
Expression floor(const Expression &x)
Expression tanh(const Expression &x)
Expression acsc(const Expression &x)
Expression sin(const Expression &x)
Expression max(const Expression &a, const Expression &b)
Expression erfc(const Expression &x)
Expression exp(const Expression &exponent)
Expression asech(const Expression &x)
Expression pow(const Expression &base, const Expression &exponent)
Expression sign(const Expression &x)
Expression sech(const Expression &x)
Expression acos(const Expression &x)
Expression csch(const Expression &x)
Expression tan(const Expression &x)
Expression acosh(const Expression &x)
Expression min(const Expression &a, const Expression &b)
Expression asec(const Expression &x)
Expression cot(const Expression &x)
Expression cos(const Expression &x)
Expression erf(const Expression &x)
Expression acoth(const Expression &x)
Expression acot(const Expression &x)
Expression log(const Expression &x)
Expression sqrt(const Expression &x)
Expression log10(const Expression &x)
Expression copysign(const Expression &value, const Expression &sign)