1 # Ceres Solver - A fast non-linear least squares minimizer
2 # Copyright 2015 Google Inc. All rights reserved.
3 # http://ceres-solver.org/
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
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.
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.
29 # Author: sameeragarwal@google.com (Sameer Agarwal)
31 # Script for explicitly generating template specialization of the
32 # PartitionedMatrixView class. Explicitly generating these
33 # instantiations in separate .cc files breaks the compilation into
34 # separate compilation unit rather than one large cc file.
36 # This script creates two sets of files.
38 # 1. partitioned_matrix_view_x_x_x.cc
39 # where the x indicates the template parameters and
41 # 2. partitioned_matrix_view.cc
43 # that contains a factory function for instantiating these classes
44 # based on runtime parameters.
46 # The list of tuples, specializations indicates the set of
47 # specializations that is generated.
49 HEADER = """// Ceres Solver - A fast non-linear least squares minimizer
50 // Copyright 2017 Google Inc. All rights reserved.
51 // http://ceres-solver.org/
53 // Redistribution and use in source and binary forms, with or without
54 // modification, are permitted provided that the following conditions are met:
56 // * Redistributions of source code must retain the above copyright notice,
57 // this list of conditions and the following disclaimer.
58 // * Redistributions in binary form must reproduce the above copyright notice,
59 // this list of conditions and the following disclaimer in the documentation
60 // and/or other materials provided with the distribution.
61 // * Neither the name of Google Inc. nor the names of its contributors may be
62 // used to endorse or promote products derived from this software without
63 // specific prior written permission.
65 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
66 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
68 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
69 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
70 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
71 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
72 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
73 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
74 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
75 // POSSIBILITY OF SUCH DAMAGE.
77 // Author: sameeragarwal@google.com (Sameer Agarwal)
79 // Template specialization of PartitionedMatrixView.
81 // ========================================
82 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
83 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
84 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
85 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
86 //=========================================
88 // This file is generated using generate_template_specializations.py.
93 #include "ceres/partitioned_matrix_view_impl.h"
94 #include "ceres/internal/eigen.h"
99 template class PartitionedMatrixView<%s, %s, %s>;
101 } // namespace internal
105 SPECIALIZATION_FILE = """
106 // This include must come before any #ifndef check on Ceres compile options.
107 #include "ceres/internal/port.h"
109 #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
111 #include "ceres/partitioned_matrix_view_impl.h"
112 #include "ceres/internal/eigen.h"
117 template class PartitionedMatrixView<%s, %s, %s>;
119 } // namespace internal
122 #endif // CERES_RESTRICT_SCHUR_SPECIALIZATION
125 FACTORY_FILE_HEADER = """
126 #include "ceres/linear_solver.h"
127 #include "ceres/partitioned_matrix_view.h"
128 #include "ceres/internal/eigen.h"
133 PartitionedMatrixViewBase*
134 PartitionedMatrixViewBase::Create(const LinearSolver::Options& options,
135 const BlockSparseMatrix& matrix) {
136 #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
138 FACTORY = """ return new PartitionedMatrixView<%s, %s, %s>(matrix, options.elimination_groups[0]);"""
142 VLOG(1) << "Template specializations not found for <"
143 << options.row_block_size << ","
144 << options.e_block_size << ","
145 << options.f_block_size << ">";
146 return new PartitionedMatrixView<Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic>(
147 matrix, options.elimination_groups[0]);
150 } // namespace internal