11#ifndef EXAMPLES_ERROR_HPP_
12#define EXAMPLES_ERROR_HPP_
20template <
typename Scalar>
21inline Eigen::Matrix<double, Eigen::Dynamic, 1> errors(
22 const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &
pot,
23 const Eigen::MatrixXd &
grid,
24 const std::function<Scalar(Eigen::Vector3d)> &
fun) {
27 (
"The size does not match!"));
29 "The grid must be a Matrix with a 3d point in each row!");
30 assert((std::min(
pot.rows(),
pot.cols())) && (
"Potential must be Vector!"));
32 Eigen::Matrix<double, 1, Eigen::Dynamic> errors(
gridsz);
35 errors(
i) = std::abs(
pot(
i) -
fun((
grid.row(
i).transpose()).eval()));
40inline Eigen::Matrix<double, Eigen::Dynamic, 1> errors(
41 const Eigen::MatrixXcd &
pot,
const Eigen::MatrixXd &
grid,
42 const std::function<Eigen::Vector3cd(Eigen::Vector3d, std::complex<double>)>
44 std::complex<double>
kappa) {
47 (
"The size does not match!"));
49 "The grid must be a Matrix with a 3d point in each row!");
51 (
"Potential must be a Matrix with a Vector3cd in each col!"));
52 Eigen::Matrix<double, 1, Eigen::Dynamic> errors(
gridsz);
61template <
typename Scalar>
62inline double maxPointwiseError(
63 const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> &
pot,
64 const Eigen::MatrixXd &
grid,
65 const std::function<Scalar(Eigen::Vector3d)> &
fun) {
68 (
"The size does not match!"));
70 "The grid must be a Matrix with a 3d point in each row!");
72 (
"Potential must be a vector!"));
82inline double maxPointwiseError(
83 const Eigen::MatrixXcd &
pot,
const Eigen::MatrixXd &
grid,
84 const std::function<Eigen::Vector3cd(Eigen::Vector3d)> &
fun) {
88 (
"The size does not match!"));
90 "The grid must be a Matrix with a 3d point in each row!");
92 (
"Must be a Matrix with a point solution in each row!"));
102double estimateRateOfConvergence(
const Eigen::VectorXd &errors) {
103 Eigen::MatrixXd
A(errors.rows(), 2);
104 A << Eigen::VectorXd::Ones(errors.rows()),
105 Eigen::VectorXd::LinSpaced(errors.rows(), 0, errors.rows() - 1);
106 Eigen::VectorXd
b = errors.array().abs().log() / std::log(2);
107 Eigen::VectorXd
x =
A.colPivHouseholderQr().solve(
b);
111bool checkRateOfConvergence(
const Eigen::VectorXd &errors,
Routines for the evalutation of pointwise errors.
constexpr int getFunctionSpaceOutputDimension()