partitioned_matrix_view_2_2_3.cc revision 1d2624a10e2c559f8ba9ef89eaa30832c0a83a96
10ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Ceres Solver - A fast non-linear least squares minimizer 21d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// Copyright 2010, 2011, 2012 Google Inc. All rights reserved. 30ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// http://code.google.com/p/ceres-solver/ 40ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 50ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Redistribution and use in source and binary forms, with or without 60ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// modification, are permitted provided that the following conditions are met: 70ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 80ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// * Redistributions of source code must retain the above copyright notice, 90ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// this list of conditions and the following disclaimer. 100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// * Redistributions in binary form must reproduce the above copyright notice, 110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// this list of conditions and the following disclaimer in the documentation 120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// and/or other materials provided with the distribution. 130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// * Neither the name of Google Inc. nor the names of its contributors may be 140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// used to endorse or promote products derived from this software without 150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// specific prior written permission. 160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// POSSIBILITY OF SUCH DAMAGE. 280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 291d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// Author: sameeragarwal@google.com (Sameer Agarwal) 301d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// 311d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// Compute a parameter block ordering for use with the Schur 321d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// complement based algorithms. 330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 341d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#ifndef CERES_INTERNAL_SCHUR_ORDERING_H_ 351d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#define CERES_INTERNAL_SCHUR_ORDERING_H_ 360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 371d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#include <vector> 381d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#include "ceres/graph.h" 391d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#include "ceres/types.h" 400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace ceres { 420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace internal { 430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 441d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberlingclass Program; 451d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberlingclass ParameterBlock; 461d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 471d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// Uses an approximate independent set ordering to order the parameter 481d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// blocks of a problem so that it is suitable for use with Schur 491d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// complement based solvers. The output variable ordering contains an 501d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// ordering of the parameter blocks and the return value is size of 511d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// the independent set or the number of e_blocks (see 521d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// schur_complement_solver.h for an explanation). Constant parameters 531d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// are added to the end. 540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 551d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// The ordering vector has the structure 560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 571d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// ordering = [independent set, 581d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// complement of the independent set, 591d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// fixed blocks] 601d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberlingint ComputeSchurOrdering(const Program& program, 611d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling vector<ParameterBlock* >* ordering); 621d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling 630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 641d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// Builds a graph on the parameter blocks of a Problem, whose 651d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// structure reflects the sparsity structure of the Hessian. Each 661d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// vertex corresponds to a parameter block in the Problem except for 671d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// parameter blocks that are marked constant. An edge connects two 681d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling// parameter blocks, if they co-occur in a residual block. 691d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha HaeberlingGraph<ParameterBlock*>* CreateHessianGraph(const Program& program); 700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} // namespace internal 720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} // namespace ceres 730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 741d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling#endif // CERES_INTERNAL_SCHUR_ORDERING_H_ 75