Skip to content

Commit b94441b

Browse files
author
Qiang Kou
committed
sugar matrix
1 parent c4a9b16 commit b94441b

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

inst/include/Rcpp/sugar/logical/and.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ class And_LogicalExpression_LogicalExpression : public Rcpp::VectorBase< LGLSXP,
209209

210210
And_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
211211

212-
inline int operator[]( int i ) const{
212+
inline int operator[]( R_xlen_t i ) const{
213213
if( lhs[i] == TRUE && rhs[i] == TRUE ) return TRUE ;
214214
if( lhs[i] == NA_LOGICAL || rhs[i] == NA_LOGICAL ) return NA_LOGICAL ;
215215
return FALSE ;
216216
}
217-
inline int size() const { return lhs.size(); }
217+
inline R_xlen_t size() const { return lhs.size(); }
218218

219219
private:
220220
const LHS_TYPE& lhs ;
@@ -229,12 +229,12 @@ class And_LogicalExpression_LogicalExpression<false,LHS_T,RHS_NA,RHS_T>
229229

230230
And_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
231231

232-
inline int operator[]( int i ) const{
232+
inline int operator[]( R_xlen_t i ) const{
233233
if( lhs[i] == TRUE && rhs[i] == TRUE ) return TRUE ;
234234
if( rhs[i] == NA_LOGICAL ) return NA_LOGICAL ;
235235
return FALSE ;
236236
}
237-
inline int size() const { return lhs.size(); }
237+
inline R_xlen_t size() const { return lhs.size(); }
238238

239239
private:
240240
const LHS_TYPE& lhs ;
@@ -249,12 +249,12 @@ class And_LogicalExpression_LogicalExpression<LHS_NA,LHS_T,false,RHS_T>
249249

250250
And_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
251251

252-
inline int operator[]( int i ) const{
252+
inline int operator[]( R_xlen_t i ) const{
253253
if( lhs[i] == TRUE && rhs[i] == TRUE ) return TRUE ;
254254
if( lhs[i] == NA_LOGICAL ) return NA_LOGICAL ;
255255
return FALSE;
256256
}
257-
inline int size() const { return lhs.size(); }
257+
inline R_xlen_t size() const { return lhs.size(); }
258258

259259
private:
260260
const LHS_TYPE& lhs ;
@@ -269,11 +269,11 @@ class And_LogicalExpression_LogicalExpression<false,LHS_T,false,RHS_T>
269269

270270
And_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
271271

272-
inline int operator[]( int i ) const{
272+
inline int operator[]( R_xlen_t i ) const{
273273
if( lhs[i] == TRUE && rhs[i] == TRUE ) return TRUE ;
274274
return FALSE;
275275
}
276-
inline int size() const { return lhs.size(); }
276+
inline R_xlen_t size() const { return lhs.size(); }
277277

278278
private:
279279
const LHS_TYPE& lhs ;

inst/include/Rcpp/sugar/logical/or.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ class Or_LogicalExpression_LogicalExpression : public Rcpp::VectorBase< LGLSXP,
206206

207207
Or_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
208208

209-
inline int operator[]( int i ) const{
209+
inline int operator[]( R_xlen_t i ) const{
210210
if( lhs[i] == TRUE || rhs[i] == TRUE ) return TRUE ;
211211
if( lhs[i] == FALSE && rhs[i] == FALSE ) return FALSE ;
212212
return NA_LOGICAL;
213213
}
214-
inline int size() const { return lhs.size(); }
214+
inline R_xlen_t size() const { return lhs.size(); }
215215

216216
private:
217217
const LHS_TYPE& lhs ;
@@ -226,12 +226,12 @@ class Or_LogicalExpression_LogicalExpression<false,LHS_T,RHS_NA,RHS_T>
226226

227227
Or_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
228228

229-
inline int operator[]( int i ) const{
229+
inline int operator[]( R_xlen_t i ) const{
230230
if( lhs[i] == TRUE || rhs[i] == TRUE ) return TRUE ;
231231
if( rhs[i] == NA_LOGICAL ) return NA_LOGICAL ;
232232
return FALSE ;
233233
}
234-
inline int size() const { return lhs.size(); }
234+
inline R_xlen_t size() const { return lhs.size(); }
235235

236236
private:
237237
const LHS_TYPE& lhs ;
@@ -246,12 +246,12 @@ class Or_LogicalExpression_LogicalExpression<LHS_NA,LHS_T,false,RHS_T>
246246

247247
Or_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
248248

249-
inline int operator[]( int i ) const{
249+
inline int operator[]( R_xlen_t i ) const{
250250
if( lhs[i] == TRUE || rhs[i] == TRUE ) return TRUE ;
251251
if( lhs[i] == NA_LOGICAL ) return NA_LOGICAL ;
252252
return FALSE;
253253
}
254-
inline int size() const { return lhs.size(); }
254+
inline R_xlen_t size() const { return lhs.size(); }
255255

256256
private:
257257
const LHS_TYPE& lhs ;
@@ -266,11 +266,11 @@ class Or_LogicalExpression_LogicalExpression<false,LHS_T,false,RHS_T>
266266

267267
Or_LogicalExpression_LogicalExpression( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : lhs(lhs_), rhs(rhs_){}
268268

269-
inline int operator[]( int i ) const{
269+
inline int operator[]( R_xlen_t i ) const{
270270
if( lhs[i] == TRUE || rhs[i] == TRUE ) return TRUE ;
271271
return FALSE;
272272
}
273-
inline int size() const { return lhs.size(); }
273+
inline R_xlen_t size() const { return lhs.size(); }
274274

275275
private:
276276
const LHS_TYPE& lhs ;

inst/include/Rcpp/sugar/matrix/as_vector.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ template <int RTYPE, bool NA, typename T>
2929
inline Rcpp::Vector<RTYPE>
3030
as_vector__impl( MatrixBase<RTYPE,NA,T>& t, Rcpp::traits::false_type ){
3131
T& ref = t.get_ref() ;
32-
int nc = ref.ncol(), nr = ref.nrow() ;
32+
R_xlen_t nc = ref.ncol(), nr = ref.nrow() ;
3333
Vector<RTYPE> out (nr*nc) ;
34-
int k =0;
35-
for( int col_index=0; col_index<nc; col_index++)
36-
for( int row_index=0; row_index<nr; row_index++, k++)
34+
R_xlen_t k =0;
35+
for( R_xlen_t col_index=0; col_index<nc; col_index++)
36+
for( R_xlen_t row_index=0; row_index<nr; row_index++, k++)
3737
out[k] = ref( row_index, col_index ) ;
3838

3939
return out ;
@@ -43,7 +43,7 @@ template <int RTYPE, bool NA, typename T>
4343
inline Rcpp::Vector<RTYPE>
4444
as_vector__impl( MatrixBase<RTYPE,NA,T>& t, Rcpp::traits::true_type ){
4545
Matrix<RTYPE>& ref = t.get_ref() ;
46-
int size = ref.ncol()*ref.nrow() ;
46+
R_xlen_t size = ref.ncol()*ref.nrow() ;
4747
typename Rcpp::Vector<RTYPE>::const_iterator first(static_cast<const Rcpp::Vector<RTYPE>&>(ref).begin()) ;
4848
return Vector<RTYPE>(first, first+size );
4949
}

inst/include/Rcpp/sugar/matrix/col.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Col : public MatrixBase<
4040
return j + 1 ;
4141
}
4242

43-
inline int size() const { return nr * nc ; }
43+
inline R_xlen_t size() const { return nr * nc ; }
4444
inline int nrow() const { return nr; }
4545
inline int ncol() const { return nc; }
4646

inst/include/Rcpp/sugar/matrix/diag.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class Diag_Extractor : public Rcpp::VectorBase< RTYPE ,NA, Diag_Extractor<RTYPE,
4040
inline STORAGE operator[]( int i ) const {
4141
return object( i, i ) ;
4242
}
43-
inline int size() const { return n; }
43+
inline R_xlen_t size() const { return n; }
4444

4545
private:
4646
const MAT_TYPE& object ;
47-
int n ;
47+
R_xlen_t n ;
4848
} ;
4949

5050

inst/include/Rcpp/sugar/matrix/lower_tri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class LowerTri : public VectorBase<
4747
return get(i,j) ;
4848
}
4949

50-
inline int size() const { return nr * nc ; }
50+
inline R_xlen_t size() const { return nr * nc ; }
5151
inline int nrow() const { return nr; }
5252
inline int ncol() const { return nc; }
5353

inst/include/Rcpp/sugar/matrix/outer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Outer : public MatrixBase<
5757
return converter_type::get( fun( lhs[i], rhs[j] ) );
5858
}
5959

60-
inline int size() const { return nr * nc ; }
60+
inline R_xlen_t size() const { return nr * nc ; }
6161
inline int nrow() const { return nr; }
6262
inline int ncol() const { return nc; }
6363

inst/include/Rcpp/sugar/matrix/row.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Row : public MatrixBase<
4040
return i + 1 ;
4141
}
4242

43-
inline int size() const { return nr * nc ; }
43+
inline R_xlen_t size() const { return nr * nc ; }
4444
inline int nrow() const { return nr; }
4545
inline int ncol() const { return nc; }
4646

inst/include/Rcpp/sugar/matrix/upper_tri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class UpperTri : public VectorBase<
4242
return get(i,j) ;
4343
}
4444

45-
inline int size() const { return nr * nc ; }
45+
inline R_xlen_t size() const { return nr * nc ; }
4646
inline int nrow() const { return nr; }
4747
inline int ncol() const { return nc; }
4848

0 commit comments

Comments
 (0)