blob: 50515956e89f329c1ddc04de45110f66b8dba151 [file] [log] [blame]
Austin Schuh70cc9552019-01-21 19:46:48 -08001# 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# 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.
37#
38# This script creates two sets of files.
39#
40# 1. schur_eliminator_x_x_x.cc
41# where, the x indicates the template parameters and
42#
43# 2. schur_eliminator.cc
44#
45# that contains a factory function for instantiating these classes
46# based on runtime parameters.
47#
48# The list of tuples, specializations indicates the set of
49# specializations that is generated.
50
51# Set of template specializations to generate
52
53HEADER = """// Ceres Solver - A fast non-linear least squares minimizer
54// Copyright 2017 Google Inc. All rights reserved.
55// http://ceres-solver.org/
56//
57// Redistribution and use in source and binary forms, with or without
58// modification, are permitted provided that the following conditions are met:
59//
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.
68//
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.
80//
81// Author: sameeragarwal@google.com (Sameer Agarwal)
82//
83// Template specialization of SchurEliminator.
84//
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//=========================================
91//
92// This file is generated using generate_template_specializations.py.
93"""
94
95DYNAMIC_FILE = """
Austin Schuh70cc9552019-01-21 19:46:48 -080096#include "ceres/schur_eliminator_impl.h"
Austin Schuh70cc9552019-01-21 19:46:48 -080097
98namespace ceres {
99namespace internal {
100
101template class SchurEliminator<%s, %s, %s>;
102
103} // namespace internal
104} // namespace ceres
105"""
106
107SPECIALIZATION_FILE = """
108// This include must come before any #ifndef check on Ceres compile options.
109#include "ceres/internal/port.h"
110
111#ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
112
113#include "ceres/schur_eliminator_impl.h"
Austin Schuh70cc9552019-01-21 19:46:48 -0800114
115namespace ceres {
116namespace internal {
117
118template class SchurEliminator<%s, %s, %s>;
119
120} // namespace internal
121} // namespace ceres
122
123#endif // CERES_RESTRICT_SCHUR_SPECIALIZATION
124"""
125
126FACTORY_FILE_HEADER = """
127#include "ceres/linear_solver.h"
128#include "ceres/schur_eliminator.h"
Austin Schuh70cc9552019-01-21 19:46:48 -0800129
130namespace ceres {
131namespace internal {
132
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800133SchurEliminatorBase* SchurEliminatorBase::Create(
134 const LinearSolver::Options& options) {
Austin Schuh70cc9552019-01-21 19:46:48 -0800135#ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
136"""
137
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800138FACTORY = """ return new SchurEliminator<%s, %s, %s>(options);"""
Austin Schuh70cc9552019-01-21 19:46:48 -0800139
140FACTORY_FOOTER = """
141#endif
142 VLOG(1) << "Template specializations not found for <"
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800143 << options.row_block_size << "," << options.e_block_size << ","
Austin Schuh70cc9552019-01-21 19:46:48 -0800144 << options.f_block_size << ">";
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800145 return new SchurEliminator<Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic>(
146 options);
Austin Schuh70cc9552019-01-21 19:46:48 -0800147}
148
149} // namespace internal
150} // namespace ceres
151"""