Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
4bc48072
Commit
4bc48072
authored
May 15, 2012
by
Paolo Bosetti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from nkshigeru/mathmsvc
Math MSVC
parents
6971b0e9
36aaaafa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
src/math.c
src/math.c
+11
-7
No files found.
src/math.c
View file @
4bc48072
...
...
@@ -17,6 +17,10 @@
#define atanh(x) (log(1+x) - log(1-x))/2.0
#define cbrt(x) pow(x,1.0/3.0)
/* Declaration of complementary Error function */
double
erfc
(
double
x
);
/*
** Implementations of error functions
** credits to http://www.digitalmars.com/archives/cplusplus/3634.html
...
...
@@ -27,11 +31,11 @@ double
erf
(
double
x
)
{
static
const
double
two_sqrtpi
=
1
.
128379167095512574
;
double
sum
=
x
,
term
=
x
,
xsqr
=
x
*
x
;
int
j
=
1
;
if
(
fabs
(
x
)
>
2
.
2
)
{
return
1
.
0
-
erfc
(
x
);
}
double
sum
=
x
,
term
=
x
,
xsqr
=
x
*
x
;
int
j
=
1
;
do
{
term
*=
xsqr
/
j
;
sum
-=
term
/
(
2
*
j
+
1
);
...
...
@@ -48,16 +52,16 @@ double
erfc
(
double
x
)
{
static
const
double
one_sqrtpi
=
0
.
564189583547756287
;
double
a
=
1
,
b
=
x
;
double
c
=
x
,
d
=
x
*
x
+
0
.
5
;
double
q1
,
q2
;
double
n
=
1
.
0
,
t
;
if
(
fabs
(
x
)
<
2
.
2
)
{
return
1
.
0
-
erf
(
x
);
}
if
(
signbit
(
x
))
{
if
(
x
<
0
.
0
)
{
/*signbit(x)*/
return
2
.
0
-
erfc
(
-
x
);
}
double
a
=
1
,
b
=
x
;
double
c
=
x
,
d
=
x
*
x
+
0
.
5
;
double
q1
,
q2
;
double
n
=
1
.
0
,
t
;
do
{
t
=
a
*
n
+
b
*
x
;
a
=
b
;
...
...
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