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 
42 #include "ceres/linear_solver.h"
43 #include "ceres/partitioned_matrix_view.h"
44 #include "ceres/internal/eigen.h"
45 
46 namespace ceres {
47 namespace internal {
48 
49 PartitionedMatrixViewBase*
Create(const LinearSolver::Options & options,const BlockSparseMatrix & matrix)50 PartitionedMatrixViewBase::Create(const LinearSolver::Options& options,
51                                   const BlockSparseMatrix& matrix) {
52 #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
53  if ((options.row_block_size == 2) &&
54      (options.e_block_size == 2) &&
55      (options.f_block_size == 2)) {
56    return new PartitionedMatrixView<2, 2, 2>(matrix, options.elimination_groups[0]);
57  }
58  if ((options.row_block_size == 2) &&
59      (options.e_block_size == 2) &&
60      (options.f_block_size == 3)) {
61    return new PartitionedMatrixView<2, 2, 3>(matrix, options.elimination_groups[0]);
62  }
63  if ((options.row_block_size == 2) &&
64      (options.e_block_size == 2) &&
65      (options.f_block_size == 4)) {
66    return new PartitionedMatrixView<2, 2, 4>(matrix, options.elimination_groups[0]);
67  }
68  if ((options.row_block_size == 2) &&
69      (options.e_block_size == 2)) {
70    return new PartitionedMatrixView<2, 2, Eigen::Dynamic>(matrix, options.elimination_groups[0]);
71  }
72  if ((options.row_block_size == 2) &&
73      (options.e_block_size == 3) &&
74      (options.f_block_size == 3)) {
75    return new PartitionedMatrixView<2, 3, 3>(matrix, options.elimination_groups[0]);
76  }
77  if ((options.row_block_size == 2) &&
78      (options.e_block_size == 3) &&
79      (options.f_block_size == 4)) {
80    return new PartitionedMatrixView<2, 3, 4>(matrix, options.elimination_groups[0]);
81  }
82  if ((options.row_block_size == 2) &&
83      (options.e_block_size == 3) &&
84      (options.f_block_size == 6)) {
85    return new PartitionedMatrixView<2, 3, 6>(matrix, options.elimination_groups[0]);
86  }
87  if ((options.row_block_size == 2) &&
88      (options.e_block_size == 3) &&
89      (options.f_block_size == 9)) {
90    return new PartitionedMatrixView<2, 3, 9>(matrix, options.elimination_groups[0]);
91  }
92  if ((options.row_block_size == 2) &&
93      (options.e_block_size == 3)) {
94    return new PartitionedMatrixView<2, 3, Eigen::Dynamic>(matrix, options.elimination_groups[0]);
95  }
96  if ((options.row_block_size == 2) &&
97      (options.e_block_size == 4) &&
98      (options.f_block_size == 3)) {
99    return new PartitionedMatrixView<2, 4, 3>(matrix, options.elimination_groups[0]);
100  }
101  if ((options.row_block_size == 2) &&
102      (options.e_block_size == 4) &&
103      (options.f_block_size == 4)) {
104    return new PartitionedMatrixView<2, 4, 4>(matrix, options.elimination_groups[0]);
105  }
106  if ((options.row_block_size == 2) &&
107      (options.e_block_size == 4) &&
108      (options.f_block_size == 6)) {
109    return new PartitionedMatrixView<2, 4, 6>(matrix, options.elimination_groups[0]);
110  }
111  if ((options.row_block_size == 2) &&
112      (options.e_block_size == 4) &&
113      (options.f_block_size == 8)) {
114    return new PartitionedMatrixView<2, 4, 8>(matrix, options.elimination_groups[0]);
115  }
116  if ((options.row_block_size == 2) &&
117      (options.e_block_size == 4) &&
118      (options.f_block_size == 9)) {
119    return new PartitionedMatrixView<2, 4, 9>(matrix, options.elimination_groups[0]);
120  }
121  if ((options.row_block_size == 2) &&
122      (options.e_block_size == 4)) {
123    return new PartitionedMatrixView<2, 4, Eigen::Dynamic>(matrix, options.elimination_groups[0]);
124  }
125  if (options.row_block_size == 2){
126    return new PartitionedMatrixView<2, Eigen::Dynamic, Eigen::Dynamic>(matrix, options.elimination_groups[0]);
127  }
128  if ((options.row_block_size == 3) &&
129      (options.e_block_size == 3) &&
130      (options.f_block_size == 3)) {
131    return new PartitionedMatrixView<3, 3, 3>(matrix, options.elimination_groups[0]);
132  }
133  if ((options.row_block_size == 4) &&
134      (options.e_block_size == 4) &&
135      (options.f_block_size == 2)) {
136    return new PartitionedMatrixView<4, 4, 2>(matrix, options.elimination_groups[0]);
137  }
138  if ((options.row_block_size == 4) &&
139      (options.e_block_size == 4) &&
140      (options.f_block_size == 3)) {
141    return new PartitionedMatrixView<4, 4, 3>(matrix, options.elimination_groups[0]);
142  }
143  if ((options.row_block_size == 4) &&
144      (options.e_block_size == 4) &&
145      (options.f_block_size == 4)) {
146    return new PartitionedMatrixView<4, 4, 4>(matrix, options.elimination_groups[0]);
147  }
148  if ((options.row_block_size == 4) &&
149      (options.e_block_size == 4)) {
150    return new PartitionedMatrixView<4, 4, Eigen::Dynamic>(matrix, options.elimination_groups[0]);
151  }
152 
153 #endif
154   VLOG(1) << "Template specializations not found for <"
155           << options.row_block_size << ","
156           << options.e_block_size << ","
157           << options.f_block_size << ">";
158   return new PartitionedMatrixView<Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic>(
159                matrix, options.elimination_groups[0]);
160 };
161 
162 }  // namespace internal
163 }  // namespace ceres
164