0

When I run the following code in tutorial of ceres solver,I met some problem.

Here is the code:

#include <iostream>

#include "ceres/ceres.h"
#include "glog/logging.h"
using ceres::AutoDiffCostFunction;
using ceres::CostFunction;
using ceres::Problem;
using ceres::Solve;
using ceres::Solver;
struct CostFunctor {
    template <typename T>
    bool operator()(const T* const x, T* residual) const {
        residual[0] = 10.0 - x[0];
        return true;
    }
};
int main(int argc, char *argv[])
{
    double x = 0.5;
    const double initial_x = x;
    Problem problem;
    CostFunction* cost_function =
        new AutoDiffCostFunction<CostFunctor, 1, 1>(new CostFunctor);
    problem.AddResidualBlock(cost_function, nullptr, &x);
    Solver::Options options;
    options.minimizer_progress_to_stdout = true;
    Solver::Summary summary;
    Solve(options, &problem, &summary);
    std::cout << summary.BriefReport() << "\n";
    std::cout << "x : " << initial_x << " -> " << x << "\n";
}

And I got the problem:

E:\study_materials\Computer Version\ceres\ceres-solver-2.0.0\internal\ceres\solver.cc:505 Terminating: Can't use SPARSE_NORMAL_CHOLESKY with Solver::Options::sparse_linear_algebra_library_type = SUITE_SPARSE, because support was not enabled when Ceres Solver was built.

I don't know how to enable this support,any assistance will be appreciated.

  • How did you install Ceres ? Downloaded the binaries, or built from source ? – TheEagle Nov 26 '21 at 14:29
  • https://github.com/ceres-solver/ceres-solver/blob/2.0.0/CMakeLists.txt#L360 this message in `CMakeLists` from the github repo is quite straightforward. Make sure you have at least one of the mentioned libraries available. – pptaszni Nov 26 '21 at 14:35

1 Answers1

0

what version of ceres solver is this? if a sparse linear algebra library is not available, it should default to using a dense solver (DENSE_QR). So this looks like a bug in the way defaults are setup in ceres solver.

Sameer Agarwal
  • 592
  • 2
  • 4
  • Please phrase this as an explained conditional answer, in order to avoid the impression of asking a clarification question instead of answering (for which a comment should be used instead of an answer, compare https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead ). For example like "If your problem is ... then the solution is to .... because .... ." – Yunnosch Apr 29 '22 at 19:07
  • Or use your commenting privilege to first ask a clarification question and then answer assertively. – Yunnosch Apr 29 '22 at 19:08