1 # Ceres Solver - A fast non-linear least squares minimizer
2 # Copyright 2017 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 # SchurEliminator class. It is a rather large class
33 # and the number of explicit instantiations is also large. Explicitly
34 # generating these instantiations in separate .cc files breaks the
35 # compilation into separate compilation unit rather than one large cc
36 # file which takes 2+GB of RAM to compile.
38 # This script creates two sets of files.
40 # 1. schur_eliminator_x_x_x.cc
41 # where, the x indicates the template parameters and
43 # 2. schur_eliminator.cc
45 # that contains a factory function for instantiating these classes
46 # based on runtime parameters.
48 # The list of tuples, specializations indicates the set of
49 # specializations that is generated.
51 # Set of template specializations to generate
53 HEADER = """// Ceres Solver - A fast non-linear least squares minimizer
54 // Copyright 2017 Google Inc. All rights reserved.
55 // http://ceres-solver.org/
57 // Redistribution and use in source and binary forms, with or without
58 // modification, are permitted provided that the following conditions are met:
60 // * Redistributions of source code must retain the above copyright notice,
61 // this list of conditions and the following disclaimer.
62 // * Redistributions in binary form must reproduce the above copyright notice,
63 // this list of conditions and the following disclaimer in the documentation
64 // and/or other materials provided with the distribution.
65 // * Neither the name of Google Inc. nor the names of its contributors may be
66 // used to endorse or promote products derived from this software without
67 // specific prior written permission.
69 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
70 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
71 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
72 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
73 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
74 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
75 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
76 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
77 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
78 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
79 // POSSIBILITY OF SUCH DAMAGE.
81 // Author: sameeragarwal@google.com (Sameer Agarwal)
83 // Template specialization of SchurEliminator.
85 // ========================================
86 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
87 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
88 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
89 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
90 //=========================================
92 // This file is generated using generate_template_specializations.py.
97 #include "ceres/schur_eliminator_impl.h"
98 #include "ceres/internal/eigen.h"
103 template class SchurEliminator<%s, %s, %s>;
105 } // namespace internal
109 SPECIALIZATION_FILE = """
110 // This include must come before any #ifndef check on Ceres compile options.
111 #include "ceres/internal/port.h"
113 #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
115 #include "ceres/schur_eliminator_impl.h"
116 #include "ceres/internal/eigen.h"
121 template class SchurEliminator<%s, %s, %s>;
123 } // namespace internal
126 #endif // CERES_RESTRICT_SCHUR_SPECIALIZATION
129 FACTORY_FILE_HEADER = """
130 #include "ceres/linear_solver.h"
131 #include "ceres/schur_eliminator.h"
132 #include "ceres/internal/eigen.h"
138 SchurEliminatorBase::Create(const LinearSolver::Options& options) {
139 #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
142 FACTORY = """ return new SchurEliminator<%s, %s, %s>(options);"""
146 VLOG(1) << "Template specializations not found for <"
147 << options.row_block_size << ","
148 << options.e_block_size << ","
149 << options.f_block_size << ">";
150 return new SchurEliminator<Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic>(options);
153 } // namespace internal