progs/mandelbrot.scala
changeset 309 b192bc772613
parent 266 ca48ac1d3c3e
child 329 8a34b2ebc8cc
--- a/progs/mandelbrot.scala	Sun Nov 03 14:42:17 2019 +0000
+++ b/progs/mandelbrot.scala	Mon Nov 04 00:51:10 2019 +0000
@@ -1,9 +1,11 @@
 // Mandelbrot pictures
+//=====================
 //
 //   see https://en.wikipedia.org/wiki/Mandelbrot_set
 // 
-// under scala 2.13 needs to be called with 
-// scala -cp `coursier fetch -p org.scala-lang.modules:scala-parallel-collections_2.13:0.2.0` mandelbrot.scala
+// under scala 2.13.1 needs to be called with
+// 
+// scala -cp scala-parallel-collections_2.13-0.2.0.jar mandelbrot.scala
 
 import java.awt.Color
 import java.awt.Dimension
@@ -102,8 +104,8 @@
   val d_x = (end.re - start.re) / W
   val d_y = (end.im - start.im) / H
    
-  for (y <- (0 until H).par) {
-    for (x <- (0 until W).par) {
+  for (y <- (0 until H)) {
+    for (x <- (0 until W)) {
     
      val c = start + 
       (x * d_x + y * d_y * i)
@@ -135,7 +137,7 @@
 val exa1 = -2.0 + -1.5 * i
 val exa2 =  1.0 +  1.5 * i
 
-time_needed(mandelbrot(exa1, exa2, 1000))
+println(s"${time_needed(mandelbrot(exa1, exa2, 1000))} secs")
 
 // example 2
 val exb1 = -0.37465401 + 0.659227668 * i
@@ -156,25 +158,19 @@
 val delta = (exc2 - exc1) * 0.0333
 
 /*
-time_needed(
+println(s"${time_needed(
   for (n <- (0 to 12)) 
      mandelbrot(exc1 + delta * n, 
-                exc2 - delta * n, 100)) 
+                exc2 - delta * n, 100))} secs") 
 */
 
-/*
-time_needed(
-  for (n <- (0 to 12)) 
-     mandelbrot(exc1 + delta * n, 
-                exc2 - delta * n, 1000))
-*/
 
 
 // Larry Paulson's example
 val exl1 = -0.74364990 + 0.13188170 * i
 val exl2 = -0.74291189 + 0.13261971 * i
 
-//time_needed(mandelbrot(exl1, exl2, 1000))
+//println(s"${time_needed(mandelbrot(exl1, exl2, 1000))} secs")
 
 
 // example by Jorgen Villadsen