Click here to Skip to main content
15,567,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: RichEdit Controls / Embedded Objects but seriously Pin
Steve Thresher1-Oct-09 1:03
Steve Thresher1-Oct-09 1:03 
GeneralRe: RichEdit Controls / Embedded Objects but seriously Pin
Gary R. Wheeler1-Oct-09 2:19
Gary R. Wheeler1-Oct-09 2:19 
GeneralRe: RichEdit Controls / Embedded Objects Pin
Dan Neely1-Oct-09 3:25
Dan Neely1-Oct-09 3:25 
Questionfloat vs double - tricky performance issue [modified] Pin
Chris Losinger30-Sep-09 11:50
professionalChris Losinger30-Sep-09 11:50 
AnswerRe: float vs double - tricky performance issue Pin
harold aptroot30-Sep-09 12:15
harold aptroot30-Sep-09 12:15 
GeneralRe: float vs double - tricky performance issue Pin
Chris Losinger30-Sep-09 12:19
professionalChris Losinger30-Sep-09 12:19 
AnswerRe: float vs double - tricky performance issue Pin
TimothyPMoore30-Sep-09 12:56
TimothyPMoore30-Sep-09 12:56 
GeneralRe: float vs double - tricky performance issue [modified] Pin
Chris Losinger30-Sep-09 13:01
professionalChris Losinger30-Sep-09 13:01 
sure.

here's most of it:

