Array-wise operations
Bob Cowdery
bob at bobcowdery.plus.com
Tue Oct 12 12:20:47 PDT 2010
I'm trying to implement some array-wise operations.
// I have an array of float values that need to be averaged over a 10
cycle period.
float x_points[600];
float x_average[600][10];
int ptr = 0;
// I accumulate one cycle in x_points and add that into a circular array
of the last 10 cycles
x_average[ptr] = x_points;
if (++ptr > 9) {ptr = 0;}
// Now I want to average the last 10 cycles and put the result back into
x_points
x_points[]
=(x_average[0]+x_average[1]+x_average[2]+x_average[3]+x_average[4]+x_average[5]+
x_average[6]+x_average[7]+x_average[8]+x_average[9])/10;
The average gives me a compile error of incompatible types.
bob
More information about the Digitalmars-d-learn
mailing list