[Rcpp-commits] r942 - pkg/Rcpp/src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Mar 26 06:05:34 CET 2010
Author: romain
Date: 2010-03-26 06:05:34 +0100 (Fri, 26 Mar 2010)
New Revision: 942
Modified:
pkg/Rcpp/src/Rcpp/Vector.h
Log:
fix bug in Matrix::diag (was using the number of elements instead of the number of columns)
Modified: pkg/Rcpp/src/Rcpp/Vector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/Vector.h 2010-03-23 16:10:26 UTC (rev 941)
+++ pkg/Rcpp/src/Rcpp/Vector.h 2010-03-26 05:05:34 UTC (rev 942)
@@ -2308,11 +2308,12 @@
template <typename U>
void fill_diag__dispatch( traits::false_type, const U& u){
SEXP elem = PROTECT( converter_type::get( u ) ) ;
- int n = Matrix::size() ;
+ int n = Matrix::ncol() ;
+ int offset = n +1 ;
iterator it( Matrix::begin()) ;
for( int i=0; i<n; i++){
*it = ::Rf_duplicate( elem );
- it += ( n + 1 );
+ it += offset;
}
UNPROTECT(1); // elem
}
@@ -2320,11 +2321,12 @@
template <typename U>
void fill_diag__dispatch( traits::true_type, const U& u){
stored_type elem = converter_type::get( u ) ;
- int n = Matrix::size() ;
+ int n = Matrix::ncol() ;
+ int offset = n + 1 ;
iterator it( Matrix::begin()) ;
for( int i=0; i<n; i++){
*it = elem ;
- it += ( n + 1 );
+ it += offset;
}
}
More information about the Rcpp-commits
mailing list