Skip to content

Commit

Permalink
remove math macro constants
Browse files Browse the repository at this point in the history
  • Loading branch information
paulstaab committed Oct 8, 2014
1 parent b42cfd0 commit b771292
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,10 +1,10 @@
Package: scrm
Type: Package
Title: Fast Simulation of Biological Sequences
Title: Fast Simulation of the Evolution of Biological Sequences
Version: 1.2-0
Date: 2014-09-10
Author: Paul Staab, Joe (Zhu) Sha, Dirk Metzler and Gerton Lunter
Maintainer: Paul R. Staab <staab@bio.lmu.de>
Maintainer: Paul Staab <develop@paulstaab.de>
Description: TBR
License: GPL (>= 3)
Suggests:
Expand Down
18 changes: 9 additions & 9 deletions src/scrm/random/fastfunc.h
Expand Up @@ -23,15 +23,14 @@
#ifndef scrm_src_random_fastfunc
#define scrm_src_random_fastfunc

#include <stdio.h>
#include <iostream>
#include <cmath>

#include <stdint.h>
#include <math.h>
//#include <malloc.h>
#if !defined(__APPLE__)
#include <malloc.h>
#endif
#include <iostream>


// Number of interpolation points. If this is changed, several constants in fastlog must also be changed.
#define SIZE_DOUBLE 1024
Expand All @@ -42,16 +41,17 @@ class FastFunc {
~FastFunc();

// Methods
double fastlog(double); /* about as fast as division; about as accurate as logf */
double fastlog(double); /* about as fast as division; about as accurate as logf */
double fastexp_up(double y); /* upper bound to exp; at most 6.148% too high. 10x as fast as exp */
double fastexp_lo(double y); /* lower bound to exp; at most 5.792% too low. 10x as fast as exp */

protected:
double* build_fastlog_double_table( int );

static constexpr double EXP_A=1048576/M_LN2;
static constexpr long long EXP_C_LO=90254;
static constexpr long long EXP_C_UP=-1;
static constexpr double LN2 = std::log(2);
static constexpr double EXP_A = 1048576/LN2;
static constexpr long long EXP_C_LO = 90254;
static constexpr long long EXP_C_UP = -1;

double* fastlog_double_table_;
};
Expand Down Expand Up @@ -100,7 +100,7 @@ inline double FastFunc::fastlog(double x) {
int index = ((*yint) >> (52-10)) & 1023; // upper 10 bits of mantissa
*yint |= 0x7ffffc0000000000; // convert float into remainder of mantissa; and
*yint &= 0x409fffffffffffff; // modify exponent to get into proper range
return (expon * M_LN2 + // contribution of base-2 log
return (expon * LN2 + // contribution of base-2 log
fastlog_double_table_[index] + // table lookup, and linear interpolation
(fastlog_double_table_[index+1] - fastlog_double_table_[index]) * (*(double*)(yint) - offset) );
}
Expand Down

0 comments on commit b771292

Please sign in to comment.