22 #ifndef Rcpp__sugar__diag_h
23 #define Rcpp__sugar__diag_h
28 template <
int RTYPE,
bool NA,
typename T>
35 int nr =
object.nrow() ;
36 int nc =
object.ncol() ;
37 n = (nc < nr ) ? nc : nr ;
43 inline R_xlen_t
size()
const {
return n; }
51 template <
int RTYPE,
bool NA,
typename T>
60 return (i==j) ?
object[i] : 0 ;
62 inline R_xlen_t
size()
const {
return static_cast<R_xlen_t
>(
n) *
n; }
63 inline int ncol()
const {
return n; }
64 inline int nrow()
const {
return n; }
Rcpp::traits::storage_type< RTYPE >::type STORAGE
STORAGE operator()(int i, int j) const
Rcpp::VectorBase< RTYPE, NA, T > VEC_TYPE
Diag_Maker(const VEC_TYPE &object_)
sugar::diag_result_type_trait< T >::type diag(const T &t)
Rcpp::traits::if_< Rcpp::traits::matrix_interface< T >::value, Diag_Extractor< T::r_type::value, T::can_have_na::value, T >, Diag_Maker< T::r_type::value, T::can_have_na::value, T > >::type type