FLENS icon indicating copy to clipboard operation
FLENS copied to clipboard

antiDiag() method seems incorrect

Open fcarlosjr opened this issue 8 years ago • 1 comments

Hi Michael,

I would like to report a issue with the method antiDiag() defined in the FullStorage class. If I didn't misuse it, its not correctly implemented. For it to work, I had to make adjustments in its code. Currently its function body is composed of the following:

IndexType row_ = (d>0) ? 0 : -d; IndexType col_ = (d>0) ? d : 0;

IndexType row = firstRow() + row_;
IndexType col = firstCol() + col_;

return ArrayView(std::min(numRows()-row_, numCols()-col_),
                 &(operator()(row,lastCol()-col+1)),
                 -leadingDimension()+1,
                 firstViewIndex,
                 allocator());

I replaced this content with the following, making it work as expected (//*** points out changed lines):

IndexType row_ = (d<0) ? 0 : d; //*** IndexType col_ = (d<0) ? -d : 0; //***

IndexType row = row_;   //***
IndexType col = firstCol() + col_;

return ArrayView(std::min(numRows()-row_, numCols()-col_),
                 &(operator()(lastRow()-row,col)),    //***
                 leadingDimension()-1,  //***
                 firstViewIndex,
                 allocator());

I hope you guys keep up this great work.

fcarlosjr avatar Aug 15 '16 11:08 fcarlosjr

Just reporting, these changes I've made don't work for RowMajor-ordered matrices.

fcarlosjr avatar Aug 28 '16 19:08 fcarlosjr