// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
/** \class SolverBase * \brief A base class for matrix decomposition and solvers * * \tparam Derived the actual type of the decomposition/solver. * * Any matrix decomposition inheriting this base class provide the following API: * * \code * MatrixType A, b, x; * DecompositionType dec(A); * x = dec.solve(b); // solve A * x = b * x = dec.transpose().solve(b); // solve A^T * x = b * x = dec.adjoint().solve(b); // solve A' * x = b * \endcode * * \warning Currently, any other usage of transpose() and adjoint() are not supported and will produce compilation errors. * * \sa class PartialPivLU, class FullPivLU, class HouseholderQR, class ColPivHouseholderQR, class FullPivHouseholderQR, class CompleteOrthogonalDecomposition, class LLT, class LDLT, class SVDBase
*/ template<typename Derived> class SolverBase : public EigenBase<Derived>
{ public:
/** \returns an expression of the solution x of \f$ A x = b \f$ using the current decomposition of A.
*/ template<typename Rhs> inlineconst Solve<Derived, Rhs>
solve(const MatrixBase<Rhs>& b) const
{
internal::solve_assertion<typename internal::remove_all<Derived>::type>::template run<false>(derived(), b); return Solve<Derived, Rhs>(derived(), b.derived());
}
/** \internal the return type of transpose() */ typedeftypename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType; /** \returns an expression of the transposed of the factored matrix. * * A typical usage is to solve for the transposed problem A^T x = b: * \code x = dec.transpose().solve(b); \endcode * * \sa adjoint(), solve()
*/ inline ConstTransposeReturnType transpose() const
{ return ConstTransposeReturnType(derived());
}
/** \internal the return type of adjoint() */ typedeftypename internal::conditional<NumTraits<Scalar>::IsComplex,
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,
ConstTransposeReturnType
>::type AdjointReturnType; /** \returns an expression of the adjoint of the factored matrix * * A typical usage is to solve for the adjoint problem A' x = b: * \code x = dec.adjoint().solve(b); \endcode * * For real scalar types, this function is equivalent to transpose(). * * \sa transpose(), solve()
*/ inline AdjointReturnType adjoint() const
{ return AdjointReturnType(derived().transpose());
}
protected:
template<bool Transpose_, typename Rhs> void _check_solve_assertion(const Rhs& b) const {
EIGEN_ONLY_USED_FOR_DEBUG(b);
eigen_assert(derived().m_isInitialized && "Solver is not initialized.");
eigen_assert((Transpose_?derived().cols():derived().rows())==b.rows() && "SolverBase::solve(): invalid number of rows of the right hand side matrix b");
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.