Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <RcppArmadillo.h>
  2. // [[Rcpp::depends(RcppArmadillo)]]
  3. // [[Rcpp::export]]
  4. arma::mat foo(arma::mat A, arma::uword block_start, arma::uword block_length) {
  5. arma::uword rows = A.n_rows;
  6. arma::mat B = arma::mat(A.begin_col(block_start), rows, block_length, false);
  7. B.fill(1.0);
  8. return A;
  9. }
  10.  
  11. /*** R
  12. A <- matrix(0, 4, 4)
  13. foo(A, 0, 2)
  14. > A <- matrix(0, 4, 4)
  15. > foo(A, 0, 2)
  16. [,1] [,2] [,3] [,4]
  17. [1,] 1 1 0 0
  18. [2,] 1 1 0 0
  19. [3,] 1 1 0 0
  20. [4,] 1 1 0 0
  21. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement