Re: [eigen] Tensor Module: chip off multiple dimensions

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

With tensor index notation it would be "A(i,j)=B(i,j,0,1,2)". I don't know if you like it better though.

I have submitted a pull request to support this but it is in standby.

Godeffroy

2015-12-23 16:50 GMT+01:00 Gabriel <gnuetzi@xxxxxxxxx>:
Hello :-)

I have a short stupid question

I would like to extract the last two dimensions as a 2d Eigen Matrix

    Tensor< double, 4> tensor(6,6,2,2);

in python notation:

    tensor[1,1,:,:]  -> map his array in a Eigen::Matrix<double,2,2> or leave it as a 2d tensor

How is this possible with chipping?

    tensor.chip(0,1).chip(0,1)   gives me the 2d Tensor of the last two dimensions

Is there a short cut to this?

I have a class which has a 5d tensor as member where I would like to
have a

    getElement(i,j,k)

function which then chips off the first 3 dimensionsand returns the chipping _expression_ as reference to be able to work on the remaining 2d data


thanks a lot!


On 10/07/2015 06:31 PM, Nathan Yonkee wrote:
That is correct Gabriel the data is stored in a single, fixed size array, the data is also aligned in case you have vectorized CPU insructions (SSE or AVX). I'm only confident for fixed sized objects, it may be different if you use dynamically sized ones.

An aside, all of the values in an array are contiGuous in memory - meaning their addresses are sequential; a chunk of aligned memory (2 or 4 doubles) is truly contiNuous so that the CPU can "blindly" operate on a whole chunk in one cycle.

On Wed, 7 Oct 2015 14:51:03 +0200
Gabriel <gnuetzi@xxxxxxxxx> wrote:

Hello =)

Trying to use the Tensor module to store some 3d Matrix and save it into
a HDF5 file.

Question:

When I do

Tensor<double,3> *a*(19,4,3);

is *a* then guaranteed to be continuous in memory as it is the case for
all DenseBase<>  objects? As far as I am aware off :-)


Thanks !

BR Gabriel Nützi










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