pow() and ArraySum() with arrays or structs?
Posted: 13 Feb 2011, 16:40
I tried to finish my Bezier curves program which took advantage of the polymorphism of the math operations. But before I knew it, I was trying to add the algorithm for general bezier curves.
Anyway, to do this I needed use pow() on an array like this:This didn't work, however this did:
It looks like the compiler uses a temporary float variable which ruins it.
I also tried this:pow doesn't work, however mul does.
Does ArraySum() support any form for polymorphism? I tried replicating the way arrop is used by the compiler, but I couldn't figure out how to get sensible results with anything else than simple arrays.
I would expect a behavior like this: (In simple terms)In other words, ArraySum ignores the type of the array and just relies on the underlying polymorphism in the math operations. If we have an array of LocationType the result will be a LocationType, if it is an array of an array of int the result will be an array of int and so on.
(It would at least be beneficial for my bezier curves program ; ) )
Anyway, is there anywhere there is info on how polymorphism is supported by these EF functions?
Anyway, to do this I needed use pow() on an array like this:
Code: Select all
float bases[5] = { 0, 1, 2, 3, 4 };
float results[];
results = pow( bases, 2 );
Code: Select all
asm{ pow results, bases, 2 }
I also tried this:
Code: Select all
task main(){
// LocationType p[] = { {10,10}, {30,50}, {55, 20}, {80, 20}, {100, 50} };
LocationType p;// = { 20, 10 };
p.X = 20;
p.Y = 10;
LocationType result;
asm{
pow result, p, 2
// mul result, p, 2
}
NumOut( 0, LCD_LINE1, result.X );
NumOut( 0, LCD_LINE2, result.Y );
for(;;);
}
Does ArraySum() support any form for polymorphism? I tried replicating the way arrop is used by the compiler, but I couldn't figure out how to get sensible results with anything else than simple arrays.
I would expect a behavior like this: (In simple terms)
Code: Select all
//function call: return_value = ArraySum( arr );
return_value = 0;
for( unsigned int i=0; i<ArrayLen(arr); i++)
return_value += arr[i];
(It would at least be beneficial for my bezier curves program ; ) )
Anyway, is there anywhere there is info on how polymorphism is supported by these EF functions?