schur_eliminator.cc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // Ceres Solver - A fast non-linear least squares minimizer
  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: sameeragarwal@google.com (Sameer Agarwal)
  30. //
  31. // Template specialization of SchurEliminator.
  32. //
  33. // ========================================
  34. // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
  35. // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
  36. // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
  37. // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
  38. //=========================================
  39. //
  40. // This file is generated using generate_template_specializations.py.
  41. #include <memory>
  42. #include "ceres/linear_solver.h"
  43. #include "ceres/schur_eliminator.h"
  44. namespace ceres::internal {
  45. SchurEliminatorBase::~SchurEliminatorBase() = default;
  46. std::unique_ptr<SchurEliminatorBase> SchurEliminatorBase::Create(
  47. const LinearSolver::Options& options) {
  48. #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
  49. if ((options.row_block_size == 2) &&
  50. (options.e_block_size == 2) &&
  51. (options.f_block_size == 2)) {
  52. return std::make_unique<SchurEliminator<2, 2, 2>>(options);
  53. }
  54. if ((options.row_block_size == 2) &&
  55. (options.e_block_size == 2) &&
  56. (options.f_block_size == 3)) {
  57. return std::make_unique<SchurEliminator<2, 2, 3>>(options);
  58. }
  59. if ((options.row_block_size == 2) &&
  60. (options.e_block_size == 2) &&
  61. (options.f_block_size == 4)) {
  62. return std::make_unique<SchurEliminator<2, 2, 4>>(options);
  63. }
  64. if ((options.row_block_size == 2) &&
  65. (options.e_block_size == 2)) {
  66. return std::make_unique<SchurEliminator<2, 2, Eigen::Dynamic>>(options);
  67. }
  68. if ((options.row_block_size == 2) &&
  69. (options.e_block_size == 3) &&
  70. (options.f_block_size == 3)) {
  71. return std::make_unique<SchurEliminator<2, 3, 3>>(options);
  72. }
  73. if ((options.row_block_size == 2) &&
  74. (options.e_block_size == 3) &&
  75. (options.f_block_size == 4)) {
  76. return std::make_unique<SchurEliminator<2, 3, 4>>(options);
  77. }
  78. if ((options.row_block_size == 2) &&
  79. (options.e_block_size == 3) &&
  80. (options.f_block_size == 6)) {
  81. return std::make_unique<SchurEliminator<2, 3, 6>>(options);
  82. }
  83. if ((options.row_block_size == 2) &&
  84. (options.e_block_size == 3) &&
  85. (options.f_block_size == 9)) {
  86. return std::make_unique<SchurEliminator<2, 3, 9>>(options);
  87. }
  88. if ((options.row_block_size == 2) &&
  89. (options.e_block_size == 3)) {
  90. return std::make_unique<SchurEliminator<2, 3, Eigen::Dynamic>>(options);
  91. }
  92. if ((options.row_block_size == 2) &&
  93. (options.e_block_size == 4) &&
  94. (options.f_block_size == 3)) {
  95. return std::make_unique<SchurEliminator<2, 4, 3>>(options);
  96. }
  97. if ((options.row_block_size == 2) &&
  98. (options.e_block_size == 4) &&
  99. (options.f_block_size == 4)) {
  100. return std::make_unique<SchurEliminator<2, 4, 4>>(options);
  101. }
  102. if ((options.row_block_size == 2) &&
  103. (options.e_block_size == 4) &&
  104. (options.f_block_size == 6)) {
  105. return std::make_unique<SchurEliminator<2, 4, 6>>(options);
  106. }
  107. if ((options.row_block_size == 2) &&
  108. (options.e_block_size == 4) &&
  109. (options.f_block_size == 8)) {
  110. return std::make_unique<SchurEliminator<2, 4, 8>>(options);
  111. }
  112. if ((options.row_block_size == 2) &&
  113. (options.e_block_size == 4) &&
  114. (options.f_block_size == 9)) {
  115. return std::make_unique<SchurEliminator<2, 4, 9>>(options);
  116. }
  117. if ((options.row_block_size == 2) &&
  118. (options.e_block_size == 4)) {
  119. return std::make_unique<SchurEliminator<2, 4, Eigen::Dynamic>>(options);
  120. }
  121. if (options.row_block_size == 2) {
  122. return std::make_unique<SchurEliminator<2, Eigen::Dynamic, Eigen::Dynamic>>(options);
  123. }
  124. if ((options.row_block_size == 3) &&
  125. (options.e_block_size == 3) &&
  126. (options.f_block_size == 3)) {
  127. return std::make_unique<SchurEliminator<3, 3, 3>>(options);
  128. }
  129. if ((options.row_block_size == 4) &&
  130. (options.e_block_size == 4) &&
  131. (options.f_block_size == 2)) {
  132. return std::make_unique<SchurEliminator<4, 4, 2>>(options);
  133. }
  134. if ((options.row_block_size == 4) &&
  135. (options.e_block_size == 4) &&
  136. (options.f_block_size == 3)) {
  137. return std::make_unique<SchurEliminator<4, 4, 3>>(options);
  138. }
  139. if ((options.row_block_size == 4) &&
  140. (options.e_block_size == 4) &&
  141. (options.f_block_size == 4)) {
  142. return std::make_unique<SchurEliminator<4, 4, 4>>(options);
  143. }
  144. if ((options.row_block_size == 4) &&
  145. (options.e_block_size == 4)) {
  146. return std::make_unique<SchurEliminator<4, 4, Eigen::Dynamic>>(options);
  147. }
  148. #endif
  149. VLOG(1) << "Template specializations not found for <"
  150. << options.row_block_size << "," << options.e_block_size << ","
  151. << options.f_block_size << ">";
  152. return std::make_unique<SchurEliminator<Eigen::Dynamic,
  153. Eigen::Dynamic,
  154. Eigen::Dynamic>>(options);
  155. }
  156. } // namespace ceres::internal