| 1 | // Ceres Solver - A fast non-linear least squares minimizercxx . . $ `<file>/internal/ceres/power_series_expansion_preconditioner.cc`/ |
| 2 | // Copyright 2023 Google Inc. All rights reserved. |
| 3 | // http://ceres-solver.org/ |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without |
| 6 | // modification, are permitted provided that the following conditions are met: |
| 7 | // |
| 8 | // * Redistributions of source code must retain the above copyright notice, |
| 9 | // this list of conditions and the following disclaimer. |
| 10 | // * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | // this list of conditions and the following disclaimer in the documentation |
| 12 | // and/or other materials provided with the distribution. |
| 13 | // * Neither the name of Google Inc. nor the names of its contributors may be |
| 14 | // used to endorse or promote products derived from this software without |
| 15 | // specific prior written permission. |
| 16 | // |
| 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 27 | // POSSIBILITY OF SUCH DAMAGE. |
| 28 | // |
| 29 | // Author: [email protected] (Mark Shachkov) |
| 30 | |
| 31 | #include "ceres/power_series_expansion_preconditioner.h"cxx . . $ `<file>/internal/ceres/power_series_expansion_preconditioner.h`/ |
| 32 | |
| 33 | #include "ceres/eigen_vector_ops.h"cxx . . $ `<file>/internal/ceres/eigen_vector_ops.h`/ |
| 34 | #include "ceres/parallel_vector_ops.h"cxx . . $ `<file>/internal/ceres/parallel_vector_ops.h`/ |
| 35 | #include "ceres/preconditioner.h"cxx . . $ `<file>/internal/ceres/preconditioner.h`/ |
| 36 | |
| 37 | namespace cerescxx . . $ ceres/::internalcxx . . $ ceres/internal/ { |
| 38 | |
| 39 | PowerSeriesExpansionPreconditionercxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#::PowerSeriesExpansionPreconditionercxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#PowerSeriesExpansionPreconditioner(5636533f9845f4e4).( |
| 40 | const ImplicitSchurComplementcxx . . $ ceres/internal/ImplicitSchurComplement#* isc, |
| 41 | const int max_num_spse_iterations, |
| 42 | const double spse_tolerance, |
| 43 | const Preconditionercxx . . $ ceres/internal/Preconditioner#::Optionscxx . . $ ceres/internal/Preconditioner#Options#& options) |
| 44 | : isc_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#isc_.(isc), |
| 45 | max_num_spse_iterations_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#max_num_spse_iterations_.(max_num_spse_iterations), |
| 46 | spse_tolerance_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#spse_tolerance_.(spse_tolerance), |
| 47 | options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_.(options) {} |
| 48 | |
| 49 | PowerSeriesExpansionPreconditionercxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#::~cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#`~PowerSeriesExpansionPreconditioner`(ced63f7c635d850d).PowerSeriesExpansionPreconditionercxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#() = |
| 50 | default; |
| 51 | |
| 52 | bool PowerSeriesExpansionPreconditionercxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#::Updatecxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#Update(13aaf9ee2e60065b).(const LinearOperatorcxx . . $ ceres/internal/LinearOperator#& /*A*/, |
| 53 | const double* /*D*/) { |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | void PowerSeriesExpansionPreconditionercxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#::RightMultiplyAndAccumulatecxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#RightMultiplyAndAccumulate(e2830e709b966a15).( |
| 58 | const double* x, double* y) const { |
| 59 | VectorRefcxx . . $ ceres/VectorRef# yrefcxx . . $ Eigen/Map#Map(4dc11cacba148567).(y, num_rowscxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#num_rows(455f465bc33b4cdf).()); |
| 60 | Vectorcxx . . $ ceres/Vector# series_termcxx . . $ Eigen/Matrix#Matrix(edcd8b2679e9bd1a).(num_rowscxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#num_rows(455f465bc33b4cdf).()); |
| 61 | Vectorcxx . . $ ceres/Vector# previous_series_termcxx . . $ Eigen/Matrix#Matrix(edcd8b2679e9bd1a).(num_rowscxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#num_rows(455f465bc33b4cdf).()); |
| 62 | ParallelSetZerocxx . . $ ceres/internal/ParallelSetZero(c064ed13d276d13f).(options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..contextcxx . . $ ceres/internal/Preconditioner#Options#context., options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..num_threadscxx . . $ ceres/internal/Preconditioner#Options#num_threads., yref); |
| 63 | isc_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#isc_.->block_diagonal_FtF_inversecxx . . $ ceres/internal/ImplicitSchurComplement#block_diagonal_FtF_inverse(c286b42a61343003).()->RightMultiplyAndAccumulatecxx . . $ ceres/internal/BlockSparseMatrix#RightMultiplyAndAccumulate(afd55616f326ff4e).( |
| 64 | x, y, options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..contextcxx . . $ ceres/internal/Preconditioner#Options#context., options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..num_threadscxx . . $ ceres/internal/Preconditioner#Options#num_threads.); |
| 65 | ParallelAssigncxx . . $ ceres/internal/ParallelAssign(1d5167670f3bfe8d).( |
| 66 | options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..contextcxx . . $ ceres/internal/Preconditioner#Options#context., options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..num_threadscxx . . $ ceres/internal/Preconditioner#Options#num_threads., previous_series_term, yref); |
| 67 | |
| 68 | const double norm_threshold = |
| 69 | spse_tolerance_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#spse_tolerance_. * Normcxx . . $ ceres/internal/Norm(38fae32d29e85ddc).(yref, options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..contextcxx . . $ ceres/internal/Preconditioner#Options#context., options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..num_threadscxx . . $ ceres/internal/Preconditioner#Options#num_threads.); |
| 70 | |
| 71 | for (int i = 1;; i++) { |
| 72 | ParallelSetZerocxx . . $ ceres/internal/ParallelSetZero(c064ed13d276d13f).(options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..contextcxx . . $ ceres/internal/Preconditioner#Options#context., options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..num_threadscxx . . $ ceres/internal/Preconditioner#Options#num_threads., series_term); |
| 73 | isc_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#isc_.->InversePowerSeriesOperatorRightMultiplyAccumulatecxx . . $ ceres/internal/ImplicitSchurComplement#InversePowerSeriesOperatorRightMultiplyAccumulate(e2830e709b966a15).( |
| 74 | previous_series_term.datacxx . . $ Eigen/PlainObjectBase#data(654f260ebb5356a9).(), series_term.datacxx . . $ Eigen/PlainObjectBase#data(654f260ebb5356a9).()); |
| 75 | ParallelAssigncxx . . $ ceres/internal/ParallelAssign(1d5167670f3bfe8d).( |
| 76 | options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..contextcxx . . $ ceres/internal/Preconditioner#Options#context., options_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#options_..num_threadscxx . . $ ceres/internal/Preconditioner#Options#num_threads., yref, yref +cxx . . $ Eigen/MatrixBase#operator+(5b980a29d77f232c). series_term); |
| 77 | if (i >= max_num_spse_iterations_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#max_num_spse_iterations_. || series_term.normcxx . . $ Eigen/MatrixBase#norm(16c6a9c61072a1c3).() < norm_threshold) { |
| 78 | break; |
| 79 | } |
| 80 | stdcxx . . $ std/::swapcxx . . $ std/swap(c75b8fd57d7c2e06).(previous_series_term, series_term); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | int PowerSeriesExpansionPreconditionercxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#::num_rowscxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#num_rows(455f465bc33b4cdf).() const { |
| 85 | return isc_cxx . . $ ceres/internal/PowerSeriesExpansionPreconditioner#isc_.->num_rowscxx . . $ ceres/internal/ImplicitSchurComplement#num_rows(455f465bc33b4cdf).(); |
| 86 | } |
| 87 | |
| 88 | } // namespace ceres::internal |