Array-wise operations

Simen kjaeraas simen.kjaras at gmail.com
Tue Oct 12 13:43:14 PDT 2010


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.

-- 
Simen


More information about the Digitalmars-d-learn mailing list