So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
EigenMatrixTraits.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2013 Gilles Daviet <gdaviet@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10 
11 
12 #ifndef BOGUS_EIGEN_MATRIX_TRAITS_HPP
13 #define BOGUS_EIGEN_MATRIX_TRAITS_HPP
14 
15 #include <Eigen/Core>
16 
17 #include "EigenLinearSolvers.hpp"
18 #include "EigenSparseLinearSolvers.hpp"
19 
20 #include "../Block/ScalarBindings.hpp"
21 
22 namespace bogus
23 {
24 
25 template < typename _MatrixType >
27 {
28  typedef _MatrixType MatrixType ;
29  typedef typename MatrixType::Scalar Scalar ;
30 
33 
34  static const MatrixType& asConstMatrix ( const MatrixType& src )
35  { return src; }
36 } ;
37 
38 template < typename _Scalar, int _Options, typename _Index >
39 struct MatrixTraits< Eigen::SparseMatrix< _Scalar, _Options, _Index > >
40 {
41  typedef _Scalar Scalar ;
42  typedef Eigen::SparseMatrix< Scalar, _Options, _Index > MatrixType ;
43 
46 
47  static const MatrixType& asConstMatrix ( const MatrixType& src )
48  { return src; }
49 } ;
50 
51 #define BOGUS_PROCESS_SCALAR( Scalar ) \
52 template < > struct MatrixTraits< Scalar > : public MatrixTraits< Eigen::Matrix< Scalar, 1, 1> > {\
53  static Eigen::Matrix< Scalar, 1, 1> asConstMatrix ( const Scalar src ) {\
54  Eigen::Matrix< Scalar, 1, 1> mat ;\
55  mat(0,0) = src ;\
56  return mat ; \
57  }\
58 };
59 BOGUS_BLOCK_SCALAR_TYPES
60 #undef BOGUS_PROCESS_SCALAR
61 
62 } //bogus
63 
64 #endif
Base class for LDLT factorizations.
Definition: LinearSolverBase.hpp:72
Definition: EigenMatrixTraits.hpp:26
Base class for LU factorizations.
Definition: LinearSolverBase.hpp:66