59 const auto nFullParams =
static_cast<Eigen::Index
>(this->
parameters_.size());
61 std::vector<Eigen::Index> enabledParameters;
62 enabledParameters.reserve(nFullParams);
63 for (
int iFullParam = 0; iFullParam < nFullParams; ++iFullParam) {
65 enabledParameters.push_back(iFullParam);
69 const auto nSubsetParams =
static_cast<int>(enabledParameters.size());
71 if (enabledParameters.empty()) {
77 qrSolver_.reset(nSubsetParams, std::sqrt(regularization_));
79 double error_orig = 0.0;
80 const size_t numBlocks = this->
solverFunction_->getJacobianBlockCount();
82 for (
size_t blockIdx = 0; blockIdx < numBlocks; ++blockIdx) {
83 const size_t blockSize = this->
solverFunction_->getJacobianBlockSize(blockIdx);
89 const auto rows =
static_cast<Eigen::Index
>(paddedBlockSize);
91 jacobian_.resizeAndSetZero(rows, nFullParams);
92 residual_.resizeAndSetZero(rows);
96 this->
parameters_, blockIdx, jacobian_.mat(), residual_.mat(), usedRows);
102 qrSolver_.addMutating(
104 jacobian_.mat().topRows(usedRows), enabledParameters),
105 residual_.mat().topRows(usedRows));
114 this->
error_ = error_orig;
116 const Eigen::VectorX<T> subsetDelta = qrSolver_.result();
118 Eigen::VectorX<T> searchDir = Eigen::VectorX<T>::Zero(nFullParams);
119 for (
int iSubsetParam = 0; iSubsetParam < nSubsetParams; ++iSubsetParam) {
120 const auto iFullParam = enabledParameters[iSubsetParam];
121 searchDir(iFullParam) = subsetDelta(iSubsetParam);
125 const double innerProd = -qrSolver_.At_times_b().dot(subsetDelta);
128 const float c_1 = 1e-4f;
129 const float tau = 0.5f;
132 const Eigen::VectorX<T> parameters_orig = this->
parameters_;
133 for (
size_t kStep = 0; kStep < 10 && std::fpclassify(alpha) == FP_NORMAL; ++kStep) {
140 if ((error_orig - error_new) >= c_1 * alpha * -innerProd) {