14 t_Matrix const A = t_Matrix::Random(
b.size(),
b.size());
17 t_Matrix const AhA = A.conjugate().transpose() * A;
18 t_Vector const Ahb = A.conjugate().transpose() *
b;
23 out = A.conjugate().transpose() * A * input;
30 auto as_matrix = cg(AhA, Ahb);
31 auto as_function = cg(aha_function, Ahb);
34 if (not(as_matrix.good and as_function.good))
throw std::runtime_error(
"Expected convergence");
35 if (as_matrix.niters != as_function.niters)
36 throw std::runtime_error(
"Expected same number of iterations");
37 if (as_matrix.residual > cg.tolerance() or as_function.residual > cg.tolerance())
38 throw std::runtime_error(
"Expected better convergence");
39 if (not as_matrix.result.isApprox(as_function.result, 1e-6))
40 throw std::runtime_error(
"Expected same result");
41 if (not(A * as_matrix.result).isApprox(
b, 1e-6))
42 throw std::runtime_error(
"Expected solution to Ax=b");
sopt::Vector< Scalar > t_Vector
sopt::Matrix< Scalar > t_Matrix
Solves $Ax = b$ for $x$, given $A$ and $b$.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A matrix of a given type.