Daniel said:
Kai-Uwe Bux said:
From the FAQ:
In particular, if these inner array-like objects end up allocating
their own block of memory for their row [or column] of the matrix,
the performance overhead for creating / destroying your matrix
objects can grow dramatically.
If I want to access just one element in the array, must I create a row
or column proxy?
Note the "if" in the FAQ. In reasonable implementations, there is no
overhead for accessing a single element via a proxy.
The "all true Scotsman" fallacy, you are giving "reasonable" a special
definition.
Please note that I do not give any definition for "reasonable".
I responded by observing that what you quote from the FAQ is a conditional
statement starting with an "if". Such a statement does not apply whenever
the hypothesis is false.
I also commented, that in reasonable implementations, the proxies are
optimized away. To deal with your contention that there might be an
overhead in using [][] for element access, a much weaker statement would
suffice, namely the existence of implementation that do no incur overhead.
In short, I do not see any "true Scotsman" fallacy in my reasoning.
Now that the fallacy comment is out of the way, I just would like to
reiterate the point that the fear of overhead in [][] over (,) is
unfounded. I provided a reference for a post where I backed up that claim
with empirical data. Of course, such claims and measurements are compiler
specific. I would appreciate if someone could show an optimizing compiler
that makes [][] slower than (,) given the simple implementation from
http://groups.google.com/group/comp...q=Bux+Steinbach+proxy&rnum=1#cecce09e32c2dfc6
(from FAQ 13.12)
If you have a decent compiler and if you judiciously use inlining,
the compiler should optimize away the temporary objects. In other
words, the operator[]-approach above will hopefully not be slower
than what it would have been if you had directly called
Matrix:
perator()(unsigned row, unsigned col) in the first place. Of
course you could have made your life simpler and avoided most of the
above work by directly calling Matrix:
perator()(unsigned row,
unsigned col) in the first place. So you might as well directly call
Matrix:
perator()(unsigned row, unsigned col) in the first place.
Is there anything in FAQs 13.10-12 that you specifically object to? If
yes, what is it and why?
I did not address the FAQ. I addressed the virtues of proxies. I think that
A.row(i) += factor*A.row(j);
is much more suggestive notation than
row_of( A, i, j, factor );
Only my refutation of your claim that proxies incur an overhead and
therefore should be avoided for simple element access got us into FAQ area,
and I only responded to the part of the FAQ you quoted.
To me the situation looks as follows:
a) proxies provide very useful syntactic sugar for linear algebra.
b) even with very simple minded proxy implementations, [][] is not slower
than (,).
So what would be the reason, not to provide [][]? Please note that I do not
claim that one should not provide (,).
Best
Kai-Uwe Bux