Skip to content

Added some iterating methods to Matrix (issue #57)#79

Merged
vkostyukov merged 18 commits intovkostyukov:masterfrom
SamoylovMD:master
Aug 10, 2013
Merged

Added some iterating methods to Matrix (issue #57)#79
vkostyukov merged 18 commits intovkostyukov:masterfrom
SamoylovMD:master

Conversation

@SamoylovMD
Copy link
Copy Markdown
Contributor

Added: each, eachInRow, eachInColumn methods;
Renamed each method to eachNonZero.

@vkostyukov
Copy link
Copy Markdown
Owner

Test are failed, since there is a usage if each in MatrixMarketStream. So, we need to change it to new eachNonZero call.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good idea. The getRow is extreamally slow method. We need to iterate in straightforward way. Like:

for (int j = 0; j < columns; j++) {
  procedure.apply(i, j, get(i, j));
}

@vkostyukov
Copy link
Copy Markdown
Owner

Hi Maxim @SamoylovMD,

Please also add eachNonZeroInRow() and eachNonZeroInColumn() implementations. And we can provide more efficient implementation of eachNonZeroInRow() for CRS matrix and eachNonZeroInColumn for CCS matrix. For other cases, it would be enough to have general implenetation in AbstractMatrix class.

Please, also follow my coments to improve the code.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. We need a separate implementation for non-zero elements here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ofc, my error. Will rewrite in few seconds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in new commit.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefere to have spaces here. Like

procedure.apply(i, j, get(i, j));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants