1#ifndef TATOOINE_SYMBOLIC_H
2#define TATOOINE_SYMBOLIC_H
3#include <tatooine/available_libraries.h>
4#if TATOOINE_GINAC_AVAILABLE
6#include <ginac/ginac.h>
11 template <size_t... Is> \
12 static auto sym(size_t idx, std::index_sequence<Is...> )->auto& { \
13 static std::array<GiNaC::symbol, sizeof...(Is)> sym_arr{ \
15 GiNaC::symbol{#sym + std::string{"_"} + std::to_string(Is)})...}; \
16 return sym_arr[idx]; \
18 static auto sym(size_t idx)->auto& { \
19 return sym(idx, std::make_index_sequence<num_pos_symbols>{}); \
21 static auto sym()->auto& { \
22 static GiNaC::symbol sym{#sym}; \
28 sym(i) sym(j) sym(k) sym(x) sym(y) sym(z) sym(t)
34template <
typename... Relations>
35auto ev(
const GiNaC::ex& expr, Relations&&... relations) {
36 GiNaC::lst substitutions{std::forward<Relations>(relations)...};
37 return expr.subs(substitutions);
42template <
typename out_real_type =
double,
typename... Relations>
43auto evtod(
const GiNaC::ex& expr, Relations&&... relations) {
44 return static_cast<out_real_type
>(
45 GiNaC::ex_to<GiNaC::numeric>(
46 ev(expr, std::forward<Relations>(relations)...).
evalf())
54#include "type_traits.h"
60 : std::integral_constant<bool, std::is_same_v<T, GiNaC::ex> ||
61 std::is_same_v<T, GiNaC::symbol>> {};
66template <
typename... Ts>
69template <
typename... Ts>
76struct are_symbolic<T> : std::integral_constant<bool, is_symbolic_v<T>> {};
78template <
typename T0,
typename T1,
typename... Ts>
80 : std::integral_constant<bool, are_symbolic_v<T0> &&
81 are_symbolic_v<T1, Ts...>> {};
83template <
typename... Ts>
85 : std::integral_constant<bool, are_arithmetic_v<Ts...> ||
86 are_symbolic_v<Ts...>> {};
88template <
typename... Ts>
92template <
typename... Ts>
94 : std::integral_constant<bool, are_arithmetic_v<Ts...> ||
95 are_complex_v<Ts...> ||
96 are_symbolic_v<Ts...>> {};
98template <
typename... Ts>
auto evtod(const GiNaC::ex &expr, Relations &&... relations)
Definition: symbolic.h:43
auto ev(const GiNaC::ex &expr, Relations &&... relations)
substitudes expression with relations
Definition: symbolic.h:35
Definition: algorithm.h:6
static constexpr auto is_symbolic_v
Definition: symbolic.h:64
static constexpr auto are_arithmetic_complex_or_symbolic_v
Definition: symbolic.h:99
static constexpr auto are_symbolic_v
Definition: symbolic.h:70
void evalf(base_tensor< Tensor, GiNaC::ex, Dims... > &m)
Definition: tensor_symbolic.h:58
static constexpr auto are_arithmetic_or_symbolic_v
Definition: symbolic.h:89
Definition: symbolic.h:96
Definition: symbolic.h:86
Definition: symbolic.h:67
Definition: symbolic.h:61
Definition: symbolic.h:26
static constexpr size_t num_pos_symbols
Definition: symbolic.h:27