Rcpp Version 1.0.14
Loading...
Searching...
No Matches
outer.h
Go to the documentation of this file.
1
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2
//
3
// outer.h: Rcpp R/C++ interface class library -- outer
4
//
5
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
6
//
7
// This file is part of Rcpp.
8
//
9
// Rcpp is free software: you can redistribute it and/or modify it
10
// under the terms of the GNU General Public License as published by
11
// the Free Software Foundation, either version 2 of the License, or
12
// (at your option) any later version.
13
//
14
// Rcpp is distributed in the hope that it will be useful, but
15
// WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
18
//
19
// You should have received a copy of the GNU General Public License
20
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21
22
#ifndef Rcpp__sugar__outer_h
23
#define Rcpp__sugar__outer_h
24
25
namespace
Rcpp
{
26
namespace
sugar{
27
28
template
<
int
RTYPE,
29
bool
LHS_NA
,
typename
LHS_T
,
30
bool
RHS_NA
,
typename
RHS_T
,
31
typename
Function
>
32
class
Outer
:
public
MatrixBase
<
33
Rcpp::traits::r_sexptype_traits<
34
typename ::Rcpp::traits::result_of<Function>::type
35
>::rtype ,
36
true ,
37
Outer<RTYPE,LHS_NA,LHS_T,RHS_NA,RHS_T,Function>
38
> {
39
public
:
40
typedef
typename ::Rcpp::traits::result_of<Function>::type
result_type
;
41
const
static
int
RESULT_R_TYPE
=
42
Rcpp::traits::r_sexptype_traits<result_type>::rtype
;
43
44
typedef
Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>
LHS_TYPE
;
45
typedef
Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
RHS_TYPE
;
46
47
typedef
Rcpp::internal::LazyVector<LHS_TYPE>
LHS_LAZY
;
48
typedef
Rcpp::internal::LazyVector<RHS_TYPE>
RHS_LAZY
;
49
50
typedef
typename
Rcpp::traits::r_vector_element_converter<RESULT_R_TYPE>::type
converter_type
;
51
typedef
typename
Rcpp::traits::storage_type<RESULT_R_TYPE>::type
STORAGE
;
52
53
Outer
(
const
LHS_TYPE
&
lhs_
,
const
RHS_TYPE
&
rhs_
,
Function
fun_
) :
54
lhs
(
lhs_
),
rhs
(
rhs_
),
fun
(
fun_
),
nr
(
lhs_
.
size
()),
nc
(
rhs_
.
size
()) {}
55
56
inline
STORAGE
operator()
(
int
i,
int
j )
const
{
57
return
converter_type::get
(
fun
(
lhs
[i],
rhs
[j] ) );
58
}
59
60
inline
R_xlen_t
size
()
const
{
return
static_cast<
R_xlen_t
>
(
nr
) *
nc
; }
61
inline
int
nrow
()
const
{
return
nr
; }
62
inline
int
ncol
()
const
{
return
nc
; }
63
64
private
:
65
66
LHS_LAZY
lhs
;
67
RHS_LAZY
rhs
;
68
69
Function
fun
;
70
int
nr
,
nc
;
71
} ;
72
73
}
// sugar
74
75
template
<
int
RTYPE,
76
bool
LHS_NA
,
typename
LHS_T
,
77
bool
RHS_NA
,
typename
RHS_T
,
78
typename
Function
>
79
inline
sugar::Outer<RTYPE,LHS_NA,LHS_T,RHS_NA,RHS_T,Function>
80
outer
(
81
const
Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>
& lhs,
82
const
Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
& rhs,
83
Function
fun ){
84
85
return
sugar::Outer<RTYPE,LHS_NA,LHS_T,RHS_NA,RHS_T,Function>
( lhs, rhs, fun ) ;
86
}
87
88
}
// Rcpp
89
90
#endif
Rcpp::MatrixBase
Definition
MatrixBase.h:32
Rcpp::VectorBase
Definition
VectorBase.h:29
Rcpp::internal::LazyVector
Definition
LazyVector.h:29
Rcpp::internal::element_converter
Definition
converter.h:28
Rcpp::internal::element_converter::get
static target get(const T &input)
Definition
converter.h:33
Rcpp::sugar::Outer
Definition
outer.h:38
Rcpp::sugar::Outer::nc
int nc
Definition
outer.h:70
Rcpp::sugar::Outer::lhs
LHS_LAZY lhs
Definition
outer.h:66
Rcpp::sugar::Outer::result_type
::Rcpp::traits::result_of< Function >::type result_type
Definition
outer.h:40
Rcpp::sugar::Outer::fun
Function fun
Definition
outer.h:69
Rcpp::sugar::Outer::LHS_TYPE
Rcpp::VectorBase< RTYPE, LHS_NA, LHS_T > LHS_TYPE
Definition
outer.h:44
Rcpp::sugar::Outer::operator()
STORAGE operator()(int i, int j) const
Definition
outer.h:56
Rcpp::sugar::Outer::converter_type
Rcpp::traits::r_vector_element_converter< RESULT_R_TYPE >::type converter_type
Definition
outer.h:50
Rcpp::sugar::Outer::STORAGE
Rcpp::traits::storage_type< RESULT_R_TYPE >::type STORAGE
Definition
outer.h:51
Rcpp::sugar::Outer::Outer
Outer(const LHS_TYPE &lhs_, const RHS_TYPE &rhs_, Function fun_)
Definition
outer.h:53
Rcpp::sugar::Outer::rhs
RHS_LAZY rhs
Definition
outer.h:67
Rcpp::sugar::Outer::ncol
int ncol() const
Definition
outer.h:62
Rcpp::sugar::Outer::nrow
int nrow() const
Definition
outer.h:61
Rcpp::sugar::Outer::RHS_LAZY
Rcpp::internal::LazyVector< RHS_TYPE > RHS_LAZY
Definition
outer.h:48
Rcpp::sugar::Outer::nr
int nr
Definition
outer.h:70
Rcpp::sugar::Outer::RESULT_R_TYPE
static const int RESULT_R_TYPE
Definition
outer.h:41
Rcpp::sugar::Outer::size
R_xlen_t size() const
Definition
outer.h:60
Rcpp::sugar::Outer::RHS_TYPE
Rcpp::VectorBase< RTYPE, RHS_NA, RHS_T > RHS_TYPE
Definition
outer.h:45
Rcpp::sugar::Outer::LHS_LAZY
Rcpp::internal::LazyVector< LHS_TYPE > LHS_LAZY
Definition
outer.h:47
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::Function
Function_Impl< PreserveStorage > Function
Definition
Function.h:131
Rcpp::outer
sugar::Outer< RTYPE, LHS_NA, LHS_T, RHS_NA, RHS_T, Function > outer(const Rcpp::VectorBase< RTYPE, LHS_NA, LHS_T > &lhs, const Rcpp::VectorBase< RTYPE, RHS_NA, RHS_T > &rhs, Function fun)
Definition
outer.h:80
Rcpp::as
T as(SEXP x)
Definition
as.h:151
Rcpp::traits::r_sexptype_traits
Definition
r_sexptype_traits.h:33
Rcpp::traits::storage_type::type
SEXP type
Definition
storage_type.h:36
inst
include
Rcpp
sugar
matrix
outer.h
Generated on Sun Jan 12 2025 11:21:43 for Rcpp Version 1.0.14 by
1.9.8