void CalcIIRFactors (FloatType sigma)
{
   // constants from eq 38

   const FloatType b0 = (FloatType)-1.783;
   const FloatType b1 = (FloatType)-1.723;
   const FloatType w0 =  (FloatType)0.6318;
   const FloatType w1 =  (FloatType)1.997;

   const FloatType b0OverSigma = b0 / sigma;
   const FloatType b1OverSigma = b1 / sigma;
   const FloatType w0OverSigma = w0 / sigma;
   const FloatType w1OverSigma = w1 / sigma;

   const FloatType pi = (FloatType)acos(-1.0);
   const FloatType scale = sqrt (2 * pi) * sigma;
   const FloatType a0 = (FloatType)1.680 / scale;
   const FloatType a1 = (FloatType)3.735 / scale;
   const FloatType c0 = (FloatType)-0.6803 / scale;
   const FloatType c1 = (FloatType)-0.2598 / scale;

   // eq 21
   numerator_factors_positive [0] = a0 + c0;
   numerator_factors_positive [1] =
 (exp(b1OverSigma)*(c1*sin(w1OverSigma)-
 (c0+2*a0)*cos(w1OverSigma)) +
 exp(b0OverSigma)*(a1*sin(w0OverSigma) -
 (2*c0+a0)*cos (w0OverSigma)));

   numerator_factors_positive [2] =
 (2 * exp(b0OverSigma+b1OverSigma) *
 ((a0+c0)*cos(w1OverSigma)*cos(w0OverSigma) -
 a1*cos(w1OverSigma)*sin(w0OverSigma) -
 c1*cos(w0OverSigma)*sin(w1OverSigma)) +
 c0*exp(2*b0OverSigma) + a0*exp(2*b1OverSigma));

   numerator_factors_positive [3] =
 (exp(b1OverSigma+2*b0OverSigma) * (c1*sin(w1OverSigma) -
 c0*cos(w1OverSigma)) + exp(b0OverSigma+2*b1OverSigma) *
 (a1*sin(w0OverSigma) - a0*cos(w0OverSigma)));

   numerator_factors_positive [4] = 0.0;

   // eq 22
   denominator_factors_positive [0] = 0.0;
   denominator_factors_positive [1] =
 -2 * exp(b1OverSigma) * cos(w1OverSigma) -
 2 * exp(b0OverSigma) * cos (w0OverSigma);

   denominator_factors_positive [2] =
 4 * cos(w1OverSigma) * cos(w0OverSigma) *
 exp(b0OverSigma + b1OverSigma) +
 exp(2 * b1OverSigma) + exp(2 * b0OverSigma);

   denominator_factors_positive [3] =
 -2 * cos(w0OverSigma) * exp(b0OverSigma +
 2*b1OverSigma) -  2*cos(w1OverSigma) *
 exp(b1OverSigma + 2*b0OverSigma);

   denominator_factors_positive [4] = exp(2*b0OverSigma + 2*b1OverSigma);

   int i;

   // FACTORS = 5
   for (i = 0; i < FACTORS; i++)
   {
      denominator_factors_negative[i] = denominator_factors_positive[i];
   }

   numerator_factors_negative[0] = 0.0;

   for (i = 1; i < FACTORS; i++)
   {
      numerator_factors_negative[i] =
 numerator_factors_positive[i] -
 denominator_factors_positive[i] *
 numerator_factors_positive[0];
   }


there's a little more after this, but it's working on things that aren't used inside the offending loop. and, yes, the values are correct. - even when slow, it's giving good results.

also, testing with finer precision, it looks like the slowdown isn't centered at 3.0 exactly, rather, it's looking more like sigma = 2.7 is the key. e ?? OMG | :OMG:

i wish i could post the whole thing, but... well, it's proprietary.


modified on Wednesday, September 30, 2009 6:11 PM

GeneralRe: float vs double - tricky performance issue Pin
TimothyPMoore30-Sep-09 14:02
TimothyPMoore30-Sep-09 14:02 
GeneralRe: float vs double - tricky performance issue Pin
Rick York30-Sep-09 14:29
mveRick York30-Sep-09 14:29 
GeneralRe: float vs double - tricky performance issue Pin
Chris Losinger30-Sep-09 14:38
professionalChris Losinger30-Sep-09 14:38 
QuestionEnumerated Type Not Comparing Correctly Pin
Jim Fell30-Sep-09 9:49
Jim Fell30-Sep-09 9:49 
AnswerRe: Enumerated Type Not Comparing Correctly Pin
includeh1030-Sep-09 9:56
includeh1030-Sep-09 9:56 
GeneralRe: Enumerated Type Not Comparing Correctly Pin
Jim Fell30-Sep-09 10:02
Jim Fell30-Sep-09 10:02 
QuestionRe: Enumerated Type Not Comparing Correctly Pin
CPallini30-Sep-09 10:23
mveCPallini30-Sep-09 10:23 
AnswerRe: Enumerated Type Not Comparing Correctly Pin
Jim Fell30-Sep-09 10:58
Jim Fell30-Sep-09 10:58 
GeneralRe: Enumerated Type Not Comparing Correctly Pin
CPallini30-Sep-09 11:57
mveCPallini30-Sep-09 11:57 
AnswerRe: Enumerated Type Not Comparing Correctly Pin
Jim Fell30-Sep-09 10:59
Jim Fell30-Sep-09 10:59 
QuestionIs exe file aligned in size? Pin
includeh1030-Sep-09 6:09
includeh1030-Sep-09 6:09 
AnswerRe: Is exe file aligned in size? Pin
Joe Woodbury30-Sep-09 7:01
professionalJoe Woodbury30-Sep-09 7:01 
GeneralRe: Is exe file aligned in size? Pin
includeh1030-Sep-09 9:46
includeh1030-Sep-09 9:46 
GeneralRe: Is exe file aligned in size? Pin
Joe Woodbury30-Sep-09 9:52
professionalJoe Woodbury30-Sep-09 9:52 
GeneralRe: Is exe file aligned in size? Pin
includeh1030-Sep-09 10:37
includeh1030-Sep-09 10:37 
AnswerRe: Is exe file aligned in size? Pin
krmed30-Sep-09 7:02
krmed30-Sep-09 7:02 
GeneralRe: Is exe file aligned in size? Pin
Richard MacCutchan30-Sep-09 7:17
mveRichard MacCutchan30-Sep-09 7:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.