solver_cholmod.cpp
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
00003 // 
00004 // g2o is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as published
00006 // by the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // g2o is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #include "linear_solver_cholmod.h"
00018 
00019 #include "g2o/core/block_solver.h"
00020 #include "g2o/core/solver.h"
00021 #include "g2o/core/solver_factory.h"
00022 
00023 #define DIM_TO_SOLVER(p, l) BlockSolver< BlockSolverTraits<p, l> >
00024 
00025 #define ALLOC_CHOLMOD(s, p, l, blockorder) \
00026   if (1) { \
00027     std::cerr << "# Using CHOLMOD poseDim " << p << " landMarkDim " << l << " blockordering " << blockorder << std::endl; \
00028     LinearSolverCholmod < DIM_TO_SOLVER(p, l)::PoseMatrixType >* linearSolver = new LinearSolverCholmod<DIM_TO_SOLVER(p, l)::PoseMatrixType>(); \
00029     linearSolver->setBlockOrdering(blockorder); \
00030     s = new DIM_TO_SOLVER(p, l)(opt, linearSolver); \
00031   } else (void)0
00032 
00033 namespace g2o {
00034 
00035   static Solver* createSolver(SparseOptimizer* opt, const std::string& solverName)
00036   {
00037     g2o::Solver* s = 0;
00038 
00039     if (solverName == "var_cholmod") {
00040       ALLOC_CHOLMOD(s, -1, -1, false);
00041     }
00042     else if (solverName == "fix3_2_cholmod") {
00043       ALLOC_CHOLMOD(s, 3, 2, true);
00044     }
00045     else if (solverName == "fix6_3_cholmod") {
00046       ALLOC_CHOLMOD(s, 6, 3, true);
00047     }
00048     else if (solverName == "fix7_3_cholmod") {
00049       ALLOC_CHOLMOD(s, 7, 3, true);
00050     }
00051     else if (solverName == "fix3_2_cholmod_scalar") {
00052       ALLOC_CHOLMOD(s, 3, 2, false);
00053     }
00054     else if (solverName == "fix6_3_cholmod_scalar") {
00055       ALLOC_CHOLMOD(s, 6, 3, false);
00056     }
00057     else if (solverName == "fix7_3_cholmod_scalar") {
00058       ALLOC_CHOLMOD(s, 7, 3, false);
00059     }
00060 
00061     return s;
00062   }
00063 
00064   class CholmodSolverCreator : public AbstractSolverCreator
00065   {
00066     public:
00067       CholmodSolverCreator(const SolverProperty& p) : AbstractSolverCreator(p) {}
00068       virtual Solver* construct(SparseOptimizer* optimizer)
00069       {
00070         return createSolver(optimizer, property().name);
00071       }
00072   };
00073 
00074   void __attribute__ ((constructor)) init_solver_cholmod()
00075   {
00076     SolverFactory* factory = SolverFactory::instance();
00077     factory->registerSolver(new CholmodSolverCreator(SolverProperty("var_cholmod", "Cholesky solver using CHOLMOD (variable blocksize)", "CHOLMOD", false, -1, -1)));
00078     factory->registerSolver(new CholmodSolverCreator(SolverProperty("fix3_2_cholmod", "Cholesky solver using CHOLMOD (fixed blocksize)", "CHOLMOD", true, 3, 2)));
00079     factory->registerSolver(new CholmodSolverCreator(SolverProperty("fix6_3_cholmod", "Cholesky solver using CHOLMOD (fixed blocksize)", "CHOLMOD", true, 6, 3)));
00080     factory->registerSolver(new CholmodSolverCreator(SolverProperty("fix7_3_cholmod", "Cholesky solver using CHOLMOD (fixed blocksize)", "CHOLMOD", true, 7, 3)));
00081     factory->registerSolver(new CholmodSolverCreator(SolverProperty("fix3_2_cholmod_scalar", "Cholesky solver using CHOLMOD (fixed blocksize, scalar ordering)", "CHOLMOD", true, 3, 2)));
00082     factory->registerSolver(new CholmodSolverCreator(SolverProperty("fix6_3_cholmod_scalar", "Cholesky solver using CHOLMOD (fixed blocksize, scalar ordering)", "CHOLMOD", true, 6, 3)));
00083     factory->registerSolver(new CholmodSolverCreator(SolverProperty("fix7_3_cholmod_scalar", "Cholesky solver using CHOLMOD (fixed blocksize, scalar ordering)", "CHOLMOD", true, 7, 3)));
00084   }
00085 
00086 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:42