Rcpp_matrix_vect_sum
C++ Function Reference
1 Signature
Rcpp::RObject BigDataStatMeth::Rcpp_matrix_vect_sum(T A, U B)2 Parameters
A(T)B(U)
3 Returns
Type: typename T
4 Source Code
NoteImplementation
File: inst/include/memAlgebra/memSum.hpp • Lines 121-150
inline Rcpp::RObject Rcpp_matrix_vect_sum ( T A, U B)
{
Rcpp::NumericMatrix m = Rcpp::as<Rcpp::NumericMatrix>(A);
Rcpp::NumericVector v = Rcpp::as<Rcpp::NumericVector>(B);
if( v.length() == m.rows()) {
Rcpp::NumericMatrix C = Rcpp::no_init( m.rows(), m.cols());
for( int i=0; i<m.cols(); i++) {
C( Rcpp::_, i) = m( Rcpp::_, i) + v;
}
return(C);
} else if( v.length() == m.cols()) {
Rcpp::NumericMatrix C = Rcpp::no_init( m.rows(), m.cols());
for( int i=0; i<m.rows(); i++) {
C( i, Rcpp::_) = m( i, Rcpp::_) + v;
}
return(C);
} else {
Rcpp::Rcout<<"Error: non-conformable arguments";
}
return(R_NilValue);
}5 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = Rcpp_matrix_vect_sum(...);