Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92998240
midpnt.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 25, 11:45
Size
475 B
Mime Type
text/x-c
Expires
Wed, Nov 27, 11:45 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22549109
Attached To
R1448 Lenstool-HPC
midpnt.c
View Options
#define FUNC(x) ((*func)(x))
double
midpnt
(
double
(
*
func
)(
double
),
double
a
,
double
b
,
int
n
)
{
double
x
,
tnm
,
sum
,
del
,
ddel
;
static
double
s
;
int
it
,
j
;
if
(
n
==
1
)
{
return
(
s
=
(
b
-
a
)
*
FUNC
(
0.5
*
(
a
+
b
)));
}
else
{
for
(
it
=
1
,
j
=
1
;
j
<
n
-
1
;
j
++
)
it
*=
3
;
tnm
=
it
;
del
=
(
b
-
a
)
/
(
3.0
*
tnm
);
ddel
=
del
+
del
;
x
=
a
+
0.5
*
del
;
sum
=
0.0
;
for
(
j
=
1
;
j
<=
it
;
j
++
)
{
sum
+=
FUNC
(
x
);
x
+=
ddel
;
sum
+=
FUNC
(
x
);
x
+=
del
;
}
s
=
(
s
+
(
b
-
a
)
*
sum
/
tnm
)
/
3.0
;
return
s
;
}
}
#undef FUNC
Event Timeline
Log In to Comment