progs/mandelbrot.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 09 Nov 2020 14:36:35 +0000
changeset 358 542d2cf143b0
parent 354 4b347b6e134f
child 394 839ad118e467
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
187
4d300409f2fe updated
Christian Urban <urbanc@in.tum.de>
parents: 186
diff changeset
     1
// Mandelbrot pictures
309
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
     2
//=====================
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
     3
//
187
4d300409f2fe updated
Christian Urban <urbanc@in.tum.de>
parents: 186
diff changeset
     4
//   see https://en.wikipedia.org/wiki/Mandelbrot_set
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
     5
// 
309
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
     6
// under scala 2.13.1 needs to be called with
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
     7
// 
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
     8
// scala -cp scala-parallel-collections_2.13-0.2.0.jar mandelbrot.scala
187
4d300409f2fe updated
Christian Urban <urbanc@in.tum.de>
parents: 186
diff changeset
     9
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
import java.awt.Color
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
import java.awt.Dimension
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
import java.awt.Graphics
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
import java.awt.Graphics2D
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
import java.awt.image.BufferedImage
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
import javax.swing.JFrame
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
import javax.swing.JPanel
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
import javax.swing.WindowConstants
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    18
import scala.language.implicitConversions    
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    19
import scala.collection.parallel.CollectionConverters._
265
59779ce322a6 updated
Christian Urban <urbanc@in.tum.de>
parents: 195
diff changeset
    20
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
// complex numbers
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    22
case class Complex(val re: Double, val im: Double) { 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    23
  // represents the complex number re + im * i
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    24
  def +(that: Complex) = Complex(this.re + that.re, this.im + that.im)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    25
  def -(that: Complex) = Complex(this.re - that.re, this.im - that.im)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    26
  def *(that: Complex) = Complex(this.re * that.re - this.im * that.im,
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    27
                                 this.re * that.im + that.re * this.im)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    28
  def *(that: Double) = Complex(this.re * that, this.im * that)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    29
  def abs() = Math.sqrt(this.re * this.re + this.im * this.im)
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
}
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
187
4d300409f2fe updated
Christian Urban <urbanc@in.tum.de>
parents: 186
diff changeset
    32
// to allow the notation n + m * i
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    33
object i extends Complex(0, 1)
187
4d300409f2fe updated
Christian Urban <urbanc@in.tum.de>
parents: 186
diff changeset
    34
implicit def double2complex(re: Double) = Complex(re, 0)
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    35
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    36
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    37
// some customn colours for the "sliding effect"
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
val colours = List(
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    39
  new Color(66, 30, 15),    new Color(25, 7, 26),
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    40
  new Color(9, 1, 47),      new Color(4, 4, 73),
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    41
  new Color(0, 7, 100),     new Color(12, 44, 138),
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    42
  new Color(24, 82, 177),   new Color(57, 125, 209),
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    43
  new Color(134, 181, 229), new Color(211, 236, 248),
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    44
  new Color(241, 233, 191), new Color(248, 201, 95),
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    45
  new Color(255, 170, 0),   new Color(204, 128, 0),
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    46
  new Color(153, 87, 0),    new Color(106, 52, 3))
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    48
// the viewer panel with an image canvas
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
class Viewer(width: Int, height: Int) extends JPanel {
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    50
  val canvas = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    51
  
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    52
  override def paintComponent(g: Graphics) = 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    53
    g.asInstanceOf[Graphics2D].drawImage(canvas, null, null)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    54
  
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    55
  override def getPreferredSize() = 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    56
    new Dimension(width, height)
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    58
  def clearCanvas(color: Color) = {
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    59
    for (x <- 0 to width - 1; y <- 0 to height - 1) 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    60
      canvas.setRGB(x, y, color.getRGB())
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    61
    repaint()
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    62
  }  
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
}
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    65
// initialising the viewer panel
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    66
def openViewer(width: Int, height: Int) : Viewer = {
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    67
  val frame = new JFrame("XYPlane")
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    68
  val viewer = new Viewer(width, height)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    69
  frame.add(viewer)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    70
  frame.pack()
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    71
  frame.setVisible(true)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    72
  frame.setResizable(false)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    73
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    74
  viewer
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
}
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    77
// some hardcoded parameters
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    78
val W = 900   // width
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    79
val H = 800   // height
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
val black = Color.black
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
val viewer = openViewer(W, H)
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    83
// draw a pixel on the canvas
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
def pixel(x: Int, y: Int, color: Color) = 
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
  viewer.canvas.setRGB(x, y, color.getRGB())
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    86
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    88
// calculates the number of iterations using lazy lists (streams)
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    89
//   the iteration goes on for a maximum of max steps,
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    90
//   but might leave early when the pred is satisfied
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    91
def iterations(c: Complex, max: Int) : Int = {
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    92
  def next(z: Complex) = z * z + c    
353
bb6074814a73 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    93
  def pred(z: Complex) = z.abs() < 2    // exit condition
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    94
  LazyList.iterate(0.0 * i, max)(next).takeWhile(pred).size
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    95
}
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    96
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
    97
