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
min.h
Go to the documentation of this file.
1
2
// Min.h: Rcpp R/C++ interface class library -- min
3
//
4
// Copyright (C) 2012 - 2018 Dirk Eddelbuettel and Romain Francois
5
//
6
// This file is part of Rcpp.
7
//
8
// Rcpp is free software: you can redistribute it and/or modify it
9
// under the terms of the GNU General Public License as published by
10
// the Free Software Foundation, either version 2 of the License, or
11
// (at your option) any later version.
12
//
13
// Rcpp is distributed in the hope that it will be useful, but
14
// WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
20
21
#ifndef Rcpp__sugar__min_h
22
#define Rcpp__sugar__min_h
23
24
namespace
Rcpp
{
25
namespace
sugar{
26
27
template
<
int
RTYPE,
bool
NA,
typename
T>
28
class
Min
{
29
public
:
30
typedef
typename
Rcpp::traits::storage_type<RTYPE>::type
STORAGE
;
31
32
Min
(
const
T&
obj_
) :
obj
(
obj_
) {}
33
34
operator
STORAGE
()
const
{
35
R_xlen_t
n =
obj
.size();
36
if
(n == 0)
return
(
static_cast<
STORAGE
>
(
R_PosInf
));
37
38
STORAGE
min
, current ;
39
min
=
obj
[0] ;
40
if
( Rcpp::traits::is_na<RTYPE>(
min
) )
return
min
;
41
42
for
(
R_xlen_t
i=1; i<n; i++){
43
current =
obj
[i] ;
44
if
( Rcpp::traits::is_na<RTYPE>( current ) )
return
current;
45
if
( current <
min
)
min
= current ;
46
}
47
return
min
;
48
}
34
operator
STORAGE
()
const
{
…
}
49
50
const
T&
obj
;
51
} ;
28
class
Min
{
…
};
52
53
// version for NA = false
54
template
<
int
RTYPE,
typename
T>
55
class
Min
<RTYPE,
false
,T> {
56
public
:
57
typedef
typename
Rcpp::traits::storage_type<RTYPE>::type
STORAGE
;
58
59
Min
(
const
T&
obj_
) :
obj
(
obj_
) {}
60
61
operator
STORAGE
()
const
{
62
R_xlen_t
n =
obj
.size();
63
if
(n == 0)
return
(
static_cast<
STORAGE
>
(
R_PosInf
));
64
65
STORAGE
min
, current ;
66
min
=
obj
[0] ;
67
for
(
R_xlen_t
i=1; i<n; i++){
68
current =
obj
[i] ;
69
if
( current <
min
)
min
= current ;
70
}
71
return
min
;
72
}
61
operator
STORAGE
()
const
{
…
}
73
74
const
T&
obj
;
75
} ;
55
class
Min
<RTYPE,
false
,T> {
…
};
76
77
78
}
// sugar
79
80
81
template
<
int
RTYPE,
bool
NA,
typename
T>
82
sugar::Min<RTYPE,NA,T>
min
(
const
VectorBase<RTYPE,NA,T>
& x){
83
return
sugar::Min<RTYPE,NA,T>
(x.
get_ref
()) ;
84
}
82
sugar::Min<RTYPE,NA,T>
min
(
const
VectorBase<RTYPE,NA,T>
& x) {
…
}
85
86
}
// Rcpp
87
88
#endif
Rcpp::VectorBase
Definition
VectorBase.h:29
Rcpp::VectorBase::get_ref
VECTOR & get_ref()
Definition
VectorBase.h:37
Rcpp::sugar::Min< RTYPE, false, T >::Min
Min(const T &obj_)
Definition
min.h:59
Rcpp::sugar::Min< RTYPE, false, T >::STORAGE
Rcpp::traits::storage_type< RTYPE >::type STORAGE
Definition
min.h:57
Rcpp::sugar::Min< RTYPE, false, T >::obj
const T & obj
Definition
min.h:74
Rcpp::sugar::Min
Definition
min.h:28
Rcpp::sugar::Min::obj
const T & obj
Definition
min.h:50
Rcpp::sugar::Min::STORAGE
Rcpp::traits::storage_type< RTYPE >::type STORAGE
Definition
min.h:30
Rcpp::sugar::Min::Min
Min(const T &obj_)
Definition
min.h:32
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::min
sugar::Min< RTYPE, NA, T > min(const VectorBase< RTYPE, NA, T > &x)
Definition
min.h:82
Rcpp::as
T as(SEXP x)
Definition
as.h:151
Rcpp::traits::storage_type::type
SEXP type
Definition
storage_type.h:36
inst
include
Rcpp
sugar
functions
min.h
Generated on Sun Jan 12 2025 11:21:43 for Rcpp Version 1.0.14 by
1.9.8