solver_dense.cpp
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, H. Strasdat, 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_dense.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_DENSE(s, p, l) \
00026   if (1) { \
00027       std::cerr << "# Using DENSE poseDim " << p << " landMarkDim " << l << std::endl; \
00028       DIM_TO_SOLVER(p, l)::LinearSolverType* linearSolver = new LinearSolverDense<DIM_TO_SOLVER(p, l)::PoseMatrixType>(); \
00029       s = new DIM_TO_SOLVER(p, l)(opt, linearSolver); \
00030   } else (void)0
00031 
00032 namespace g2o {
00033 
00034   static Solver* createSolver(SparseOptimizer* opt, const std::string& solverName)
00035   {
00036     g2o::Solver* s = 0;
00037 
00038     if (solverName == "dense") {
00039       ALLOC_DENSE(s, -1, -1);
00040     }
00041     else if (solverName == "dense3_2") {
00042       ALLOC_DENSE(s, 3, 2);
00043     }
00044     else if (solverName == "dense6_3") {
00045       ALLOC_DENSE(s, 6, 3);
00046     }
00047     else if (solverName == "dense7_3") {
00048       ALLOC_DENSE(s, 7, 3);
00049     }
00050 
00051     return s;
00052   }
00053 
00054   class DenseSolverCreator : public AbstractSolverCreator
00055   {
00056     public:
00057       DenseSolverCreator(const SolverProperty& p) : AbstractSolverCreator(p) {}
00058       virtual Solver* construct(SparseOptimizer* optimizer)
00059       {
00060         return createSolver(optimizer, property().name);
00061       }
00062   };
00063 
00064   void __attribute__ ((constructor)) init_solver_csparse()
00065   {
00066     SolverFactory* factory = SolverFactory::instance();
00067     factory->registerSolver(new DenseSolverCreator(SolverProperty("dense", "Dense solver (variable blocksize)", "Dense", false, -1, -1)));
00068     factory->registerSolver(new DenseSolverCreator(SolverProperty("dense3_2", "Dense solver (fixed blocksize)", "Dense", true, 3, 2)));
00069     factory->registerSolver(new DenseSolverCreator(SolverProperty("dense6_3", "Dense solver (fixed blocksize)", "Dense", true, 6, 3)));
00070     factory->registerSolver(new DenseSolverCreator(SolverProperty("dense7_3", "Dense solver (fixed blocksize)", "Dense", true, 7, 3)));
00071   }
00072 
00073   }


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