## Not run: ------------------------------------
# M = 200
# bistable = '
# laplace4(x, dxdt, D); // parallel 4-point discrete laplacian
# #pragma omp parallel for
# for (int i = 0; i < N; ++i)
# dxdt[i] += a * x[i] * (1 - x[i]) * (x[i] - b);
# ' # bistable
# compile_sys_openmp("bistable", bistable, sys_dim = M * M,
# pars = c(D = 0.1, a = 1.0, b = 1/2),
# const = TRUE)
# at = 10 ^ (0:3)
# inic = rbinom(M * M, 1, 1/2)
# system.time({x = bistable_at(inic, at)})
# par(mfrow = rep(2, 2), mar = rep(1, 4), oma = rep(1, 4))
# for (i in 1:4){
# image(matrix(unlist(x[i, -1]), M, M),
# asp = 1, col = c("black", "lightgray"),
# axes = FALSE)
# title(main=paste("Time =", x[i, 1]))}
## ---------------------------------------------
Run the code above in your browser using DataLab