-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsd.h
More file actions
32 lines (23 loc) · 786 Bytes
/
sd.h
File metadata and controls
32 lines (23 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef Rcpp__sugar__sd_h
#define Rcpp__sugar__sd_h
namespace Rcpp{
namespace sugar{
template <int RTYPE, bool NA, typename T>
class Sd : public Lazy< typename Rcpp::traits::storage_type<RTYPE>::type , Sd<RTYPE,NA,T> > {
public:
typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
Sd( const VEC_TYPE& object_ ) : object(object_){}
STORAGE get() const {
return ::sqrt( var(object).get() ) ;
}
private:
const VEC_TYPE& object ;
} ;
} // sugar
template <bool NA, typename T>
inline sugar::Sd<REALSXP,NA,T> sd( const VectorBase<REALSXP,NA,T>& t){
return sugar::Sd<REALSXP,NA,T>( t ) ;
}
} // Rcpp
#endif