32 #define TEST_NAME "optim/least_absolute_deviations"
35 #include <Eigen/Dense>
43 Eigen::SparseMatrix<double> A(4, 3);
44 for (
int i = 0; i < A.rows(); ++i) {
45 for (
int j = 0; j < A.cols(); ++j) {
46 A.insert(i, j) = i * A.cols() + j + 1;
49 A.coeffRef(0, 0) = 10;
51 Eigen::VectorXd b(A.rows());
52 for (
int i = 0; i < b.size(); ++i) {
56 Eigen::VectorXd
x = Eigen::VectorXd::Zero(A.cols());
62 const Eigen::Vector3d x_ref(0, 0, 1 / 3.0);
63 BOOST_CHECK(
x.isApprox(x_ref));
65 const Eigen::VectorXd residual = A *
x - b;
66 BOOST_CHECK_LE(residual.norm(), 1
e-6);
70 Eigen::SparseMatrix<double> A(3, 3);
71 for (
int i = 0; i < A.rows(); ++i) {
72 for (
int j = 0; j < A.cols(); ++j) {
73 A.insert(i, j) = i * A.cols() + j + 1;
76 A.coeffRef(0, 0) = 10;
78 Eigen::VectorXd b(A.rows());
79 for (
int i = 0; i < b.size(); ++i) {
83 Eigen::VectorXd
x = Eigen::VectorXd::Zero(A.cols());
89 const Eigen::Vector3d x_ref(0, 0, 1 / 3.0);
90 BOOST_CHECK(
x.isApprox(x_ref));
92 const Eigen::VectorXd residual = A *
x - b;
93 BOOST_CHECK_LE(residual.norm(), 1
e-6);
98 Eigen::SparseMatrix<double> A(2, 3);
99 Eigen::VectorXd b(A.rows());
100 Eigen::VectorXd
x = Eigen::VectorXd::Zero(A.cols());
BOOST_AUTO_TEST_CASE(TestOverDetermined)
bool SolveLeastAbsoluteDeviations(const LeastAbsoluteDeviationsOptions &options, const Eigen::SparseMatrix< double > &A, const Eigen::VectorXd &b, Eigen::VectorXd *x)