// main function 
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    98
//    start and end are the upper-left and lower-right corners, 
187
4d300409f2fe updated
Christian Urban <urbanc@in.tum.de>
parents: 186
diff changeset
    99
//    max is the number of maximum iterations
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   100
def mandelbrot(start: Complex, end: Complex, max: Int) : Unit = {
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
  viewer.clearCanvas(black)
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   102
  
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   103
  // deltas for each grid step 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   104
  val d_x = (end.re - start.re) / W
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   105
  val d_y = (end.im - start.im) / H
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
   
354
4b347b6e134f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 353
diff changeset
   107
  for (y <- (0 until H)) {
4b347b6e134f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 353
diff changeset
   108
    for (x <- (0 until W)) {
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
    
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   110
     val c = start + 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   111
      (x * d_x + y * d_y * i)
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   112
     val iters = iterations(c, max) 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   113
     val col = 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   114
       if (iters == max) black 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   115
       else colours(iters % 16)
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   117
     pixel(x, y, col)
143
11396c17cd8b updated
Christian Urban <urbanc@in.tum.de>
parents: 137
diff changeset
   118
    }
11396c17cd8b updated
Christian Urban <urbanc@in.tum.de>
parents: 137
diff changeset
   119
    viewer.updateUI()
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   120
  }   
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
}
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
187
4d300409f2fe updated
Christian Urban <urbanc@in.tum.de>
parents: 186
diff changeset
   123
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
// Examples
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
//==========
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
//for measuring time
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
def time_needed[T](code: => T) = {
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  val start = System.nanoTime()
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  code
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
  val end = System.nanoTime()
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  (end - start) / 1.0e9
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
}
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
353
bb6074814a73 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
   136
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
// example 1
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   138
val exa1 = -2.0 + -1.5 * i
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   139
val exa2 =  1.0 +  1.5 * i
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
309
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
   141
println(s"${time_needed(mandelbrot(exa1, exa2, 1000))} secs")
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
136
Christian Urban <urbanc@in.tum.de>
parents: 124
diff changeset
   143
// example 2
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   144
val exb1 = -0.37465401 + 0.659227668 * i
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   145
val exb2 = -0.37332410 + 0.66020767 * i
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   147
//time_needed(mandelbrot(exb1, exb2, 1000))
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
// example 3
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   150
val exc1 = 0.435396403 + 0.367981352 * i
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   151
val exc2 = 0.451687191 + 0.380210061 * i
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 143
diff changeset
   153
//time_needed(mandelbrot(exc1, exc2, 1000))
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
   155
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
   156
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
// some more computations with example 3
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   158
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
val delta = (exc2 - exc1) * 0.0333
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
309
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
   161
println(s"${time_needed(
186
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   162
  for (n <- (0 to 12)) 
f211d9cb856e updated
Christian Urban <urbanc@in.tum.de>
parents: 174
diff changeset
   163
     mandelbrot(exc1 + delta * n, 
309
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
   164
                exc2 - delta * n, 100))} secs") 
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
   165
124
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
c45d3cd9a749 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
191
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   168
// Larry Paulson's example
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   169
val exl1 = -0.74364990 + 0.13188170 * i
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   170
val exl2 = -0.74291189 + 0.13261971 * i
189
ff815ca0bbcf updated
Christian Urban <urbanc@in.tum.de>
parents: 187
diff changeset
   171
309
b192bc772613 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
   172
//println(s"${time_needed(mandelbrot(exl1, exl2, 1000))} secs")
189
ff815ca0bbcf updated
Christian Urban <urbanc@in.tum.de>
parents: 187
diff changeset
   173
191
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   174
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   175
// example by Jorgen Villadsen
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   176
val exj1 = 0.10284 - 0.63275 * i
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   177
val exj2 = 0.11084 - 0.64075 * i
f78b18c4c886 updated
Christian Urban <urbanc@in.tum.de>
parents: 189
diff changeset
   178
195
fc3ac7b70a06 updated
Christian Urban <urbanc@in.tum.de>
parents: 191
diff changeset
   179
//time_needed(mandelbrot(exj1, exj2, 1000))