blob: 7894523cdea16d36633bc0a106b28a72c2d6e9a5 [file] [log] [blame]
Austin Schuh70cc9552019-01-21 19:46:48 -08001# Ceres Solver - A fast non-linear least squares minimizer
2# Copyright 2015 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# 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.
35#
36# This script creates two sets of files.
37#
38# 1. partitioned_matrix_view_x_x_x.cc
39# where the x indicates the template parameters and
40#
41# 2. partitioned_matrix_view.cc
42#
43# that contains a factory function for instantiating these classes
44# based on runtime parameters.
45#
46# The list of tuples, specializations indicates the set of
47# specializations that is generated.
48
49HEADER = """// Ceres Solver - A fast non-linear least squares minimizer
50// Copyright 2017 Google Inc. All rights reserved.
51// http://ceres-solver.org/
52//
53// Redistribution and use in source and binary forms, with or without
54// modification, are permitted provided that the following conditions are met:
55//
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.
64//
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.
76//
77// Author: sameeragarwal@google.com (Sameer Agarwal)
78//
79// Template specialization of PartitionedMatrixView.
80//
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//=========================================
87//
88// This file is generated using generate_template_specializations.py.
89"""
90
91DYNAMIC_FILE = """
92
93#include "ceres/partitioned_matrix_view_impl.h"
94#include "ceres/internal/eigen.h"
95
96namespace ceres {
97namespace internal {
98
99template class PartitionedMatrixView<%s, %s, %s>;
100
101} // namespace internal
102} // namespace ceres
103"""
104
105SPECIALIZATION_FILE = """
106// This include must come before any #ifndef check on Ceres compile options.
107#include "ceres/internal/port.h"
108
109#ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
110
111#include "ceres/partitioned_matrix_view_impl.h"
112#include "ceres/internal/eigen.h"
113
114namespace ceres {
115namespace internal {
116
117template class PartitionedMatrixView<%s, %s, %s>;
118
119} // namespace internal
120} // namespace ceres
121
122#endif // CERES_RESTRICT_SCHUR_SPECIALIZATION
123"""
124
125FACTORY_FILE_HEADER = """
126#include "ceres/linear_solver.h"
127#include "ceres/partitioned_matrix_view.h"
128#include "ceres/internal/eigen.h"
129
130namespace ceres {
131namespace internal {
132
133PartitionedMatrixViewBase*
134PartitionedMatrixViewBase::Create(const LinearSolver::Options& options,
135 const BlockSparseMatrix& matrix) {
136#ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
137"""
138FACTORY = """ return new PartitionedMatrixView<%s, %s, %s>(matrix, options.elimination_groups[0]);"""
139
140FACTORY_FOOTER = """
141#endif
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]);
148};
149
150} // namespace internal
151} // namespace ceres
152"""