Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
5c227efc
Commit
5c227efc
authored
Dec 11, 2013
by
peastman
Browse files
Merge pull request #239 from peastman/master
Fixes for compilation errors on Visual Studio 2013
parents
56e5e007
b4150b1b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
97 deletions
+98
-97
libraries/lepton/include/lepton/Operation.h
libraries/lepton/include/lepton/Operation.h
+2
-1
libraries/lepton/src/MSVC_erfc.h
libraries/lepton/src/MSVC_erfc.h
+87
-88
openmmapi/include/openmm/internal/MSVC_erfc.h
openmmapi/include/openmm/internal/MSVC_erfc.h
+9
-8
No files found.
libraries/lepton/include/lepton/Operation.h
View file @
5c227efc
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <sstream>
#include <sstream>
#include <algorithm>
namespace
Lepton
{
namespace
Lepton
{
...
@@ -1002,7 +1003,7 @@ public:
...
@@ -1002,7 +1003,7 @@ public:
return
result
;
return
result
;
}
}
else
else
return
std
::
pow
(
args
[
0
],
value
);
return
std
::
pow
(
args
[
0
],
value
);
}
}
ExpressionTreeNode
differentiate
(
const
std
::
vector
<
ExpressionTreeNode
>&
children
,
const
std
::
vector
<
ExpressionTreeNode
>&
childDerivs
,
const
std
::
string
&
variable
)
const
;
ExpressionTreeNode
differentiate
(
const
std
::
vector
<
ExpressionTreeNode
>&
children
,
const
std
::
vector
<
ExpressionTreeNode
>&
childDerivs
,
const
std
::
string
&
variable
)
const
;
double
getValue
()
const
{
double
getValue
()
const
{
...
...
libraries/lepton/src/MSVC_erfc.h
View file @
5c227efc
#ifndef LEPTON_MSVC_ERFC_H_
#ifndef LEPTON_MSVC_ERFC_H_
#define LEPTON_MSVC_ERFC_H_
#define LEPTON_MSVC_ERFC_H_
/*
/*
* At least up to version 8 (VC++ 2005), Microsoft does not support the
* Up to version 11 (VC++ 2012), Microsoft does not support the
* standard C99 erf() and erfc() functions. For now we're including these
* standard C99 erf() and erfc() functions so we have to fake them here.
* definitions for an MSVC compilation; if these are added later then
* These were added in version 12 (VC++ 2013), which sets _MSC_VER=1800
* the #ifdef below should change to compare _MSC_VER with a particular
* (VC11 has _MSC_VER=1700).
* version level.
*/
*/
#if defined(_MSC_VER)
#ifdef _MSC_VER
#define M_PI 3.14159265358979323846264338327950288
#if _MSC_VER <= 1700 // 1700 is VC11, 1800 is VC12
/***************************
/***************************
* erf.cpp
* erf.cpp
* author: Steve Strand
* author: Steve Strand
* written: 29-Jan-04
* written: 29-Jan-04
***************************/
***************************/
#include <cmath>
#include <cmath>
#define M_PI 3.14159265358979323846264338327950288
static
const
double
rel_error
=
1E-12
;
//calculate 12 significant figures
//you can adjust rel_error to trade off between accuracy and speed
static
const
double
rel_error
=
1E-12
;
//calculate 12 significant figures
//but don't ask for > 15 figures (assuming usual 52 bit mantissa in a double)
//you can adjust rel_error to trade off between accuracy and speed
//but don't ask for > 15 figures (assuming usual 52 bit mantissa in a double)
static
double
erfc
(
double
x
);
static
double
erfc
(
double
x
);
static
double
erf
(
double
x
)
//erf(x) = 2/sqrt(pi)*integral(exp(-t^2),t,0,x)
static
double
erf
(
double
x
)
// = 2/sqrt(pi)*[x - x^3/3 + x^5/5*2! - x^7/7*3! + ...]
//erf(x) = 2/sqrt(pi)*integral(exp(-t^2),t,0,x)
// = 1-erfc(x)
// = 2/sqrt(pi)*[x - x^3/3 + x^5/5*2! - x^7/7*3! + ...]
{
// = 1-erfc(x)
static
const
double
two_sqrtpi
=
1
.
128379167095512574
;
// 2/sqrt(pi)
{
if
(
fabs
(
x
)
>
2
.
2
)
{
static
const
double
two_sqrtpi
=
1
.
128379167095512574
;
// 2/sqrt(pi)
return
1
.
0
-
erfc
(
x
);
//use continued fraction when fabs(x) > 2.2
if
(
fabs
(
x
)
>
2
.
2
)
{
}
return
1
.
0
-
erfc
(
x
);
//use continued fraction when fabs(x) > 2.2
double
sum
=
x
,
term
=
x
,
xsqr
=
x
*
x
;
}
int
j
=
1
;
double
sum
=
x
,
term
=
x
,
xsqr
=
x
*
x
;
do
{
int
j
=
1
;
term
*=
xsqr
/
j
;
do
{
sum
-=
term
/
(
2
*
j
+
1
);
term
*=
xsqr
/
j
;
++
j
;
sum
-=
term
/
(
2
*
j
+
1
);
term
*=
xsqr
/
j
;
++
j
;
sum
+=
term
/
(
2
*
j
+
1
);
term
*=
xsqr
/
j
;
++
j
;
sum
+=
term
/
(
2
*
j
+
1
);
}
while
(
fabs
(
term
)
/
sum
>
rel_error
);
++
j
;
return
two_sqrtpi
*
sum
;
}
while
(
fabs
(
term
)
/
sum
>
rel_error
);
}
return
two_sqrtpi
*
sum
;
}
static
double
erfc
(
double
x
)
//erfc(x) = 2/sqrt(pi)*integral(exp(-t^2),t,x,inf)
static
double
erfc
(
double
x
)
// = exp(-x^2)/sqrt(pi) * [1/x+ (1/2)/x+ (2/2)/x+ (3/2)/x+ (4/2)/x+ ...]
//erfc(x) = 2/sqrt(pi)*integral(exp(-t^2),t,x,inf)
// = 1-erf(x)
// = exp(-x^2)/sqrt(pi) * [1/x+ (1/2)/x+ (2/2)/x+ (3/2)/x+ (4/2)/x+ ...]
//expression inside [] is a continued fraction so '+' means add to denominator only
// = 1-erf(x)
{
//expression inside [] is a continued fraction so '+' means add to denominator only
static
const
double
one_sqrtpi
=
0
.
564189583547756287
;
// 1/sqrt(pi)
{
if
(
fabs
(
x
)
<
2
.
2
)
{
static
const
double
one_sqrtpi
=
0
.
564189583547756287
;
// 1/sqrt(pi)
return
1
.
0
-
erf
(
x
);
//use series when fabs(x) < 2.2
if
(
fabs
(
x
)
<
2
.
2
)
{
}
return
1
.
0
-
erf
(
x
);
//use series when fabs(x) < 2.2
// Don't look for x==0 here!
}
if
(
x
<
0
)
{
//continued fraction only valid for x>0
// Don't look for x==0 here!
return
2
.
0
-
erfc
(
-
x
);
if
(
x
<
0
)
{
//continued fraction only valid for x>0
}
return
2
.
0
-
erfc
(
-
x
);
double
a
=
1
,
b
=
x
;
//last two convergent numerators
}
double
c
=
x
,
d
=
x
*
x
+
0
.
5
;
//last two convergent denominators
double
a
=
1
,
b
=
x
;
//last two convergent numerators
double
q1
,
q2
=
b
/
d
;
//last two convergents (a/c and b/d)
double
c
=
x
,
d
=
x
*
x
+
0
.
5
;
//last two convergent denominators
double
n
=
1
.
0
,
t
;
double
q1
,
q2
=
b
/
d
;
//last two convergents (a/c and b/d)
do
{
double
n
=
1
.
0
,
t
;
t
=
a
*
n
+
b
*
x
;
do
{
a
=
b
;
t
=
a
*
n
+
b
*
x
;
b
=
t
;
a
=
b
;
t
=
c
*
n
+
d
*
x
;
b
=
t
;
c
=
d
;
t
=
c
*
n
+
d
*
x
;
d
=
t
;
c
=
d
;
n
+=
0
.
5
;
d
=
t
;
q1
=
q2
;
n
+=
0
.
5
;
q2
=
b
/
d
;
q1
=
q2
;
}
while
(
fabs
(
q1
-
q2
)
/
q2
>
rel_error
);
q2
=
b
/
d
;
return
one_sqrtpi
*
exp
(
-
x
*
x
)
*
q2
;
}
while
(
fabs
(
q1
-
q2
)
/
q2
>
rel_error
);
}
return
one_sqrtpi
*
exp
(
-
x
*
x
)
*
q2
;
}
#endif // _MSC_VER <= 1700
#endif // _MSC_VER
#endif // _MSC_VER
#endif // LEPTON_MSVC_ERFC_H_
#endif // LEPTON_MSVC_ERFC_H_
openmmapi/include/openmm/internal/MSVC_erfc.h
View file @
5c227efc
#ifndef OPENMM_MSVC_ERFC_H_
#ifndef OPENMM_MSVC_ERFC_H_
#define OPENMM_MSVC_ERFC_H_
#define OPENMM_MSVC_ERFC_H_
/*
/*
* At least up to version 8 (VC++ 2005), Microsoft does not support the
* Up to version 11 (VC++ 2012), Microsoft does not support the
* standard C99 erf() and erfc() functions. For now we're including these
* standard C99 erf() and erfc() functions so we have to fake them here.
* definitions for an MSVC compilation; if these are added later then
* These were added in version 12 (VC++ 2013), which sets _MSC_VER=1800
* the #ifdef below should change to compare _MSC_VER with a particular
* (VC11 has _MSC_VER=1700).
* version level.
*/
*/
#ifdef
_MSC_VER
#if
def
ined(
_MSC_VER
)
#define M_PI 3.14159265358979323846264338327950288
#if _MSC_VER <= 1700 // 1700 is VC11, 1800 is VC12
/***************************
/***************************
* erf.cpp
* erf.cpp
* author: Steve Strand
* author: Steve Strand
...
@@ -81,6 +81,7 @@ static double erfc(double x)
...
@@ -81,6 +81,7 @@ static double erfc(double x)
return
one_sqrtpi
*
exp
(
-
x
*
x
)
*
q2
;
return
one_sqrtpi
*
exp
(
-
x
*
x
)
*
q2
;
}
}
#endif // _MSC_VER <= 1700
#endif // _MSC_VER
#endif // _MSC_VER
#endif // OPENMM_MSVC_ERFC_H_
#endif // OPENMM_MSVC_ERFC_H_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment