Array-wise operations

Bob Cowdery bob at bobcowdery.plus.com
Tue Oct 12 13:51:48 PDT 2010


 On 12/10/2010 21:43, Simen kjaeraas wrote:
> Bob Cowdery <bob at bobcowdery.plus.com> wrote:
>
>> x_average[ptr] = x_points; // tells me array length don't match.
>>
>> When I print x_average[ptr] or x_average[][ptr] or x_average[ptr][] they
>> all tell me the length is 10. What do I have to do to get to the row
>> which is 600?
>
> Oh, yes. Sorry, I didn't see that at first. D (for some reason) supports
> both C style definition of arrays (int a[3][];), and D style (int[][3]
> a;).
> As you can see, the order of indices are reversed.
>
> If you print typeof( x_average ), you should get float[10][600], meaning
> an array of 600 elements, each holding 10 floats.
>
> I believe what you want is float[600][10], which is an array of 10 arrays
> of 600 floats.
>
> If I'm wrong, you likely want a strided array, which D noes not currently
> support.
>
How confusing to support two ways of doing something which require the
indices in a different order. I now have a C style defined which works
so I will change it to a D style which should also work.

Thanks for the help.



More information about the Digitalmars-d-learn mailing list