1#ifndef MPTENSOR_TEST_TEST_FUNCTIONS_HPP_
2#define MPTENSOR_TEST_TEST_FUNCTIONS_HPP_
20constexpr double kEps = 1.0e-10;
33 if constexpr (std::is_same_v<T, double>) {
34 return 1.0 / (1.0 + std::abs(
x0 - std::sqrt(
x1)));
47 if constexpr (std::is_same_v<T, double>) {
48 return (
x0 +
x1) / (1.0 + std::abs(
x2 -
x3));
61 if constexpr (std::is_same_v<T, double>) {
62 return std::cos(
x0 *
x3) + std::sin(
x1 / (
x2 + 1.0));
73template <
typename TensorType,
typename F>
75 const Shape shape = t.shape();
76 for (std::size_t
i = 0;
i < t.local_size(); ++
i) {
77 t[
i] =
f(t.global_index(
i), shape);
82template <
typename TensorType,
typename F>
85 for (std::size_t
i = 0;
i < t.local_size(); ++
i) {
std::complex< double > complex
Definition complex.hpp:38
Top header file of mptensor.
double coord(const Index &idx, const Shape &shape, std::size_t k)
Definition test_functions.hpp:23
Definition mpi_helpers.hpp:10
T func4_2(const Index &idx, const Shape &shape)
Analytic rank-4 element (legacy func4_2 / cfunc4_2).
Definition test_functions.hpp:56
constexpr double kEps
Default tolerance.
Definition test_functions.hpp:20
double max_over_ranks(double local, MPI_Comm comm)
Maximum of local over all ranks of comm. Collective.
Definition mpi_helpers.hpp:19
void fill_tensor(TensorType &t, F f)
Set every local element to f(global_index, shape).
Definition test_functions.hpp:74
constexpr int kL
Base size of test tensors (legacy default N).
Definition test_functions.hpp:18
T func2_1(const Index &idx, const Shape &shape)
Analytic matrix element (legacy func2_1 / cfunc2_1).
Definition test_functions.hpp:30
double max_error(const TensorType &t, F exact)
Maximum over all ranks of |t[idx] - exact(idx)|. Collective.
Definition test_functions.hpp:83
double conj_value(double x)
Complex conjugate that keeps double as double.
Definition test_functions.hpp:69
T func4_1(const Index &idx, const Shape &shape)
Analytic rank-4 element (legacy func4_1 / cfunc4_1).
Definition test_functions.hpp:42
Definition complex.hpp:34