1. Just wondering if something like this would be faster....

Code:
```...

for(i=0;j=0;i<M||j<n;i++;j++){

coeffs[i][j] = xpwr * ypwr;
ypwr *= y;
sol += C[i][j] * coeffs[i][j];
}

return sol;```
warning it may be a bad idea. it may not run faster.

2. Originally Posted by kryptkat
Just wondering if something like this would be faster....

Code:
```...

for(i=0;j=0;i<M||j<n;i++;j++){```
warning it may be a bad idea. it may not run faster.
Please explain that for loop to me.

Quzah.

3. sure. i was asking if taking the four for() loops in the previous example and combining them in to two loops using one for() statement would be any faster. it was just an example to get the point across.... the example will not work as is the actual modifications to get it to work you or the op would have to do for themself. for(var1loop1;var2loop2;compairstatment or statements;loopinc;loopinc){statements};

i know i messed up the forstatement logic but it was just an example and would not work as is. did it quik with out thinking.

also is there a proper name for the double loop for() ? messed up look to it but it is more compact.

4. @Lina
It would be really useful if you could provide a main() which sets up some data, calls that function and prints the expected results.

And it would be useful to know how you calculate ACPE for a given function.

It's a lot easier to see whether an optimisation works if we have a working frame of reference to compare against.

5. Originally Posted by kryptkat
did it quik with out thinking.
Yes, that was definitely apparent.

Quzah.

6. Quote:
Originally Posted by kryptkat
did it quik with out thinking.
Yes, that was definitely apparent.
queston still stands .... would it be faster to use one for() with multi var?

7. Hi,

whenever i type
Code:
`static val_t coeffs[M][N] = {0};`
i get an error tha says=
missing braces around initializer
(near initialization for `coffs[0]')
why is that?

8. Originally Posted by Lina
Hi,

whenever i type
Code:
`static val_t coeffs[M][N] = {0};`
i get an error tha says=
missing braces around initializer
(near initialization for `coffs[0]')
why is that?
For just the reason it says. It is saying that it would prefer full braces, but I chose not to. It does what I expect, and the warning is telling me something I am aware of, but choose to ignore.

9. can you show how you would do it coz i tried to do it and i didn't work

10. Is it an error or is it a warning? I get the warning, understand it, ignore it; the code builds, I run it.

To do the full bracing, you need to do this
Code:
`static val_t coeffs[M][N] = {{0,0,0},{0,0,0},{0,0,0}};`
for whatever dimensions M and N are. Or do the same for any M and N using {0}.

Attached my test code.

11. when i tested the following, it gave me wrong results.

Code:
```val_t poly2d_dave(val_t C[M][N])
{
static val_t coeffs[M][N] = {0};
static int init = 0;
int i, j;
val_t sol = 0.0;

if ( init == 0 )
{
val_t xpwr = 1.0;
val_t ypwr = 1.0;
val_t x = *x_p;
val_t y = *y_p;
for ( i = 0; i < M; i++ )
{
ypwr = 1.0;
for ( j = 0; j < N; j++ )
{
coeffs[i][j] = xpwr * ypwr;
ypwr *= y;
}
xpwr *= x;
}
init = 1;
}

for ( i = 0; i < M; i++ )
{
for ( j = 0; j < N; j++ )
{
sol += C[i][j] * coeffs[i][j];
}
}
return sol;
}```

12. > when i tested the following, it gave me wrong results.
Which is why YOU need to post a complete compilable program which we can just load and run without having to do any guessing as to what input data to pass, or what output to expect.

13. If you really want help, let us all play on the same field. Show your actual code, please.
Originally Posted by Salem
@Lina
It would be really useful if you could provide a main() which sets up some data, calls that function and prints the expected results.

And it would be useful to know how you calculate ACPE for a given function.

It's a lot easier to see whether an optimisation works if we have a working frame of reference to compare against.
Originally Posted by Dave_Sinkula
I am not familiar with ACPE, but I've tried to look into it a bit. I was wondering if you've got some tool that you use that might be helpful to share with the rest of us?

Also, such as in the case of your precomputed version, is the amortization over a single call to the function, or is it amortized over all calls?
Originally Posted by Dave_Sinkula
Is it an error or is it a warning?

14. M=83, N=97, system clock rate=3190 MHz

Error in poly2d_dave
x=1.062500 y=-0.937500 Output = 3538.000000 but should be 44581.437500

15. Now if only I had C, i might have a prayer at reproducing this.
Code:
```val_t C[M][N] = {{1.2,3.4,5.6},{7.8,9.0,-2.3},{-4.5,-6.7,-8.9}};
val_t X = 1.062500, *x_p = &X;
val_t Y = -0.937500, *y_p = &Y;

int main(void)
{
long count = 10000;
test(count, BIND(poly2d_base),    C);
test(count, BIND(poly2d_precomp), C);
test(count, BIND(poly2d_dave),    C);
test(count, BIND(poly2d_horner),  C);
return 0;
}

/* my output
poly2d_base     = -6.71054, 10000 iterations : 2.493
poly2d_precomp  = -6.71054, 10000 iterations : 2.294
poly2d_dave     = -6.71054, 10000 iterations : 2.042
poly2d_horner   = -6.71054, 10000 iterations : 2.114
*/```