Re: [eigen] combine matrix blocks |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] combine matrix blocks
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 27 Nov 2009 14:17:45 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ATbEuoPGbwuoeKfF557XDz6sDNqEY5seItLa3fI6EQ4=; b=AaK8lJAnaXWppBxiO7/FDPElIl7tmiKt2rtk/pNfHSxatW6cIUuO78io7HWGMX3ETv BlG2dQaeKkQi4De6R3Q7gpzuuZVtYhYX7HPbRD37bkKmzx+qfv476HI0UU2BkvINW8Ht 6bYH5h8kwsZ6R6VwtqY5LMVe2i/w6aKKZ+n2o=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=utPJgJxvbp7vBRHKn7nnigPzcj3DHDEKIunrf+PIWMlrlyVRQ67aTWok1MvnjI5gnI WtH2ezNMCIHVfrgn/jmeu54je6l0MQoCO9REj8Ttn7KkNU8gkX+7nJTdC0l6cWBUzkbb 1PVKqMUk8ogVN7rQ6i9E/sfLwwIIADYQgloRY=
2009/11/27 Stefan Ulbrich <s.ulbrich@xxxxxxxxxxxxxx>:
> Hello,
> thank you for your answer. I managed to fix the error (I had a reference to
> a temporary variable involved).
> I think the MatrixView is a nice feature that I'd like to share with other
> users or to see in a future Eigen release.
> Is there a place - maybe on the wiki - where one can publish his own
> plugins?
Hm, we don't have anything like that, and the wiki is not quite the
right tool anyway, instead what comes closest is patch queues on
bitbucket.
See:
https://bitbucket.org/eigen/eigen/descendants/
Benoit
> best,
> Stefan
> Am 27.11.2009 um 00:15vorm. schrieb Gael Guennebaud:
>
> I don't really get it, but it seems you want to add a MatrixBase member
> returning an IndirectView. Then the correct way to write it is:
>
> template<typename Derived>
> class MatrixBase : ......
> {
> // ......
>
> template<typename A, typename B>
> IndirectView<Derived,A,B> view(const A& a, const B& b) { return
> IndirectView<Derived,A,B>(derived(), a, b); }
>
> };
>
> Does that help ?
>
> Also in your code you are mixing IndirectView and MatrixView, but I guess
> that's just a copy paste typo.
>
> gael.
>
> On Thu, Nov 26, 2009 at 6:27 PM, Stefan Ulbrich <s.ulbrich@xxxxxxxxxxxxxx>
> wrote:
>>
>> Hello,
>> sorry for the very long delay, I could not find the time to continue the
>> work on my project with Eigen.
>> The matrix view/proxy works quite well (addressing of elements via two
>> lists of indices). I only have still one problem. I want to hide the
>> creation of a
>> matrixview object within a member:
>> MatrixView<MatrixXd,Dynamic,Dynamic> getView(){
>> return m_matrix(range1,range2);
>> }
>> But it seems that this does not work .. for instance cout<<getView()
>> gives me an exception in malloc.
>> Do you have any idea what could go wrong?
>> Thank you very much!
>> Best,
>> Stefan
>>
>>
>> template<typename MatrixType, typename RowType, typename ColType> class
>> MatrixView
>> : public MatrixBase<MatrixView<MatrixType, RowType, ColType> >
>> {
>> public:
>> EIGEN_GENERIC_PUBLIC_INTERFACE(IndirectMatrix)
>> inline IndirectMatrix(const MatrixType& matrix, const RowType &rows, const
>> ColType &cols)
>> : m_matrix(matrix), m_rows(rows), m_cols(cols)
>> {
>> //std::cout << "Debug: " << m_rows.minCoeff() << "," << m_rows.maxCoeff()
>> << "," << matrix.rows() << std::endl;
>> //std::cout << "Debug: " << m_cols.minCoeff() << "," << m_cols.maxCoeff()
>> << "," << matrix.cols() << std::endl << matrix << std::endl << m_matrix <<
>> std::endl;
>> ei_assert(m_rows.minCoeff() >= 0 && m_rows.maxCoeff() < matrix.rows()
>> && m_cols.minCoeff() >= 0 && m_cols.maxCoeff() < matrix.cols());
>> }
>>
>> EIGEN_INHERIT_ASSIGNMENT_OPERATORS(IndirectMatrix)
>> inline int rows() const { return m_rows.rows(); }
>> inline int cols() const { return m_cols.rows(); }
>> inline Scalar& coeffRef(int row, int col)
>> {
>> return m_matrix.const_cast_derived().coeffRef(m_rows(row), m_cols(col));
>> }
>> inline const Scalar coeff(int row, int col) const
>> {
>> return m_matrix.coeff(m_rows(row), m_cols(col));
>> }
>> protected:
>> const typename MatrixType::Nested m_matrix;
>> const typename RowType::Nested m_rows;
>> const typename ColType::Nested m_cols;
>> };
>>
>>
>>
>>
>>
>
>
>
>
>