1#ifndef MATH_FUNCTIONS_DEFINED
2#define MATH_FUNCTIONS_DEFINED
12template <
typename F =
double>
14 return std::acos(F(-1));
17template <
typename F =
double>
23template <
typename F =
double>
28template <
typename F =
double>
29inline F
abs(F
const x) {
39inline double conj(
double const x) {
44template <
typename F =
double>
45inline F
dot(F
const x, F
const y) {
52template <
typename F =
double>
54 return std::real(x *
conj(y));
57template <
typename F =
double>
58inline F
divide(F
const x, F
const y) {
62template <
typename F =
double>
69 char *indices(
new char[t.order + 1]);
70 for (
int index(0); index < t.order; ++index) indices[index] =
'a' + index;
72 CTF::Bivar_Function<F> fRealDot(&sisi4s::realDot<F>);
73 CTF::Scalar<F> s(*t.wrld);
74 s.contract(1.0, t, indices, t, indices, 0.0,
"", fRealDot);
75 return std::sqrt(std::real(s.get_val()));
89 t[indices.c_str()] += prefactor * t[permuted.c_str()];
96 testResultUp[
"abij"] += testResultUp[
"baij"];
97 testResultDown[
"abij"] += testResultDown[
"abji"];
98 normValue = testResultUp.norm1();
99 normValue += testResultDown.norm1();
100 if (normValue >= 1e-3) {
102 LOG(0,
"AntisymmetryCheck")
103 << t.get_name() <<
": zero tensor norm " << normValue << std::endl;
#define LOG(...)
Definition Log.hpp:119
Definition Algorithm.hpp:10
void checkAntisymmetry(Tensor< F > &t)
Definition MathFunctions.hpp:92
CTF::Tensor< F > Tensor
Definition Tensor.hpp:9
void symmetrize(std::string indices, std::string permuted, Tensor< F > &t, F prefactor=1)
Apply a permutation operator and antisymmetrize accordingly, e.g. antiSymmetrize(X,...
Definition MathFunctions.hpp:85
F sqrt(F const x)
Definition MathFunctions.hpp:24
F divide(F const x, F const y)
Definition MathFunctions.hpp:58
constexpr F Pi()
Definition MathFunctions.hpp:13
F multiply(F const x, F const y)
Definition MathFunctions.hpp:63
F dot(F const x, F const y)
Definition MathFunctions.hpp:45
constexpr F Tau()
Definition MathFunctions.hpp:18
F realDot(F const x, F const y)
Calculates only the real part of x*conj(y).
Definition MathFunctions.hpp:53
double frobeniusNorm(Tensor< F > &t)
Definition MathFunctions.hpp:68
F abs(F const x)
Definition MathFunctions.hpp:29
F conj(F const x)
Definition MathFunctions.hpp:34