This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Zero copying block operations?

Tags: None
(comma "," separated)
bravegag
Registered Member
Posts
52
Karma
0

Zero copying block operations?

Tue Mar 25, 2014 8:16 am
Hello,

I have multiple use-cases where I extract a portion of a matrix using block operations e.g. block, middleRows, bottomRows etc. For performance reasons I would like to get a reference to those data portions within the matrix rather than a copy. I know this is not always possible due to e.g. striding but in some cases it does make sense and the performance gains of avoiding unnecessary expensive copies is substantial.

Is there a way to do block operations that do not incur in copying?

TIA,
Best regards,
Giovanni
jitseniesen
Registered Member
Posts
204
Karma
2
The object returned by block (and similar functions) does precisely what you want. The return type is an expression type. It is not a reference in the C++ sense (a type of the form X&), but it stores a reference to the matrix. This means that bad things happen if the matrix is destroyed.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]