Rcpp Version 1.0.14
Toggle main menu visibility
Main Page
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
_
b
c
d
f
g
k
m
n
r
t
y
Typedefs
c
d
e
f
g
i
l
n
p
r
s
t
v
w
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
_
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Enumerator
r
v
Related Symbols
o
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
x
y
Functions
a
c
d
e
f
g
i
l
m
o
p
r
s
Variables
Typedefs
Macros
_
a
b
c
d
e
g
h
i
j
l
m
n
o
r
s
t
u
v
y
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
Loading...
Searching...
No Matches
piSugar.cpp
Go to the documentation of this file.
1
2
#include <
Rcpp.h
>
3
4
using namespace
Rcpp
;
5
6
// [[Rcpp::export]]
7
double
piSugar
(
const
int
N
) {
8
NumericVector
x =
runif
(
N
);
9
NumericVector
y =
runif
(
N
);
10
NumericVector
d
= sqrt(x*x + y*y);
11
return
4.0 *
sum
(
d
< 1.0) /
N
;
12
}
7
double
piSugar
(
const
int
N
) {
…
}
Rcpp.h
Rcpp::Vector
Definition
Vector.h:35
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::runif
NumericVector runif(int n, double min, double max)
Definition
random.h:295
Rcpp::as
T as(SEXP x)
Definition
as.h:151
Rcpp::sum
sugar::Sum< INTSXP, NA, T > sum(const VectorBase< INTSXP, NA, T > &t)
Definition
sum.h:98
piSugar
double piSugar(const int N)
Definition
piSugar.cpp:7
inst
examples
Misc
piSugar.cpp
Generated on Sun Jan 12 2025 11:21:42 for Rcpp Version 1.0.14 by
1.9.8