Re: Optimizing the Speed / Design tradeoff in numeric applications
- From: Dave <solomons_dad.w.marks_and_whom@xxxxxxxxxx>
- Date: Wed, 18 May 2005 09:35:21 +0100
Jonathan Bartlett wrote:
The program took three points from n-dimensional space and did calculations to arrive at three values, named d2, t0 and theta. Each value is a function of the three points. However, many of the subcalculations for each value are shared.
So, the design side of me says that I should separate each calculation into it's own function/module, so that we have:
d2 = calc_d2(p1, p2, p3); t0 = calc_t0(p1, p2, p3); theta = calc_theta(p1, p2, p3);
What I like about this method is that it truly separates concerns.
Too far, perhaps. If you always calculate d2, t0 and theta together, then a transform function along the lines of
transform(p1, p2, p3, &d2, &t0, &theta);
is a perfectly workable solution; it's obvious in intent and can share common subcalculations.
Only if you want to calculate any one of d2, t0 and theta in isolation from the other two does it really make sense to have separate functions for each.
.
- Follow-Ups:
- Re: Optimizing the Speed / Design tradeoff in numeric applications
- From: Jonathan Bartlett
- Re: Optimizing the Speed / Design tradeoff in numeric applications
- References:
- Optimizing the Speed / Design tradeoff in numeric applications
- From: Jonathan Bartlett
- Optimizing the Speed / Design tradeoff in numeric applications
- Prev by Date: Re: dangers of operator overloading
- Next by Date: Re: 'Fuzzy' text matching
- Previous by thread: Re: Optimizing the Speed / Design tradeoff in numeric applications
- Next by thread: Re: Optimizing the Speed / Design tradeoff in numeric applications
- Index(es):
Relevant Pages
|
Loading