Post Reply 
Optimized Stack Operations
02-25-2019, 09:45 AM
Post: #8
RE: Optimized Stack Operations
Actually I'm using something odd - but it makes sense for saving memory:

I use one subroutine to calculate exp(), sin() and asin() - all have "similar" Taylor polynoms:
Code:

static double _exp_sin_asin(double f, byte nr) { // Calculate exp, sin or asin
  double result = f; // Start values for sin or asin
  double frac = f;
  if (nr == BITEXP) result = frac = 1.0; // Start values for exp
  for (int i = 1; _abs(frac) > TINYNUMBER && i < MAXITERATE; i++) {
    int i2 = 2 * i, i2p = 2 * i + 1, i2m = 2 * i - 1, i2m2 = i2m * i2m;
    double ffi2i2p = f * f / (i2 * i2p);
    if (nr == BITEXP) frac *= f / i; // Fraction for exp
    else if (nr == BITSIN) frac *=  -ffi2i2p; // Fraction for sin
    else frac *= ffi2i2p * i2m2; // Fraction for asin
    result += frac;
  }
  return (result);
}
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Optimized Stack Operations - deetee - 02-25-2019, 06:35 AM
RE: Optimized Stack Operations - ijabbott - 02-25-2019, 07:57 AM
RE: Optimized Stack Operations - grsbanks - 02-25-2019, 08:03 AM
RE: Optimized Stack Operations - deetee - 02-25-2019, 08:42 AM
RE: Optimized Stack Operations - deetee - 02-25-2019, 09:04 AM
RE: Optimized Stack Operations - grsbanks - 02-25-2019, 09:14 AM
RE: Optimized Stack Operations - deetee - 02-25-2019 09:45 AM
RE: Optimized Stack Operations - grsbanks - 02-25-2019, 09:50 AM
RE: Optimized Stack Operations - deetee - 02-25-2019, 09:57 AM
RE: Optimized Stack Operations - grsbanks - 02-25-2019, 10:00 AM
RE: Optimized Stack Operations - grsbanks - 02-25-2019, 10:09 AM
RE: Optimized Stack Operations - Leviset - 02-25-2019, 12:37 PM
RE: Optimized Stack Operations - deetee - 02-26-2019, 06:57 AM
RE: Optimized Stack Operations - rprosperi - 02-25-2019, 08:04 PM
RE: Optimized Stack Operations - rprosperi - 02-25-2019, 09:49 PM
RE: Optimized Stack Operations - deetee - 02-26-2019, 10:40 AM
RE: Optimized Stack Operations - Paul Dale - 02-26-2019, 10:52 AM
RE: Optimized Stack Operations - deetee - 02-26-2019, 03:00 PM
RE: Optimized Stack Operations - deetee - 02-27-2019, 11:04 AM
RE: Optimized Stack Operations - grsbanks - 02-27-2019, 11:13 AM
RE: Optimized Stack Operations - deetee - 03-03-2019, 08:25 AM
RE: Optimized Stack Operations - Paul Dale - 03-03-2019, 08:32 AM
RE: Optimized Stack Operations - deetee - 03-05-2019, 08:36 AM



User(s) browsing this thread: 2 Guest(s)