Solve.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // Eigen is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // Alternatively, you can redistribute it and/or
12 // modify it under the terms of the GNU General Public License as
13 // published by the Free Software Foundation; either version 2 of
14 // the License, or (at your option) any later version.
15 //
16 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
17 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License and a copy of the GNU General Public License along with
23 // Eigen. If not, see <http://www.gnu.org/licenses/>.
24 
25 #ifndef EIGEN_MISC_SOLVE_H
26 #define EIGEN_MISC_SOLVE_H
27 
28 namespace Eigen {
29 
30 namespace internal {
31 
35 template<typename DecompositionType, typename Rhs>
36 struct traits<solve_retval_base<DecompositionType, Rhs> >
37 {
38  typedef typename DecompositionType::MatrixType MatrixType;
39  typedef Matrix<typename Rhs::Scalar,
40  MatrixType::ColsAtCompileTime,
41  Rhs::ColsAtCompileTime,
42  Rhs::PlainObject::Options,
43  MatrixType::MaxColsAtCompileTime,
44  Rhs::MaxColsAtCompileTime> ReturnType;
45 };
46 
47 template<typename _DecompositionType, typename Rhs> struct solve_retval_base
48  : public ReturnByValue<solve_retval_base<_DecompositionType, Rhs> >
49 {
50  typedef typename remove_all<typename Rhs::Nested>::type RhsNestedCleaned;
51  typedef _DecompositionType DecompositionType;
52  typedef ReturnByValue<solve_retval_base> Base;
53  typedef typename Base::Index Index;
54 
55  solve_retval_base(const DecompositionType& dec, const Rhs& rhs)
56  : m_dec(dec), m_rhs(rhs)
57  {}
58 
59  inline Index rows() const { return m_dec.cols(); }
60  inline Index cols() const { return m_rhs.cols(); }
61  inline const DecompositionType& dec() const { return m_dec; }
62  inline const RhsNestedCleaned& rhs() const { return m_rhs; }
63 
64  template<typename Dest> inline void evalTo(Dest& dst) const
65  {
66  static_cast<const solve_retval<DecompositionType,Rhs>*>(this)->evalTo(dst);
67  }
68 
69  protected:
70  const DecompositionType& m_dec;
71  typename Rhs::Nested m_rhs;
72 };
73 
74 } // end namespace internal
75 
76 #define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType,Rhs) \
77  typedef typename DecompositionType::MatrixType MatrixType; \
78  typedef typename MatrixType::Scalar Scalar; \
79  typedef typename MatrixType::RealScalar RealScalar; \
80  typedef typename MatrixType::Index Index; \
81  typedef Eigen::internal::solve_retval_base<DecompositionType,Rhs> Base; \
82  using Base::dec; \
83  using Base::rhs; \
84  using Base::rows; \
85  using Base::cols; \
86  solve_retval(const DecompositionType& dec, const Rhs& rhs) \
87  : Base(dec, rhs) {}
88 
89 } // end namespace Eigen
90 
91 #endif // EIGEN_MISC_SOLVE_H