11d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# Ceres Solver - A fast non-linear least squares minimizer 21d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# Copyright 2010, 2011, 2012, 2013 Google Inc. All rights reserved. 31d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# http://code.google.com/p/ceres-solver/ 41d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# 51d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# Redistribution and use in source and binary forms, with or without 61d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# modification, are permitted provided that the following conditions are met: 71d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# 81d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# * Redistributions of source code must retain the above copyright notice, 91d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# this list of conditions and the following disclaimer. 101d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# * Redistributions in binary form must reproduce the above copyright notice, 111d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# this list of conditions and the following disclaimer in the documentation 121d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# and/or other materials provided with the distribution. 131d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# * Neither the name of Google Inc. nor the names of its contributors may be 141d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# used to endorse or promote products derived from this software without 151d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# specific prior written permission. 161d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# 171d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 181d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 211d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 221d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 231d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 241d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 251d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 261d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 271d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling# POSSIBILITY OF SUCH DAMAGE. 280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 290ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Author: sameeragarwal@google.com (Sameer Agarwal) 300ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 310ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Script for explicitly generating template specialization of the 320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# SchurEliminator class. It is a rather large class 330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# and the number of explicit instantiations is also large. Explicitly 340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# generating these instantiations in separate .cc files breaks the 350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# compilation into separate compilation unit rather than one large cc 360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# file which takes 2+GB of RAM to compile. 370ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 380ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# This script creates two sets of files. 390ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 1. schur_eliminator_x_x_x.cc 410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# where, the x indicates the template parameters and 420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 2. schur_eliminator.cc 440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 450ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# that contains a factory function for instantiating these classes 460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# based on runtime parameters. 470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# 480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# The list of tuples, specializations indicates the set of 490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# specializations that is generated. 500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong# Set of template specializations to generate 520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongSPECIALIZATIONS = [(2, 2, 2), 530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (2, 2, 3), 540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (2, 2, 4), 551d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling (2, 2, "Eigen::Dynamic"), 560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (2, 3, 3), 570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (2, 3, 4), 580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (2, 3, 9), 591d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling (2, 3, "Eigen::Dynamic"), 600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (2, 4, 3), 610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (2, 4, 4), 621d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling (2, 4, "Eigen::Dynamic"), 630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (4, 4, 2), 640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (4, 4, 3), 650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (4, 4, 4), 661d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling (4, 4, "Eigen::Dynamic"), 671d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling ("Eigen::Dynamic", "Eigen::Dynamic", "Eigen::Dynamic")] 681d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha HaeberlingHEADER = """// Ceres Solver - A fast non-linear least squares minimizer 691d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// Copyright 2010, 2011, 2012, 2013 Google Inc. All rights reserved. 701d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// http://code.google.com/p/ceres-solver/ 711d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// 721d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// Redistribution and use in source and binary forms, with or without 731d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// modification, are permitted provided that the following conditions are met: 741d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// 751d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// * Redistributions of source code must retain the above copyright notice, 761d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// this list of conditions and the following disclaimer. 771d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// * Redistributions in binary form must reproduce the above copyright notice, 781d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// this list of conditions and the following disclaimer in the documentation 791d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// and/or other materials provided with the distribution. 801d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// * Neither the name of Google Inc. nor the names of its contributors may be 811d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// used to endorse or promote products derived from this software without 821d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// specific prior written permission. 831d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// 841d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 851d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 861d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 871d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 881d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 891d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 901d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 911d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 921d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 931d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 941d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// POSSIBILITY OF SUCH DAMAGE. 951d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// 960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Author: sameeragarwal@google.com (Sameer Agarwal) 970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Template specialization of SchurEliminator. 990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 1000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// ======================================== 1010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// THIS FILE IS AUTOGENERATED. DO NOT EDIT. 1020ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// THIS FILE IS AUTOGENERATED. DO NOT EDIT. 1030ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// THIS FILE IS AUTOGENERATED. DO NOT EDIT. 1040ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// THIS FILE IS AUTOGENERATED. DO NOT EDIT. 1050ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//========================================= 1060ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 1071d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// This file is generated using generate_eliminator_specialization.py. 1080ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Editing it manually is not recommended. 1091d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling""" 1101d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 1111d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha HaeberlingDYNAMIC_FILE = """ 1120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#include "ceres/schur_eliminator_impl.h" 1140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#include "ceres/internal/eigen.h" 1150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace ceres { 1170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace internal { 1180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongtemplate class SchurEliminator<%s, %s, %s>; 1200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} // namespace internal 1220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} // namespace ceres 1230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong""" 1240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1251d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha HaeberlingSPECIALIZATION_FILE = """ 1261d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION 1270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1281d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#include "ceres/schur_eliminator_impl.h" 1291d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#include "ceres/internal/eigen.h" 1301d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 1311d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberlingnamespace ceres { 1321d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberlingnamespace internal { 1331d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 1341d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberlingtemplate class SchurEliminator<%s, %s, %s>; 1351d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 1361d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling} // namespace internal 1371d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling} // namespace ceres 1381d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 1391d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#endif // CERES_RESTRICT_SCHUR_SPECIALIZATION 1401d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling""" 1411d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 1421d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha HaeberlingFACTORY_FILE_HEADER = """ 1430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#include "ceres/linear_solver.h" 1440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#include "ceres/schur_eliminator.h" 1450ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#include "ceres/internal/eigen.h" 1460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace ceres { 1480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace internal { 1490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongSchurEliminatorBase* 1510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongSchurEliminatorBase::Create(const LinearSolver::Options& options) { 1520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION 1530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong""" 1540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongFACTORY_CONDITIONAL = """ if ((options.row_block_size == %s) && 1560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (options.e_block_size == %s) && 1570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong (options.f_block_size == %s)) { 1580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong return new SchurEliminator<%s, %s, %s>(options); 1590ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong } 1600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong""" 1610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus KongFACTORY_FOOTER = """ 1630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#endif 1640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong VLOG(1) << "Template specializations not found for <" 1650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong << options.row_block_size << "," 1660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong << options.e_block_size << "," 1670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong << options.f_block_size << ">"; 1681d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling return new SchurEliminator<Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic>(options); 1690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} 1700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} // namespace internal 1720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} // namespace ceres 1730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong""" 1740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongdef SuffixForSize(size): 1771d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling if size == "Eigen::Dynamic": 1780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong return "d" 1790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong return str(size) 1800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongdef SpecializationFilename(prefix, row_block_size, e_block_size, f_block_size): 1830ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong return "_".join([prefix] + map(SuffixForSize, (row_block_size, 1840ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong e_block_size, 1850ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f_block_size))) 1860ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1870ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1880ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongdef Specialize(): 1890ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong """ 1900ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong Generate specialization code and the conditionals to instantiate it. 1910ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong """ 1920ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f = open("schur_eliminator.cc", "w") 1931d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling f.write(HEADER) 1940ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f.write(FACTORY_FILE_HEADER) 1950ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong for row_block_size, e_block_size, f_block_size in SPECIALIZATIONS: 1970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong output = SpecializationFilename("generated/schur_eliminator", 1980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong row_block_size, 1990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong e_block_size, 2000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f_block_size) + ".cc" 2010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong fptr = open(output, "w") 2021d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling fptr.write(HEADER) 2031d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 2041d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling template = SPECIALIZATION_FILE 2051d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling if (row_block_size == "Eigen::Dynamic" and 2061d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling e_block_size == "Eigen::Dynamic" and 2071d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling f_block_size == "Eigen::Dynamic"): 2081d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling template = DYNAMIC_FILE 2091d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 2101d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling fptr.write(template % (row_block_size, e_block_size, f_block_size)) 2110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong fptr.close() 2120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f.write(FACTORY_CONDITIONAL % (row_block_size, 2140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong e_block_size, 2150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f_block_size, 2160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong row_block_size, 2170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong e_block_size, 2180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f_block_size)) 2190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f.write(FACTORY_FOOTER) 2200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong f.close() 2210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongif __name__ == "__main__": 2240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong Specialize() 225