Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef EIGEN_SPARSE_SOLVE_H
00011 #define EIGEN_SPARSE_SOLVE_H
00012
00013 namespace Eigen {
00014
00015 namespace internal {
00016
00017 template<typename _DecompositionType, typename Rhs> struct sparse_solve_retval_base;
00018 template<typename _DecompositionType, typename Rhs> struct sparse_solve_retval;
00019
00020 template<typename DecompositionType, typename Rhs>
00021 struct traits<sparse_solve_retval_base<DecompositionType, Rhs> >
00022 {
00023 typedef typename DecompositionType::MatrixType MatrixType;
00024 typedef SparseMatrix<typename Rhs::Scalar, Rhs::Options, typename Rhs::Index> ReturnType;
00025 };
00026
00027 template<typename _DecompositionType, typename Rhs> struct sparse_solve_retval_base
00028 : public ReturnByValue<sparse_solve_retval_base<_DecompositionType, Rhs> >
00029 {
00030 typedef typename remove_all<typename Rhs::Nested>::type RhsNestedCleaned;
00031 typedef _DecompositionType DecompositionType;
00032 typedef ReturnByValue<sparse_solve_retval_base> Base;
00033 typedef typename Base::Index Index;
00034
00035 sparse_solve_retval_base(const DecompositionType& dec, const Rhs& rhs)
00036 : m_dec(dec), m_rhs(rhs)
00037 {}
00038
00039 inline Index rows() const { return m_dec.cols(); }
00040 inline Index cols() const { return m_rhs.cols(); }
00041 inline const DecompositionType& dec() const { return m_dec; }
00042 inline const RhsNestedCleaned& rhs() const { return m_rhs; }
00043
00044 template<typename Dest> inline void evalTo(Dest& dst) const
00045 {
00046 static_cast<const sparse_solve_retval<DecompositionType,Rhs>*>(this)->evalTo(dst);
00047 }
00048
00049 protected:
00050 const DecompositionType& m_dec;
00051 typename Rhs::Nested m_rhs;
00052 };
00053
00054 #define EIGEN_MAKE_SPARSE_SOLVE_HELPERS(DecompositionType,Rhs) \
00055 typedef typename DecompositionType::MatrixType MatrixType; \
00056 typedef typename MatrixType::Scalar Scalar; \
00057 typedef typename MatrixType::RealScalar RealScalar; \
00058 typedef typename MatrixType::Index Index; \
00059 typedef Eigen::internal::sparse_solve_retval_base<DecompositionType,Rhs> Base; \
00060 using Base::dec; \
00061 using Base::rhs; \
00062 using Base::rows; \
00063 using Base::cols; \
00064 sparse_solve_retval(const DecompositionType& dec, const Rhs& rhs) \
00065 : Base(dec, rhs) {}
00066
00067
00068
00069 template<typename DecompositionType, typename Rhs, typename Guess> struct solve_retval_with_guess;
00070
00071 template<typename DecompositionType, typename Rhs, typename Guess>
00072 struct traits<solve_retval_with_guess<DecompositionType, Rhs, Guess> >
00073 {
00074 typedef typename DecompositionType::MatrixType MatrixType;
00075 typedef Matrix<typename Rhs::Scalar,
00076 MatrixType::ColsAtCompileTime,
00077 Rhs::ColsAtCompileTime,
00078 Rhs::PlainObject::Options,
00079 MatrixType::MaxColsAtCompileTime,
00080 Rhs::MaxColsAtCompileTime> ReturnType;
00081 };
00082
00083 template<typename DecompositionType, typename Rhs, typename Guess> struct solve_retval_with_guess
00084 : public ReturnByValue<solve_retval_with_guess<DecompositionType, Rhs, Guess> >
00085 {
00086 typedef typename DecompositionType::Index Index;
00087
00088 solve_retval_with_guess(const DecompositionType& dec, const Rhs& rhs, const Guess& guess)
00089 : m_dec(dec), m_rhs(rhs), m_guess(guess)
00090 {}
00091
00092 inline Index rows() const { return m_dec.cols(); }
00093 inline Index cols() const { return m_rhs.cols(); }
00094
00095 template<typename Dest> inline void evalTo(Dest& dst) const
00096 {
00097 dst = m_guess;
00098 m_dec._solveWithGuess(m_rhs,dst);
00099 }
00100
00101 protected:
00102 const DecompositionType& m_dec;
00103 const typename Rhs::Nested m_rhs;
00104 const typename Guess::Nested m_guess;
00105 };
00106
00107 }
00108
00109 }
00110
00111 #endif // EIGEN_SPARSE_SOLVE_H