[viff-devel] Vedr.: Small VIFF language parser
Janus Dam Nielsen
fagidiot at daimi.au.dk
Tue Jul 15 07:35:58 PDT 2008
Hi again,
Heres the fruit of half a days work :)
Analyzing the expression:
sint n = (a * y + (1 - a) * x);
Yields the following results:
Final result:
((a * y )+ ((1 - a )* x )) cost: 30
(((a * y )+ x )- (x * a )) cost: 30
(((a * y )+ x )- (a * x )) cost: 30
(((a * y )- (a * x ))+ x ) cost: 30
(((y * a )+ x )- (a * x )) cost: 30
(((y * a )+ x )- (x * a )) cost: 30
((a * y )+ (x - (x * a ))) cost: 30
(((y * a )- (a * x ))+ x ) cost: 30
(((y * a )- (x * a ))+ x ) cost: 30
(((a * y )- (x * a ))+ x ) cost: 30
((a * (y - x ))+ x ) cost: 20
And lo and behold the last line reveals that the expression
a * (y - x )+ x
has the lowest cost. Again I just used the 10,5,5 costs for multiplication,
addition, and subtraction (they seem to enough for the moment).
These 11 expressions are not all the possible expressions one could generate, so
I don't claim that my implementation is complete but I hope it is sound.
Later...
More information about the viff-devel
mailing list