Improve documentation on Kronecker product module.

This commit is contained in:
Chen-Pang He 2013-07-21 00:19:46 +08:00
parent 3d94ed9fa0
commit 1191949e87

View File

@ -14,6 +14,13 @@
namespace Eigen { namespace Eigen {
/*!
* \ingroup KroneckerProduct_Module
*
* \brief The base class of dense and sparse Kronecker product.
*
* \tparam Derived is the derived type.
*/
template<typename Derived> template<typename Derived>
class KroneckerProductBase : public ReturnByValue<Derived> class KroneckerProductBase : public ReturnByValue<Derived>
{ {
@ -27,6 +34,7 @@ class KroneckerProductBase : public ReturnByValue<Derived>
typedef typename Traits::Index Index; typedef typename Traits::Index Index;
public: public:
/*! \brief Constructor. */
KroneckerProductBase(const Lhs& A, const Rhs& B) KroneckerProductBase(const Lhs& A, const Rhs& B)
: m_A(A), m_B(B) : m_A(A), m_B(B)
{} {}
@ -34,12 +42,20 @@ class KroneckerProductBase : public ReturnByValue<Derived>
inline Index rows() const { return m_A.rows() * m_B.rows(); } inline Index rows() const { return m_A.rows() * m_B.rows(); }
inline Index cols() const { return m_A.cols() * m_B.cols(); } inline Index cols() const { return m_A.cols() * m_B.cols(); }
/*!
* This overrides ReturnByValue::coeff because this function is
* efficient enough.
*/
Scalar coeff(Index row, Index col) const Scalar coeff(Index row, Index col) const
{ {
return m_A.coeff(row / m_B.rows(), col / m_B.cols()) * return m_A.coeff(row / m_B.rows(), col / m_B.cols()) *
m_B.coeff(row % m_B.rows(), col % m_B.cols()); m_B.coeff(row % m_B.rows(), col % m_B.cols());
} }
/*!
* This overrides ReturnByValue::coeff because this function is
* efficient enough.
*/
Scalar coeff(Index i) const Scalar coeff(Index i) const
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
@ -52,6 +68,8 @@ class KroneckerProductBase : public ReturnByValue<Derived>
}; };
/*! /*!
* \ingroup KroneckerProduct_Module
*
* \brief Kronecker tensor product helper class for dense matrices * \brief Kronecker tensor product helper class for dense matrices
* *
* This class is the return value of kroneckerProduct(MatrixBase, * This class is the return value of kroneckerProduct(MatrixBase,
@ -80,6 +98,8 @@ class KroneckerProduct : public KroneckerProductBase<KroneckerProduct<Lhs,Rhs> >
}; };
/*! /*!
* \ingroup KroneckerProduct_Module
*
* \brief Kronecker tensor product helper class for sparse matrices * \brief Kronecker tensor product helper class for sparse matrices
* *
* If at least one of the operands is a sparse matrix expression, * If at least one of the operands is a sparse matrix expression,