1+ #include < iterator>
2+ #include < fmt/format.h>
3+ #include < catch2/catch_approx.hpp>
4+ #include < catch2/catch_test_macros.hpp>
5+ #include < catch2/benchmark/catch_benchmark_all.hpp>
6+ #include < catch2/generators/catch_generators_all.hpp>
7+ #include < catch2/matchers/catch_matchers_floating_point.hpp>
8+ #include " models/romoperator.hpp"
9+
10+ using namespace palace ;
11+
12+ // auto complex_circle_sample_points(int nr_sample_points, double radius = 5.5)
13+ // {
14+ // double end_point_linscale = double(nr_sample_points - 1) / nr_sample_points;
15+ // Eigen::ArrayXcd zj_sample =
16+ // Eigen::ArrayXcd::LinSpaced(nr_sample_points, 0, 2 * M_PI * end_point_linscale);
17+ // zj_sample =
18+ // zj_sample.unaryExpr([radius](std::complex<double> z)
19+ // { return radius * std::exp(std::complex<double>(0., 1.) * z);
20+ // });
21+ // return zj_sample;
22+ // }
23+
24+ TEST_CASE (" MinimalRationalInterpolation" , " [romoperator]" )
25+ {
26+ auto *comm = Mpi::World ();
27+
28+ auto fn_tan_shift = [](double z)
29+ { return std::tan (0.5 * M_PI * (z - std::complex <double >(1 ., 1 .))); };
30+
31+ // Test scalar case: 2 sample points for 2 x 2 vector
32+ MinimalRationalInterpolation mri_1 (2 );
33+
34+ CHECK (mri_1.GetSamplePoints () == std::vector<double >{});
35+ CHECK_THROWS (mri_1.FindMaxError (1 ));
36+
37+ for (double x_sample : {-1.0 , 1.0 })
38+ {
39+ ComplexVector c_vec (1 );
40+ c_vec = fn_tan_shift (x_sample) / double (Mpi::Size (comm));
41+
42+ mri_1.AddSolutionSample (x_sample, c_vec, comm, Orthogonalization::MGS);
43+ }
44+
45+ CHECK (mri_1.GetSamplePoints ().size () == 2 );
46+ CHECK (mri_1.GetSamplePoints () == std::vector<double >{-1.0 , 1.0 });
47+ // By symmetry of poles max erro should be at zero.
48+ auto max_err_1 = mri_1.FindMaxError (1 );
49+ REQUIRE (max_err_1.size () == 1 );
50+ CHECK_THAT (max_err_1[0 ], Catch::Matchers::WithinAbsMatcher (0 ., 1e-6 ));
51+ }
0 commit comments