dpalahn@guido.uucp (Donald Palahnuk) (07/06/89)
Sorry to have to repost this in this news group but E-Mail has been bouncing as usual, ATTENTION JERRY LEE :: HERE IS THE CODE YOU REQUESTED. Included is addended code that allows variable view size ! notes: this computation produces the Julia Set of Lambda*ComplexCosine(Z) the algorithm was developed from RL Devaney's Hubbard Alg apprch. super major godlike disclaimer:::: works on a SUN 4/110, don't ask me what else, period!!! Although I would love any theory questions on the alg, I'm a mathematician and chemical eng'r not a comp sci'tist. However, what I am aware of is that this code may only be SUN4 compatible??? see further notes below, donnie IMPORTANT NOTE: you must extract the following code from this file. Following are three sets of code which all must be extracted. 1. go_var: gofile to comp, link and exe. 2. c_var.c: graphics source code 3. c_var.F: computational source code. (note CAP F extension required for CC precompilation! ) notes: choose 75 for the starting array size to see if it works for speed lambda is the funky parameter: change it to change the image 1. go_var echo comp f77 c_var f77 -c c_var.F -o cf_var.o echo comp cc c_var cc c_var.c cf_var.o -o cfor_var -lpixrect -lsunwindow -lsuntool -lm -lF77 -lI77 -lU77 echo execute cfor_var cfor_var notes: The library extensions -lF77 -lI77 -lU77 are optional (I think) and are only required if you require i/o from the fortran subroutine level and don't want the infamous core dump. The file.F for f77 should be used for speed and optimization. 2. c_var.c # include <suntool/sunview.h> # include <suntool/canvas.h> # include <stdio.h> # include <math.h> #include <sunwindow/cms_rgb.h> #define CMS_SIZE 64 /* graphics routine for donnie's fractal image prog */ u_char red[64] = { 0,100,130,200,225,255,255,255,255,255,255, /* 11*/ 255,255,255,255,255,255,255,240,223,193,168,140,120,100, 45, 10, /* 27*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 43*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 96,114,135,150,168,193, /* 59*/ 218,255,255,255,255}; u_char blue[64] = { 0, 0, 0, 0, 0, 0, 60, 90,100,120,138, /* 11*/ 151,168,193,215,230,245,255,255,255,255,255,255,255,255,255,255, /* 27*/ 255,255,255,255,255,255,255,255,255,255,255,255,255,243,229,205, /* 43*/ 189,175,161,139,122,105, 69, 35, 0, 0, 0, 0, 0, 0, 0, 0, /* 59*/ 0, 0,173,233,255}; u_char green[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 11*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 27*/ 0, 50, 95,120,145,160,175,191,205,218,231,241,255,255,255,255, /* 43*/ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, /* 59*/ 255,255,255,255,255}; main() { /* graphics attributes variabke declerations */ Frame frame; Canvas canvas; register Pixwin *pw; int i,j,quib; int flag[500][500]; int tag; printf("enter array dimension\n"); scanf("%d",&quib); printf("%d\n",quib); /* create canvas and frame */ frame=window_create(NULL,FRAME,0); canvas=window_create(frame,CANVAS,0); pw=canvas_pixwin(canvas); /* initilize a roy-gee-biv */ /* send info to pixwindow */ pw_setcmsname(pw,"showcolor"); pw_putcolormap(pw,0,CMS_SIZE,red,blue,green); /* get information for plotting */ /* note that the transfer below are pointed addresses ! */ res_(flag,&quib); /* send information to window */ for(i=0;i<=quib-2;++i){ for(j=0;j<=quib-2;++j){ pw_rop(pw,i+10,j+10,1,1,PIX_SRC | PIX_COLOR(flag[i][j]*2), (Pixrect *)0,0,0); }} window_main_loop(frame); exit(0); } notes: VERY IMPORTANT (or fairly anyway), transfer of variables to fortran code must be pointed addresses ! Look @ res_(flag,&quib) ! Secondly the program has an upper limit of 500X500 pixels, this may need to be reduced if you run into memory problems. To make an image larger the computation would need to be done in segments. 3. c_var.F c Complex Plane Iterative Routine c As Per R. Devaney and the Hubbard Algorithm function res(flag,quib) c give it a try integer i,j,k,flag(500,500),quib real bound complex z complex*16 zt real im,Pi real lambda Pi=3.141592654 bound=quib/2.0 lambda=2.94 do i=1,quib do j=1,quib k=0 z=cmplx((bound-i)*Pi/(2*quib),(bound-j)*Pi/(2*quib)) do while (flag(i,j).eq.0.and.k.lt.31) k=k+1 zt=lambda*ccos(z) im=dimag(zt) if(abs(im).gt.25) then flag(i,j)=31-k endif z=zt enddo enddo enddo return end notes: I don't think I have any for this section, besides the I/O mentioned above concernig the proper libraries. (which may or may not be suppported by SUNS below model 4?) Thank you for your interest, donnie