Re: [eigen] Map with negative outer stride

```On Mon, Feb 2, 2015 at 23:24:40, Chen-Pang He wrote:
> Theoretically a negative stride would work.  However, in
> Eigen/src/Core/Stride.h, there is an assertion
>
> eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);

There is also

eigen_assert(innerStride>=0 && outerStride>=0);

in the constructor.

> Because Dynamic is defined as -1 in
> Eigen/src/Core/util/Constants.h,  this prevents OuterStride<-1>
> from working.  Other negative strides such as OuterStride<-2>
> are OK.

To sum up, with assertions, only compile-time negative strides
work, and the stride cannot be -1.

> I am unsure if disabling assertions is a good idea.  If you want
> to disable assertions, #define EiGEN_NO_DEBUG.

The following is my test.

#define EIGEN_NO_DEBUG  // Disable eigen_assert

#include <Eigen/Core>
#include <iostream>

int main()
{
using namespace Eigen;

int data[] = { 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6 };

std::cout << Map<Matrix<int, 6, 6>, 0, OuterStride<-1> >(data + 5, 6, 6)
<< std::endl;
}

Cheers again,
Chen-Pang

> On Mon, Feb 2, 2015 at 13:52:40, Matwey V. Kornilov wrote:
> > Hi,
> >
> > I have an Vector: {1,2,3,4,5,6}
> > And I need to construct a matrix of the special form it:
> >
> > 1 0 0 0 0 0
> > 2 1 0 0 0 0
> > 3 2 1 0 0 0
> > 4 3 2 1 0 0
> > 5 4 3 2 1 0
> > 6 5 4 3 2 1
> >
> > Is there a simple way to do that through mapings?

```

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/