47 std::vector<csl::Parent>
const &from,
48 std::vector<csl::Parent>
const &to
53 std::vector<csl::Expr>
const &from,
54 std::vector<csl::Expr>
const &to
59 std::vector<csl::Expr>
const &from,
60 std::vector<csl::Expr>
const &to
65 std::vector<csl::Parent>
const &from,
66 std::vector<csl::Expr>
const &to,
70 template<
class T,
class U,
class Type,
class Type2 = Type>
72 static inline constexpr
bool value =
73 std::is_convertible_v<std::decay_t<T>,
Type>
74 && std::is_convertible_v<std::decay_t<U>, Type2>;
78 template<
class T,
class U,
class Type,
class Type2 = Type>
85 template<
class T,
class U,
class ...Params,
86 typename = std::enable_if_t<
87 !csl::canDecay_v<T, U, csl::Index>
88 && !csl::canDecay_v<T, U, csl::IndexStructure>
89 && !csl::canDecay_v<T, U, std::vector<csl::Index>>
105 std::forward<Params>(params)...
129 expr = csl::Replaced(expr, from, to, refresh);
135 std::vector<csl::Index>
const &from,
136 std::vector<csl::Index>
const &to,
142 std::vector<csl::Index>
const &from,
143 std::vector<csl::Index>
const &to,
147 expr = csl::Replaced(expr, from, to, refresh);
165 expr = csl::Replaced(expr, from, to, refresh);
183 std::function<std::optional<csl::Expr>(
csl::Expr const&, bool)>;
195 return [&rule](csl::Expr
const &expr) ->
bool {
196 return bool(rule(expr,
true));
211 csl::Expr
const &expr,
212 std::function<
bool(csl::Expr
const&)>
const &predicate
231 std::optional<csl::Expr> scalarReplacement(
232 csl::Expr
const &expr,
233 std::vector<csl::Expr>
const &from,
234 std::vector<csl::Expr>
const &ccFrom,
235 std::vector<csl::Expr>
const &to,
239 std::optional<csl::Expr> indicialReplacement(
240 csl::Expr
const &expr,
241 std::vector<csl::Expr>
const &from,
242 std::vector<csl::Parent_info>
const &parentFrom,
243 std::vector<csl::Expr>
const &to,
247 std::optional<csl::Expr> tensorReplacement(
248 csl::Expr
const &expr,
249 std::vector<csl::Parent>
const &from,
250 std::vector<csl::Parent>
const &to,
254 std::optional<csl::Expr> tensorExpressionReplacement(
255 csl::Expr
const &expr,
256 std::vector<csl::Parent>
const &from,
257 std::vector<csl::Expr>
const &to,
265 void ResetDummyIndices(csl::Expr &expr);
280 std::map<csl::Index, csl::Index> &mapping
283 void RenameIndices(csl::Expr& expr);
285 csl::Expr RenamedIndices(csl::Expr
const& expr);
287 void internal_RenameIndices(
289 std::map<csl::Index, csl::Index> &mapping
296 template<
class ParentType,
297 typename = std::enable_if_t<std::is_convertible_v<ParentType, Parent>>
301 std::vector<ParentType>
const& t_from,
302 std::vector<ParentType>
const& t_to)
304 std::vector<Parent> from(t_from.size());
305 std::vector<Parent> to(t_to.size());
306 for (
size_t i = 0; i != from.size(); ++i)
308 for (
size_t i = 0; i != to.size(); ++i)
310 Replace(expr, from, to);
313 template<
class ParentType,
314 typename = std::enable_if_t<std::is_convertible_v<ParentType, Parent>>
318 std::vector<ParentType>
const& t_from,
319 std::vector<csl::Expr>
const& to)
321 std::vector<Parent> from(t_from.size());
322 for (
size_t i = 0; i != from.size(); ++i)
324 Replace(expr, from, to);
333 template<
class ...Args>
334 Expr Tried(
const Expr& expr, Args &&...args)
336 Expr trial = Replaced(expr, std::forward<Args>(args)...);
337 return (*trial < expr.get()) ? trial : expr;
340 template<
class ...Args>
341 void Try(
Expr& expr, Args &&...args)
343 Expr trial = Replaced(expr, std::forward<Args>(args)...);
Namespace for csl library.
Definition: abreviation.h:34
Index object that is used for indicial objects.
Definition: index.h:75
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
auto ruleToPredicate(replacementRule const &rule)
Converts a replacementRule into a predicate.
Definition: replace.h:194
std::function< std::optional< csl::Expr >(csl::Expr const &, bool)> replacementRule
Replacement rule prototype.
Definition: replace.h:183
void applyThroughAbbreviations(csl::Expr &expr, replacementRule const &rule)
Applies a replacement rule thoughout an expression, also entering abbreviations and replacing them if...
Definition: replace.cpp:287
bool hasWeakDependency(csl::Expr const &expr, std::function< bool(csl::Expr const &)> const &predicate)
Search for a true value for a given predicate in an expression, considering also sub-expressions enca...
Definition: replace.cpp:270
Base classes for all exprs in the program.
Manages a std::vector of Index, to be used by an TensorElement.
Definition: index.h:472
Expression type/.
Definition: abstract.h:1573