partitioned_matrix_view.cc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. // Ceres Solver - A fast non-linear least squares minimizer
  2. // Copyright 2017 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 PartitionedMatrixView.
  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/partitioned_matrix_view.h"
  44. namespace ceres::internal {
  45. PartitionedMatrixViewBase::~PartitionedMatrixViewBase() = default;
  46. std::unique_ptr<PartitionedMatrixViewBase> PartitionedMatrixViewBase::Create(
  47. const LinearSolver::Options& options, const BlockSparseMatrix& matrix) {
  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<PartitionedMatrixView<2,2, 2>>(
  53. options, matrix);
  54. }
  55. if ((options.row_block_size == 2) &&
  56. (options.e_block_size == 2) &&
  57. (options.f_block_size == 3)) {
  58. return std::make_unique<PartitionedMatrixView<2,2, 3>>(
  59. options, matrix);
  60. }
  61. if ((options.row_block_size == 2) &&
  62. (options.e_block_size == 2) &&
  63. (options.f_block_size == 4)) {
  64. return std::make_unique<PartitionedMatrixView<2,2, 4>>(
  65. options, matrix);
  66. }
  67. if ((options.row_block_size == 2) &&
  68. (options.e_block_size == 2)) {
  69. return std::make_unique<PartitionedMatrixView<2,2, Eigen::Dynamic>>(
  70. options, matrix);
  71. }
  72. if ((options.row_block_size == 2) &&
  73. (options.e_block_size == 3) &&
  74. (options.f_block_size == 3)) {
  75. return std::make_unique<PartitionedMatrixView<2,3, 3>>(
  76. options, matrix);
  77. }
  78. if ((options.row_block_size == 2) &&
  79. (options.e_block_size == 3) &&
  80. (options.f_block_size == 4)) {
  81. return std::make_unique<PartitionedMatrixView<2,3, 4>>(
  82. options, matrix);
  83. }
  84. if ((options.row_block_size == 2) &&
  85. (options.e_block_size == 3) &&
  86. (options.f_block_size == 6)) {
  87. return std::make_unique<PartitionedMatrixView<2,3, 6>>(
  88. options, matrix);
  89. }
  90. if ((options.row_block_size == 2) &&
  91. (options.e_block_size == 3) &&
  92. (options.f_block_size == 9)) {
  93. return std::make_unique<PartitionedMatrixView<2,3, 9>>(
  94. options, matrix);
  95. }
  96. if ((options.row_block_size == 2) &&
  97. (options.e_block_size == 3)) {
  98. return std::make_unique<PartitionedMatrixView<2,3, Eigen::Dynamic>>(
  99. options, matrix);
  100. }
  101. if ((options.row_block_size == 2) &&
  102. (options.e_block_size == 4) &&
  103. (options.f_block_size == 3)) {
  104. return std::make_unique<PartitionedMatrixView<2,4, 3>>(
  105. options, matrix);
  106. }
  107. if ((options.row_block_size == 2) &&
  108. (options.e_block_size == 4) &&
  109. (options.f_block_size == 4)) {
  110. return std::make_unique<PartitionedMatrixView<2,4, 4>>(
  111. options, matrix);
  112. }
  113. if ((options.row_block_size == 2) &&
  114. (options.e_block_size == 4) &&
  115. (options.f_block_size == 6)) {
  116. return std::make_unique<PartitionedMatrixView<2,4, 6>>(
  117. options, matrix);
  118. }
  119. if ((options.row_block_size == 2) &&
  120. (options.e_block_size == 4) &&
  121. (options.f_block_size == 8)) {
  122. return std::make_unique<PartitionedMatrixView<2,4, 8>>(
  123. options, matrix);
  124. }
  125. if ((options.row_block_size == 2) &&
  126. (options.e_block_size == 4) &&
  127. (options.f_block_size == 9)) {
  128. return std::make_unique<PartitionedMatrixView<2,4, 9>>(
  129. options, matrix);
  130. }
  131. if ((options.row_block_size == 2) &&
  132. (options.e_block_size == 4)) {
  133. return std::make_unique<PartitionedMatrixView<2,4, Eigen::Dynamic>>(
  134. options, matrix);
  135. }
  136. if (options.row_block_size == 2) {
  137. return std::make_unique<PartitionedMatrixView<2,Eigen::Dynamic, Eigen::Dynamic>>(
  138. options, matrix);
  139. }
  140. if ((options.row_block_size == 3) &&
  141. (options.e_block_size == 3) &&
  142. (options.f_block_size == 3)) {
  143. return std::make_unique<PartitionedMatrixView<3,3, 3>>(
  144. options, matrix);
  145. }
  146. if ((options.row_block_size == 4) &&
  147. (options.e_block_size == 4) &&
  148. (options.f_block_size == 2)) {
  149. return std::make_unique<PartitionedMatrixView<4,4, 2>>(
  150. options, matrix);
  151. }
  152. if ((options.row_block_size == 4) &&
  153. (options.e_block_size == 4) &&
  154. (options.f_block_size == 3)) {
  155. return std::make_unique<PartitionedMatrixView<4,4, 3>>(
  156. options, matrix);
  157. }
  158. if ((options.row_block_size == 4) &&
  159. (options.e_block_size == 4) &&
  160. (options.f_block_size == 4)) {
  161. return std::make_unique<PartitionedMatrixView<4,4, 4>>(
  162. options, matrix);
  163. }
  164. if ((options.row_block_size == 4) &&
  165. (options.e_block_size == 4)) {
  166. return std::make_unique<PartitionedMatrixView<4,4, Eigen::Dynamic>>(
  167. options, matrix);
  168. }
  169. #endif
  170. VLOG(1) << "Template specializations not found for <"
  171. << options.row_block_size << "," << options.e_block_size << ","
  172. << options.f_block_size << ">";
  173. return std::make_unique<PartitionedMatrixView<Eigen::Dynamic,
  174. Eigen::Dynamic,
  175. Eigen::Dynamic>>(
  176. options, matrix);
  177. };
  178. } // namespace ceres::internal