Created
February 15, 2017 17:22
-
-
Save 8q/c40d58b00304ff207dd8651c3c0f2d2d to your computer and use it in GitHub Desktop.
R lang test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xmin <- -2 | |
xmax <- 2 | |
ymin <- -2 | |
ymax <- 2 | |
size <- 1000 #点の数はsize*size | |
n <- 100 #発散判定の試行回数 | |
X <- matrix(rep(seq(xmin, xmax, length=size), times=size), nrow=size) | |
Y <- matrix(rep(seq(xmin, xmax, length=size), times=size), nrow=size, byrow=TRUE) | |
C <- X + 1i * Y | |
Z <- matrix(rep(numeric(size), times=size), nrow = size) | |
Res <- matrix(rep(numeric(size), times=size), nrow = size) | |
for(i in 1:n) { | |
Z = Z^2 + C | |
mask = abs(Z) > 2 | |
Z[mask] <- C[mask] <- 0 + 0i | |
Res[mask] <- i | |
print(i) | |
} | |
image(Res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment