Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
 
Loading...
Searching...
No Matches
SolverBase.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_SOLVERBASE_H
11#define EIGEN_SOLVERBASE_H
12
13namespace Eigen {
14
15namespace internal {
16
17template<typename Derived>
18struct solve_assertion {
19 template<bool Transpose_, typename Rhs>
20 static void run(const Derived& solver, const Rhs& b) { solver.template _check_solve_assertion<Transpose_>(b); }
21};
22
23template<typename Derived>
24struct solve_assertion<Transpose<Derived> >
25{
26 typedef Transpose<Derived> type;
27
28 template<bool Transpose_, typename Rhs>
29 static void run(const type& transpose, const Rhs& b)
30 {
31 internal::solve_assertion<typename internal::remove_all<Derived>::type>::template run<true>(transpose.nestedExpression(), b);
32 }
33};
34
35template<typename Scalar, typename Derived>
36struct solve_assertion<CwiseUnaryOp<Eigen::internal::scalar_conjugate_op<Scalar>, const Transpose<Derived> > >
37{
38 typedef CwiseUnaryOp<Eigen::internal::scalar_conjugate_op<Scalar>, const Transpose<Derived> > type;
39
40 template<bool Transpose_, typename Rhs>
41 static void run(const type& adjoint, const Rhs& b)
42 {
43 internal::solve_assertion<typename internal::remove_all<Transpose<Derived> >::type>::template run<true>(adjoint.nestedExpression(), b);
44 }
45};
46} // end namespace internal
47
67template<typename Derived>
68class SolverBase : public EigenBase<Derived>
69{
70 public:
71
73 typedef typename internal::traits<Derived>::Scalar Scalar;
74 typedef Scalar CoeffReturnType;
75
76 template<typename Derived_>
77 friend struct internal::solve_assertion;
78
79 enum {
80 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
81 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
82 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
83 internal::traits<Derived>::ColsAtCompileTime>::ret),
84 MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
85 MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
86 MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,
87 internal::traits<Derived>::MaxColsAtCompileTime>::ret),
88 IsVectorAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime == 1
89 || internal::traits<Derived>::MaxColsAtCompileTime == 1,
90 NumDimensions = int(MaxSizeAtCompileTime) == 1 ? 0 : bool(IsVectorAtCompileTime) ? 1 : 2
91 };
92
95 {}
96
98 {}
99
100 using Base::derived;
101
104 template<typename Rhs>
105 inline const Solve<Derived, Rhs>
106 solve(const MatrixBase<Rhs>& b) const
107 {
108 internal::solve_assertion<typename internal::remove_all<Derived>::type>::template run<false>(derived(), b);
109 return Solve<Derived, Rhs>(derived(), b.derived());
110 }
111
113 typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType;
122 {
124 }
125
127 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
129 ConstTransposeReturnType
130 >::type AdjointReturnType;
140 inline AdjointReturnType adjoint() const
141 {
142 return AdjointReturnType(derived().transpose());
143 }
144
145 protected:
146
147 template<bool Transpose_, typename Rhs>
148 void _check_solve_assertion(const Rhs& b) const {
149 EIGEN_ONLY_USED_FOR_DEBUG(b);
150 eigen_assert(derived().m_isInitialized && "Solver is not initialized.");
151 eigen_assert((Transpose_?derived().cols():derived().rows())==b.rows() && "SolverBase::solve(): invalid number of rows of the right hand side matrix b");
152 }
153};
154
155namespace internal {
156
157template<typename Derived>
158struct generic_xpr_base<Derived, MatrixXpr, SolverStorage>
159{
160 typedef SolverBase<Derived> type;
161
162};
163
164} // end namespace internal
165
166} // end namespace Eigen
167
168#endif // EIGEN_SOLVERBASE_H
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:56
Derived & derived()
Definition: EigenBase.h:46
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:65
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
Pseudo expression representing a solving operation.
Definition: Solve.h:63
A base class for matrix decomposition and solvers.
Definition: SolverBase.h:69
AdjointReturnType adjoint() const
Definition: SolverBase.h:140
SolverBase()
Definition: SolverBase.h:94
ConstTransposeReturnType transpose() const
Definition: SolverBase.h:121
Derived & derived()
Definition: EigenBase.h:46
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SolverBase.h:106
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Definition: EigenBase.h:30
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:63
Derived & derived()
Definition: EigenBase.h:46
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:60