On Fri, 2013-10-04 at 12:49 -0700, Daryle Walker wrote:
> I figured out how to activate the web page feature of the GitHub
> repository for my array proposal. It is at
> http://ctmacuser.github.io/multiarray-iso-proposal. It should lead to
> the copy of the proposal copied there from the regular branch.
>
> The next submission deadline is in a week, so I need a final check
> over. Are there any mistakes or omissions? Is anything unclear?
I think you need to put a lot more effort into the motivation section.
Explain why this is something that is needed.
In "Design Decisions" you are waving your hands trying to claim that
operator[]() calls are inherently slower than calls to the built in
operator[].
Do you have any data to support this claim?
Preferably data that support that it is infeasible to achieve the same
performance.
This is important as you are disabling user defined indexing for data
stored in your class based on this.
I am strongly opposed to misappropriating the function call operator for
indexing.
std::array<int, 17> anArray;
std::function<int(int)> fun(anArray);
One can have lots of fun with that function call operator.
array_md<int, 2, 3> my2dArray;
my2dArray
[{1,2,3,4}] = 42;
On Fri, 2013-10-04 at 12:49 -0700, Daryle Walker wrote:
> I figured out how to activate the web page feature of the GitHub
> repository for my array proposal. It is at
> http://ctmacuser.github.io/multiarray-iso-proposal. It should lead to
> the copy of the proposal copied there from the regular branch.
>
> The next submission deadline is in a week, so I need a final check
> over. Are there any mistakes or omissions? Is anything unclear?
I think you need to put a lot more effort into the motivation section.
Explain why this is something that is needed.
2013. október 4., péntek 22:32:30 UTC+2 időpontban Magnus Fromreide a következőt írta:On Fri, 2013-10-04 at 12:49 -0700, Daryle Walker wrote:
> I figured out how to activate the web page feature of the GitHub
> repository for my array proposal. It is at
> http://ctmacuser.github.io/multiarray-iso-proposal. It should lead to
> the copy of the proposal copied there from the regular branch.
>
> The next submission deadline is in a week, so I need a final check
> over. Are there any mistakes or omissions? Is anything unclear?
In "Design Decisions" you are waving your hands trying to claim that
operator[]() calls are inherently slower than calls to the built in
operator[].
Do you have any data to support this claim?
Preferably data that support that it is infeasible to achieve the same
performance.
This is important as you are disabling user defined indexing for data
stored in your class based on this.I guess he referred to the std::array<X,n> implementation may have extra data besides the element, so indexing std::array<std::array<X,n>,m> with (a,b) "coordinates" isn't the same as indexing a X[n*m] with a*n+b.
I am strongly opposed to misappropriating the function call operator for
indexing.
std::array<int, 17> anArray;
std::function<int(int)> fun(anArray);
One can have lots of fun with that function call operator.A multidimensional array needs to have multicoordinate indexing, otherwise it is useless.
Before C++11, it was done using the function call operator, because it was totally awkward to use operator[] (call syntax would been something like my_array_obj[array_indexes(1,2,3)];). I haven't seen any multiarray/linalg matrix library that started from zero using C++11, that's why all of them still use operator(). But this is no reason to have this new proposed class to use it.
As for operator[], the 'reference' implementation allows this, without any error:Instead of initializer_list (as you cannot restrict the accepted init list size), I think it would be better to use std::array<size_type, dimensionality> (or something equivalent) as the parameter for operator[].
array_md<int, 2, 3> my2dArray;my2dArray
[{1,2,3,4}] = 42;
Also, I find linear addresses of a multidim array error-prone. Instead, I'd give a reshape() function that would allow us to reshape the contiguous memory layout to another dimension (internally, that can be done with a static_cast), then use it to reshape to an 1D array, then index it - with the linear index. The idea is to do something like Matlab's reshape (it does have linear indexing - and I get burned by that every now and then).
Can you clarify what "any multiarray/linalg matrix library that started from zero" means?
For the current containers, at() throws when given a bad index, while operator[] tries to use it even when it causes Undefined Behavior. My operator[] does the same thing; it forfeits checking the list length or the individual values, even if it causes a crash. Use at() again to check those and throw if they're found wanting, but forfeit speed due to those checks.
Someone from the previous discussion brought up using std::array<std::size_t, extent_count> as the index type for tuple-enabled operator[]. He also mentioned the down side. We get an error if too many items are in the initializer, but not if there are too few. In the latter case, the missing elements will be zero instead of causing an error. There's also the cosmetic issue of a double brace pair is sometimes needed for a std::array "literal" because brace-elision isn't always accepted. (And it's weird to use std::array as a helper type since this code will be redefining array!)
Also, I find linear addresses of a multidim array error-prone. Instead, I'd give a reshape() function that would allow us to reshape the contiguous memory layout to another dimension (internally, that can be done with a static_cast), then use it to reshape to an 1D array, then index it - with the linear index. The idea is to do something like Matlab's reshape (it does have linear indexing - and I get burned by that every now and then).For "linear addresses of a multidim array," are you talking about the begin/end functions?
int a[][][] = {...}
begin(a);
And what would happen if the source and destination type have different total element counts? Or would such conversions be blocked?
A copy seems better all around, and I can change element type and/or count at the same time.
2013. október 5., szombat 13:58:15 UTC+2 időpontban Daryle Walker a következőt írta:For the current containers, at() throws when given a bad index, while operator[] tries to use it even when it causes Undefined Behavior. My operator[] does the same thing; it forfeits checking the list length or the individual values, even if it causes a crash. Use at() again to check those and throw if they're found wanting, but forfeit speed due to those checks.Your reference implementation adds a run-time check not just for out-of-range indexing, but also for the amount of indexes. That should be a compile-time error, for both operator[] and at().
Also, I find linear addresses of a multidim array error-prone. Instead, I'd give a reshape() function that would allow us to reshape the contiguous memory layout to another dimension (internally, that can be done with a static_cast), then use it to reshape to an 1D array, then index it - with the linear index. The idea is to do something like Matlab's reshape (it does have linear indexing - and I get burned by that every now and then).For "linear addresses of a multidim array," are you talking about the begin/end functions?No. An operator[](size_t). That should be given only for 1D arrays, I believe. While at it, I think begin() and end() also should give an iterator to an array with one-less extents (except for 1D arrays): similarly togiving a pointer to int[][]. I think it is both more logical, and compatible with built-in arrays with multiple extents.
int a[][][] = {...}
begin(a);
And what would happen if the source and destination type have different total element counts? Or would such conversions be blocked?Blocked, of course. Using the same memory are for items of different size and/or amount is going straight against any type system. (((((Although: what about array<uint8_t, 4> vs array<_simd_vector_of_4_uint8, 1>?)))))
If one needs that, make a copy (rather, being different type, make a conversion).
A copy seems better all around, and I can change element type and/or count at the same time.I think it is quite bad to have my 3D array to be viewed in a 1D or 2D fashion, I need to make a copy.. (Alternatively to this reshape, an appropriate array_view could be a good solution as well.)