Skip to content

Parallel computing: comparison and update #94

Answered by rstub
option72 asked this question in Q&A
Discussion options

You must be logged in to vote

It is pretty straightforward to adapt the first example, since it already generates a matrix:

#include <Rcpp.h>
// [[Rcpp::depends(dqrng, BH)]]
#include <dqrng_distribution.h>
// [[Rcpp::depends(RcppParallel)]]
#include <RcppParallel.h>

struct RandomFill : public RcppParallel::Worker {
  RcppParallel::RMatrix<double> output;
  uint64_t seed;
  double min;
  double max;

  RandomFill(Rcpp::NumericMatrix output,
             const uint64_t seed,
             const double min = 0.0,
             const double max = 1.0) : output(output), seed(seed), min(min), max(max) {};

  void operator()(std::size_t begin, std::size_t end) {
    auto rng = dqrng::generator<>(seed, end);
    for (std::size_t

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rstub
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #92 on January 04, 2025 15:06.