; MANDL
;---------------------------------------------------------------
;! creates an image of a subset of the Mandlebrot Set
;# Task Imaging
;-----------------------------------------------------------------------
;;  Copyright (C) 1995
;;  Associated Universities, Inc. Washington DC, USA.
;;
;;  This program is free software; you can redistribute it and/or
;;  modify it under the terms of the GNU General Public License as
;;  published by the Free Software Foundation; either version 2 of
;;  the License, or (at your option) any later version.
;;
;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU General Public License for more details.
;;
;;  You should have received a copy of the GNU General Public
;;  License along with this program; if not, write to the Free
;;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
;;  MA 02139, USA.
;;
;;  Correspondence concerning AIPS should be addressed as follows:
;;         Internet email: aipsmail@nrao.edu.
;;         Postal address: AIPS Project Office
;;                         National Radio Astronomy Observatory
;;                         520 Edgemont Road
;;                         Charlottesville, VA 22903-2475 USA
;-----------------------------------------------------------------------
;---------------------------------------------------------------
MANDL     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
MANDL     Create a sub-section of the MANDLEBROT Set
OBJECT                             Source name
IMSIZE                             Output image size (cells)
CELLSIZE                           Cellsize (0=Fill X-Y Range)
OUTNAME                            Output image name (name)
OUTCLASS                           Output image name (class)
OUTSEQ           -1.0     9999.0   Output image name (seq. #)
OUTDISK           0.0        9.0   Output image disk unit #.
CPARM                              Set Region selection,
                                   1:XMin;2:YMin;3:XMax;4:YMax
                                   5:Max Value for Set (0=> 256)
----------------------------------------------------------------
MANDL
Task:  Mandelbrot set capability for AIPS.  Can make an image as
       large as is desired, but is limited by the dynamic range
       of floating point numbers.
Note:  Setting all numeric parameters to zero causes the whole
       set to be calculated.
       Glen Langstion, MPIfR and MIT, October 1987
Adverbs:
  OBJECT.....Object name.
  IMSIZE.....Desired image size in cells.
  CELLSIZE...Desired cell spacing, currently assumes sec.
             The mandelbrot set is only interesting in the -2
             to 1 range in x and -1 to 1 in y, so for a 256x256
             image, 0.012 gives the whole region.  For
             CELLSIZE=0, the X and Y min and max are used to
             calculate the CELLSIZE.
  OUTNAME....Output image name (name).     Standard behavior
             with default = 'MANDELBRO'.
  OUTCLASS...Output image name (class).    Standard defaults.
  OUTSEQ.....Output image name (seq. #).   0 => highest unique.
  OUTDISK....Disk drive # of output image. 0 => highest number
             with sufficient space.
  CPARM......1:XMin, 2:YMin, 3:XMax, 4:YMax
             Used in combination with cells to calculate the map
             center and scale
----------------------------------------------------------------
MANDL:  Task which creates and fills an AIPS catalogue image
        file with a section of the Mandelbrot Set.
DOCUMENTOR: Glen Langston, MPIfR and MIT

                          PURPOSE

     MANDL is designed as a thought provoking display of a very
simple mathmatical function.  The algorthym is a very simple
recursive calculation, using the initial coordinate of the
point at each set of the calculation.

     The algorithm is as follows:
       For each point, (x,y), in the desired section of the
       plane, calculate the complex square of this point.
         If the magnitude is greater than 2, stop at this
         iteration.
         If it is not, add the inital x,y coordinate and
         repeat until tired. (Here 256)

      In Coded Form:
         z1 = 0
         z2 = 0
         FOR I = 1 to 256
           z1 = z1 + x
           z2 = z2 + y
           znext1 = z1*z1 - z2*z2
           z2 = 2*z1*z2
           z1 = znext1
           zmag = sqrt(z1*z1+z2*z2)
           if (zmag .gt. 2) return i
         ENDDO
         return i
