home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / lypnvxlb / part01 < prev    next >
Encoding:
Text File  |  1992-03-31  |  50.1 KB  |  1,640 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: Renaldo Recuerdo <rr@sco.COM>
  4. Subject: v17i048: Xlib only lyapunov, Part01/02
  5. Message-ID: <csx-17i048-lyapunov-xlib@uunet.UU.NET>
  6. Originator: dcmartin@snoopy
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. Date: Wed, 1 Apr 1992 14:45:31 GMT
  10. Approved: dcmartin@msi.com
  11.  
  12. Submitted-by: Renaldo Recuerdo <rr@sco.COM>
  13. Posting-number: Volume 17, Issue 48
  14. Archive-name: lyapunov-xlib/part01
  15.  
  16. # This is a shell archive (produced by shar 3.49)
  17. # To extract the files from this archive, save it to a file, remove
  18. # everything above the "!/bin/sh" line above, and type "sh file_name".
  19. #
  20. # made 04/01/1992 14:44 UTC by dcmartin@snoopy
  21. # Source directory /home/fascet/csx/src
  22. #
  23. # existing files will NOT be overwritten unless -c is specified
  24. #
  25. # This is part 1 of a multipart archive                                    
  26. # do not concatenate these parts, unpack them in order with /bin/sh        
  27. #
  28. # This shar contains:
  29. # length  mode       name
  30. # ------ ---------- ------------------------------------------
  31. #    719 -rw-r--r-- Imakefile
  32. #    969 -rw-r--r-- Makefile.ODT
  33. #    810 -rw-r--r-- Makefile.OSF
  34. #    141 -rw-r--r-- Package
  35. #   2890 -rw-r--r-- README
  36. #   3365 -rw-r--r-- TAGS
  37. #   2282 -rw-r--r-- hls2rgb.c
  38. #   7181 -rw-r--r-- lyap.6X
  39. #  40245 -rw-r--r-- lyap.c
  40. #   3798 -rw-r--r-- lyap.h
  41. #   6696 -rw-r--r-- lyap.man
  42. #     91 -rw-r--r-- params/asharpe.1
  43. #     57 -rw-r--r-- params/asharpe.2
  44. #     86 -rw-r--r-- params/asharpe.3
  45. #     79 -rw-r--r-- params/asharpe.4
  46. #     73 -rw-r--r-- params/asharpe.5
  47. #     77 -rw-r--r-- params/asharpe.6
  48. #     91 -rw-r--r-- params/asharpe.7
  49. #     88 -rw-r--r-- params/asharpe.8
  50. #     87 -rw-r--r-- params/asharpe.9
  51. #     81 -rw-r--r-- params/circle-12
  52. #     68 -rw-r--r-- params/circle-12test
  53. #     65 -rw-r--r-- params/circle-2
  54. #     73 -rw-r--r-- params/circle-4
  55. #     77 -rw-r--r-- params/circle-8
  56. #    119 -rw-r--r-- params/manray
  57. #     76 -rw-r--r-- params/period-12
  58. #     60 -rw-r--r-- params/period-2
  59. #     68 -rw-r--r-- params/period-4
  60. #     72 -rw-r--r-- params/period-8
  61. #     81 -rw-r--r-- params/skewed-12
  62. #     65 -rw-r--r-- params/skewed-2
  63. #     73 -rw-r--r-- params/skewed-4
  64. #     78 -rw-r--r-- params/skewed-8
  65. #    123 -rw-r--r-- patchlevel.h
  66. #   2381 -rw-r--r-- tags
  67. #     33 -rw-r--r-- testit
  68. #
  69. if test -r _shar_seq_.tmp; then
  70.     echo 'Must unpack archives in sequence!'
  71.     echo Please unpack part `cat _shar_seq_.tmp` next
  72.     exit 1
  73. fi
  74. # ============= Imakefile ==============
  75. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  76.     echo 'x - skipping Imakefile (File already exists)'
  77.     rm -f _shar_wnt_.tmp
  78. else
  79. > _shar_wnt_.tmp
  80. echo 'x - extracting Imakefile (Text)'
  81. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  82. #
  83. #    Imakefile for lyap, by Ron Record
  84. #
  85. X        DEPLIBS = $(DEPXLIB)
  86. #    Uncomment the following line if you have only 16 colors
  87. #    COLORDEFINE = -DSIXTEEN_COLORS
  88. #    Uncomment the following line if your system doesn't support prototypes 
  89. #    PROTODEFINE = -D_NO_PROTO
  90. #    -DMAPS includes code to support "Function forcing". See lyap.man (-F)
  91. X      MAPDEFINE = -DMAPS
  92. X        DEFINES = $(COLORDEFINE) $(MAPDEFINE) $(PROTODEFINE)
  93. X         CFLAGS = -O $(DEFINES) $(CDEBUGFLAGS)
  94. LOCAL_LIBRARIES = $(XLIB) 
  95. X  SYS_LIBRARIES = -lm
  96. X       INCLUDES = .
  97. X           SRCS = lyap.c hls2rgb.c
  98. X           OBJS = lyap.o hls2rgb.o
  99. X
  100. ComplexProgramTarget(lyap)
  101. X
  102. InstallProgram(lyap, /usr/games/X11)
  103. InstallManPage(lyap, /usr/games/X11/doc)
  104. SHAR_EOF
  105. chmod 0644 Imakefile ||
  106. echo 'restore of Imakefile failed'
  107. Wc_c="`wc -c < 'Imakefile'`"
  108. test 719 -eq "$Wc_c" ||
  109.     echo 'Imakefile: original size 719, current size' "$Wc_c"
  110. rm -f _shar_wnt_.tmp
  111. fi
  112. # ============= Makefile.ODT ==============
  113. if test -f 'Makefile.ODT' -a X"$1" != X"-c"; then
  114.     echo 'x - skipping Makefile.ODT (File already exists)'
  115.     rm -f _shar_wnt_.tmp
  116. else
  117. > _shar_wnt_.tmp
  118. echo 'x - extracting Makefile.ODT (Text)'
  119. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.ODT' &&
  120. CC = cc 
  121. #DEBUG =  -g
  122. ##
  123. ## Compiler Defines
  124. ## 
  125. DEFINES = -DSYSV -DSOCKETCONN -DTCPCONN -DTLICONN -DLAI_TCP \
  126. X       -DSTREAMWRITEMAX=4096 -DXSIGHT -DSIXTEEN_COLORS -DMAPS
  127. X
  128. CFLAGS = $(DEBUG) $(DEFINES)
  129. ##
  130. ## Libraries
  131. ## X11     X11 graphics library
  132. ##
  133. ##
  134. LIBS     =     -lX11    \
  135. X        -lx        \
  136. X              -lsocket    \
  137. X        -lnsl_s    \
  138. X        -lPW    \
  139. X        -lm
  140. X
  141. X
  142. .o:.c
  143. X
  144. all: lyap lyap.doc
  145. X
  146. cp install:    all
  147. X    -mkdir -p $(ROOT)/usr/games/X11
  148. X    cp lyap $(ROOT)/usr/games/X11/lyap
  149. X    -mkdir -p $(ROOT)/usr/games/X11/doc
  150. X    cp lyap.doc $(ROOT)/usr/games/X11/doc/lyap
  151. X    -mkdir -p $(ROOT)/usr/games/X11/lib/lyap
  152. X    cp params/* $(ROOT)/usr/games/X11/lib/lyap
  153. X    -mkdir -p $(ROOT)/usr/games/X11/lib/lyap/pics
  154. X    cp pics/* $(ROOT)/usr/games/X11/lib/lyap/pics
  155. X
  156. clean:
  157. X    rm -f *.o
  158. X
  159. clobber:    clean
  160. X    rm -f lyap
  161. X
  162. lyap : lyap.o hls2rgb.o
  163. X    $(CC) $(CFLAGS) -o $@ $@.o hls2rgb.o $(LIBS)
  164. X
  165. lyap.o: lyap.c hls2rgb.c lyap.h
  166. X
  167. lyap.doc:    lyap.man
  168. X    nroff -man lyap.man > lyap.doc
  169. X
  170. lyap.doc.mm:    lyap.man.mm
  171. X    nroff -cm -rN4 lyap.man.mm > lyap.doc.mm
  172. SHAR_EOF
  173. chmod 0644 Makefile.ODT ||
  174. echo 'restore of Makefile.ODT failed'
  175. Wc_c="`wc -c < 'Makefile.ODT'`"
  176. test 969 -eq "$Wc_c" ||
  177.     echo 'Makefile.ODT: original size 969, current size' "$Wc_c"
  178. rm -f _shar_wnt_.tmp
  179. fi
  180. # ============= Makefile.OSF ==============
  181. if test -f 'Makefile.OSF' -a X"$1" != X"-c"; then
  182.     echo 'x - skipping Makefile.OSF (File already exists)'
  183.     rm -f _shar_wnt_.tmp
  184. else
  185. > _shar_wnt_.tmp
  186. echo 'x - extracting Makefile.OSF (Text)'
  187. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.OSF' &&
  188. CC = cc 
  189. #DEBUG =  -g
  190. ##
  191. ## Compiler Defines
  192. ## 
  193. DEFINES = -DMAPS
  194. X
  195. CFLAGS = $(DEBUG) $(DEFINES)
  196. ##
  197. ## Libraries
  198. ## X11     X11 graphics library
  199. ##
  200. ##
  201. LIBS     = -lX11 -lm
  202. X
  203. .o:.c
  204. X
  205. all: lyap lyap.doc
  206. X
  207. cp install:    all
  208. X    -mkdir -p $(ROOT)/usr/games/X11
  209. X    cp lyap $(ROOT)/usr/games/X11/lyap
  210. X    -mkdir -p $(ROOT)/usr/games/X11/doc
  211. X    cp lyap.doc $(ROOT)/usr/games/X11/doc/lyap
  212. X    -mkdir -p $(ROOT)/usr/games/X11/lib/lyap
  213. X    cp params/* $(ROOT)/usr/games/X11/lib/lyap
  214. X    -mkdir -p $(ROOT)/usr/games/X11/lib/lyap/pics
  215. X    cp pics/* $(ROOT)/usr/games/X11/lib/lyap/pics
  216. X
  217. clean:
  218. X    rm -f *.o
  219. X
  220. clobber:    clean
  221. X    rm -f lyap
  222. X
  223. lyap : lyap.o hls2rgb.o
  224. X    $(CC) $(CFLAGS) -o $@ $@.o hls2rgb.o $(LIBS)
  225. X
  226. lyap.o: lyap.c hls2rgb.c lyap.h
  227. X
  228. lyap.doc:    lyap.man
  229. X    nroff -man lyap.man > lyap.doc
  230. X
  231. lyap.doc.mm:    lyap.man.mm
  232. X    nroff -cm -rN4 lyap.man.mm > lyap.doc.mm
  233. SHAR_EOF
  234. chmod 0644 Makefile.OSF ||
  235. echo 'restore of Makefile.OSF failed'
  236. Wc_c="`wc -c < 'Makefile.OSF'`"
  237. test 810 -eq "$Wc_c" ||
  238.     echo 'Makefile.OSF: original size 810, current size' "$Wc_c"
  239. rm -f _shar_wnt_.tmp
  240. fi
  241. # ============= Package ==============
  242. if test -f 'Package' -a X"$1" != X"-c"; then
  243.     echo 'x - skipping Package (File already exists)'
  244.     rm -f _shar_wnt_.tmp
  245. else
  246. > _shar_wnt_.tmp
  247. echo 'x - extracting Package (Text)'
  248. sed 's/^X//' << 'SHAR_EOF' > 'Package' &&
  249. [ -f lyap.shar ] && mv lyap.shar lyap.shar-
  250. shar R* Imakefile M*T M*F Package *.c *.h lyap.6X lyap.man tags TAGS params/* testit > lyap.shar
  251. SHAR_EOF
  252. chmod 0644 Package ||
  253. echo 'restore of Package failed'
  254. Wc_c="`wc -c < 'Package'`"
  255. test 141 -eq "$Wc_c" ||
  256.     echo 'Package: original size 141, current size' "$Wc_c"
  257. rm -f _shar_wnt_.tmp
  258. fi
  259. # ============= README ==============
  260. if test -f 'README' -a X"$1" != X"-c"; then
  261.     echo 'x - skipping README (File already exists)'
  262.     rm -f _shar_wnt_.tmp
  263. else
  264. > _shar_wnt_.tmp
  265. echo 'x - extracting README (Text)'
  266. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  267. X
  268. X
  269. Written by Ronald Joe Record (rr@sco) 03 Sep 1991
  270. X
  271. INTRO
  272. -----
  273. X
  274. The idea here is to calculate the Lyapunov exponent for a periodically
  275. forced logistic map (later i added several other nonlinear maps of the unit
  276. interval). In order to turn the 1-dimensional parameter space of the
  277. logistic map into a 2-dimensional parameter space, select two parameter
  278. values (a and b) then alternate the iterations of the logistic map using
  279. first a then b as the parameter. This program accepts an argument to 
  280. specify a forcing function, so instead of just alternating a and b, you
  281. can use a as the parameter for say 6 iterations, then b for 6 iterations
  282. and so on. An interesting forcing function to look at is abbabaab (the
  283. Morse-Thue sequence, an aperiodic self-similar, self-generating sequence).
  284. Anyway, you step through all the values of a and b in the ranges you want,
  285. calculating the Lyapunov exponent for each pair of values. The exponent
  286. is calculated by iterating out a ways (specified by the variable "settle")
  287. then on subsequent iterations calculating an average of the logarithm of
  288. the absolute value of the derivative at that point. Points in parameter
  289. space with a negative Lyapunov exponent are colored one way (using the
  290. value of the exponent to index into a color map) while points with a
  291. non-negative exponent are colored differently. 
  292. X
  293. ACKNOWLEDGEMENTS
  294. ----------------
  295. X
  296. The algorithm was taken from the September 1991 Scientific American article
  297. by A. K. Dewdney who gives credit to Mario Markus of the Max Planck Institute
  298. for its creation. Additional information and ideas were gleaned from the
  299. discussion on alt.fractals involving Stephen Hall, Ed Kubaitis, Dave Platt
  300. and Baback Moghaddam. Assistance with colormaps and spinning color wheels
  301. and X was gleaned from Hiram Clawson. Rubber band code was adapted from 
  302. Stacey Campbell's xmandel source.
  303. X
  304. BUILD
  305. -----
  306. X
  307. To build the lyap binary, either use the Imakefile or one of the sample 
  308. makefiles - Makefile.ODT or Makefile.OSF. Makefile.ODT is a sample makefile
  309. used to build lyap on an SCO ODT system. Makefile.OSF was used as a makefile
  310. on a DECstation 3100 running OSF/1. If your system has only 16 colors, 
  311. uncomment the COLORDEFINE line of the Imakefile and/or add a -DSIXTEEN_COLORS 
  312. to the appropriate makefile. The manual page can be formatted by typing 
  313. "nroff -man lyap.man > lyap.doc".
  314. X
  315. INSTALL
  316. -------
  317. X
  318. To install lyap, copy the lyap binary to the desired location (the sample
  319. makefiles put it in /usr/games/X11)
  320. Copy the formatted man page to wherever you keep your local doc (i use
  321. /usr/games/X11/doc for games and imaging software), then add that location
  322. to your MANPATH.
  323. X
  324. Some "interesting" runs of lyap are included as simple shell scripts in the
  325. "params" subdirectory.
  326. X
  327. X
  328. Ideas, comments, additions, deletions, suggestions, bug reports, code review,...
  329. e-mail Ronald Record at rr@sco.com or ...uunet!sco!rr.
  330. X
  331. SHAR_EOF
  332. chmod 0644 README ||
  333. echo 'restore of README failed'
  334. Wc_c="`wc -c < 'README'`"
  335. test 2890 -eq "$Wc_c" ||
  336.     echo 'README: original size 2890, current size' "$Wc_c"
  337. rm -f _shar_wnt_.tmp
  338. fi
  339. # ============= TAGS ==============
  340. if test -f 'TAGS' -a X"$1" != X"-c"; then
  341.     echo 'x - skipping TAGS (File already exists)'
  342.     rm -f _shar_wnt_.tmp
  343. else
  344. > _shar_wnt_.tmp
  345. echo 'x - extracting TAGS (Text)'
  346. sed 's/^X//' << 'SHAR_EOF' > 'TAGS' &&
  347. ABS               20 lyap.h           #define ABS(a)    (((a)<0) ? (0-(a)) : (a) )
  348. BufferPoint     1388 lyap.c           BufferPoint(display, window, color, x, y)
  349. Clear           1152 lyap.c           Clear() 
  350. CreateXorGC     1173 lyap.c           CreateXorGC()
  351. Cycle_frames     743 lyap.c           Cycle_frames()
  352. Destroy_frame   1362 lyap.c           Destroy_frame()
  353. EndRubberBand   1248 lyap.c           void 
  354. FlushBuffer     1408 lyap.c           FlushBuffer()
  355. Getkey           777 lyap.c           Getkey(event)
  356. InitBuffer      1379 lyap.c           InitBuffer()
  357. Max               22 lyap.h           #define Max(x,y) ((x > y)?x:y)
  358. Min               21 lyap.h           #define Min(x,y) ((x < y)?x:y)
  359. Redraw          1048 lyap.c           Redraw() 
  360. SetupCorners    1202 lyap.c           SetupCorners(corners, data)
  361. Spin             753 lyap.c           Spin(w)
  362. StartRubberBand 1185 lyap.c           void 
  363. TrackRubberBand 1218 lyap.c           void 
  364. check_params     678 lyap.c           check_params(mapnum, parnum)
  365. circle           250 lyap.c           circle(x, r)            /* sin() hump or sorta like the circle map */
  366. complyap         131 lyap.c           complyap()
  367. dcircle          259 lyap.c           dcircle(x, r)            /* derivative of the "sin() hump" */
  368. ddoublelog       309 lyap.c           ddoublelog(x, r)        /* derivative of the double logistic */
  369. dleftlog         278 lyap.c           dleftlog(x, r)            /* derivative of the left skewed logistic */
  370. dlogistic        243 lyap.c           dlogistic(x, r)            /* the derivative of logistic map */
  371. doublelog        299 lyap.c           doublelog(x, r)            /* double logistic */
  372. drightlog        292 lyap.c           drightlog(x, r)            /* derivative of the right skewed logistic */
  373. freemem         1481 lyap.c           freemem()
  374. go_back         1322 lyap.c           go_back() 
  375. go_down         1311 lyap.c           go_down() 
  376. go_init         1354 lyap.c           go_init() 
  377. hls2rgb           24 hls2rgb.c        void hls2rgb( hue_light_sat, rgb )
  378. hue_value         82 hls2rgb.c        static double hue_value( n1, n2, hue )
  379. init_canvas      344 lyap.c           init_canvas()
  380. init_color       366 lyap.c           init_color()
  381. init_data        319 lyap.c           init_data()
  382. jumpwin         1332 lyap.c           jumpwin()
  383. leftlog          268 lyap.c           leftlog(x, r)            /* left skewed logistic */
  384. logistic         236 lyap.c           logistic(x, r)            /* the familiar logistic map */
  385. main              37 lyap.c           main(ac, av)
  386. main_event        91 lyap.c           main_event()
  387. parseargs        563 lyap.c           parseargs(ac, av)
  388. print_help      1426 lyap.c           print_help() 
  389. print_values    1452 lyap.c           print_values() 
  390. recalc          1137 lyap.c           recalc() 
  391. redisplay        968 lyap.c           void 
  392. redraw          1018 lyap.c           redraw(exparray, index, cont)
  393. resize           982 lyap.c           resize()
  394. rightlog         285 lyap.c           rightlog(x, r)            /* right skewed logistic */
  395. save_to_file    1062 lyap.c           save_to_file() 
  396. sendpoint        924 lyap.c           sendpoint(expo)
  397. set_new_params  1284 lyap.c           set_new_params(w, data)
  398. setforcing      1502 lyap.c           setforcing()
  399. setupmem        1489 lyap.c           setupmem()
  400. show_defaults   1161 lyap.c           show_defaults() 
  401. usage            704 lyap.c           usage()
  402. SHAR_EOF
  403. chmod 0644 TAGS ||
  404. echo 'restore of TAGS failed'
  405. Wc_c="`wc -c < 'TAGS'`"
  406. test 3365 -eq "$Wc_c" ||
  407.     echo 'TAGS: original size 3365, current size' "$Wc_c"
  408. rm -f _shar_wnt_.tmp
  409. fi
  410. # ============= hls2rgb.c ==============
  411. if test -f 'hls2rgb.c' -a X"$1" != X"-c"; then
  412.     echo 'x - skipping hls2rgb.c (File already exists)'
  413.     rm -f _shar_wnt_.tmp
  414. else
  415. > _shar_wnt_.tmp
  416. echo 'x - extracting hls2rgb.c (Text)'
  417. sed 's/^X//' << 'SHAR_EOF' > 'hls2rgb.c' &&
  418. /* From colorwheel.c which is part of color3 by Hiram Clawson (hiramc@sco.com)*/
  419. X
  420. #include    <X11/Xlib.h>
  421. #include    <X11/Xutil.h>
  422. X
  423. #ifdef _NO_PROTO
  424. static double hue_value();
  425. #else
  426. static double hue_value( double, double, double );
  427. #endif
  428. X
  429. /***********************************************************************
  430. X * NAME: hls2rgb() from foley and van dam, fundamentals of interactive ...
  431. X *        page 619
  432. X *
  433. X * PURPOSE: Convert hls[0..3600][0..1000][0..1000] space to rgb space
  434. X *    That is the Hue, Lightness, Saturation color model.
  435. X *    Which is two cones, base to base, the bottom tip is black, the
  436. X *    top tip is white, the middle (bases) around the outside is a color
  437. X *    wheel.  The axis of this solid is Lightness.  Hue is the angular
  438. X *    measure around the cones, and the saturation is the radius from the
  439. X *    axis towards the surface of the cones.
  440. X ***********************************************************************/
  441. void hls2rgb( hue_light_sat, rgb )
  442. int hue_light_sat[3];
  443. int rgb[3];        /*    Each in range [0..65535]    */
  444. {
  445. X    double r, g, b, h, l, s;
  446. X    double m1, m2;
  447. X
  448. X    h = (double) hue_light_sat[0] / 10.0;
  449. X    l = (double) hue_light_sat[1] / 1000.0;
  450. X    s = (double) hue_light_sat[2] / 1000.0;
  451. X
  452. X    if ( l < 0.5 )
  453. X    {
  454. X        m2 = l * ( 1.0 + s );
  455. X    }
  456. X    else
  457. X    {
  458. X        m2 = l + s - (l * s);
  459. X    }
  460. X    m1 = (2.0 * l) - m2;
  461. X    if ( (s + 1.0) == 1.0 )
  462. X    {
  463. X        if ( (h + 1.0) < 1.0 )
  464. X        {
  465. X            r = g = b = l;
  466. X        }
  467. X        else
  468. X        {
  469. X            r = g = b = 0.0;
  470. X        }
  471. X    }
  472. X    else
  473. X    {
  474. X        r = hue_value( m1, m2, h + 120.0 );
  475. X        g = hue_value( m1, m2, h );
  476. X        b = hue_value( m1, m2, h - 120.0 );
  477. X    }
  478. X    rgb[0] = 65535.0 * r;
  479. X    rgb[1] = 65535.0 * g;
  480. X    rgb[2] = 65535.0 * b;
  481. X    if ( rgb[0] > 65535 )
  482. X        rgb[0] = 65535;
  483. X    else if ( rgb[0] < 0 )
  484. X        rgb[0] = 0;
  485. X
  486. X    if ( rgb[1] > 65535 )
  487. X        rgb[1] = 65535;
  488. X    else if ( rgb[1] < 0 )
  489. X        rgb[1] = 0;
  490. X
  491. X    if ( rgb[2] > 65535 )
  492. X        rgb[2] = 65535;
  493. X    else if ( rgb[2] < 0 )
  494. X        rgb[2] = 0;
  495. X
  496. X    return;
  497. }    /* end of void hls2rgb( hue_light_sat, rgb )    */
  498. X
  499. static double hue_value( n1, n2, hue )
  500. double n1;
  501. double n2;
  502. double hue;
  503. {
  504. X    if ( hue > 360.0 )
  505. X        hue -= 360.0;
  506. X    if ( hue < 0.0 )
  507. X        hue += 360.0;
  508. X    if ( hue < 60.0 )
  509. X        return  ( n1 + ((n2 - n1)*hue/60.0));
  510. X    else if ( hue < 180.0 )
  511. X        return ( n2 );
  512. X    else if ( hue < 240.0 )
  513. X        return ( n1 + ((n2 - n1)*(240.0 - hue)/60.0));
  514. X    else
  515. X        return( n1 );
  516. }    /* end of double hue_value( n1, n2, hue )    */
  517. SHAR_EOF
  518. chmod 0644 hls2rgb.c ||
  519. echo 'restore of hls2rgb.c failed'
  520. Wc_c="`wc -c < 'hls2rgb.c'`"
  521. test 2282 -eq "$Wc_c" ||
  522.     echo 'hls2rgb.c: original size 2282, current size' "$Wc_c"
  523. rm -f _shar_wnt_.tmp
  524. fi
  525. # ============= lyap.6X ==============
  526. if test -f 'lyap.6X' -a X"$1" != X"-c"; then
  527.     echo 'x - skipping lyap.6X (File already exists)'
  528.     rm -f _shar_wnt_.tmp
  529. else
  530. > _shar_wnt_.tmp
  531. echo 'x - extracting lyap.6X (Text)'
  532. sed 's/^X//' << 'SHAR_EOF' > 'lyap.6X' &&
  533. X
  534. X
  535. X
  536. LYAP(6X)                                                             LYAP(6X)
  537. X
  538. X
  539. X
  540. NAME
  541. X  lyap - display an array of Lyapunov exponents graphically
  542. X
  543. SYNOPSIS
  544. X  _l_y_a_p [-BLps][-W width][-H height][-o filename][-a _n ] [-b _n ] [-w _n ] [-h _n
  545. X          ] [-i xstart] [-M _n ] [-R _p ] [-S _n ] [-D _n ] [-F string][-f
  546. X          string][-r _n ] [-O _n ] [-C _n ] [-c _n ] [-m _n ] [-x xpos] [-y ypos]
  547. X
  548. DESCRIPTION
  549. X  _l_y_a_p generates and graphically displays an array of Lyapunov exponents for
  550. X  a variety of iterated periodically forced non-linear maps of the unit
  551. X  interval.
  552. X
  553. OPTIONS
  554. X
  555. X  -C _n    Specifies the minimum color index to be used for negative exponents
  556. X
  557. X  -D _n    Specifies the "dwell" or number of iterations over which to average
  558. X          in order to calculate the Lyapunov exponent. Default is 400.
  559. X
  560. X  -B      Causes the stop, go, spin and quit buttons to be displayed.
  561. X
  562. X  -H _n    Specifies the height of the window. Default is 256.
  563. X
  564. X  -L      Indicates use log(x) + log(y) rather than log(xy).
  565. X
  566. X  -M _r    Specifies the real value to compare exponent values to for indexing
  567. X          into a color wheel. The default value is 1.0.
  568. X
  569. X  -O _n    Specifies the minimum color index to be used for positive exponents
  570. X
  571. X  -R _p    Specifies pseudo-random forcing with probability _p of using parame-
  572. X          ter value 'a'.
  573. X
  574. X  -S _n    Specifies the "settle" or number of iterations prior to the begin-
  575. X          ning of the calculation of the Lyapunov exponent. Default is 200.
  576. X
  577. X  -W _n    Specifies the width of the window. Default is 256.
  578. X
  579. X  -a _r    Specifies the real value to use as the minimum parameter value of
  580. X          the horizontal axis. Default is 3.0 for the logistic map.
  581. X
  582. X  -b _n    Specifies the real value to use as the minimum parameter value of
  583. X          the vertical axis. Default is 3.0 for the logistic map.
  584. X
  585. X  -c _n    Selects one of six different color wheels to use. The default color
  586. X          wheel is a rainbow palette.
  587. X
  588. X  -F _1_0_1_0_1_0_1_0
  589. X          Specifies the "Function" forcing function to use. The example above
  590. X          would alternate between iterating the circle and logistic maps. An
  591. X          argument of "-F 2323" would alternate between left and right logis-
  592. X          tic maps. The default is to only use the single specified map (see
  593. X          the description of -m).
  594. X
  595. X  -f _a_b_b_a_b_a_a_b
  596. X          Specifies the forcing function to use. The default is to alternate
  597. X          between the "a" parameter and the "b" parameter.
  598. X
  599. X  -h _r    Specifies the real value to be used as the range over which the
  600. X          vertical parameter values vary. The default is 1.0.
  601. X
  602. X  -i _r    Specifies the real value of the initial condition to use. Default
  603. X          is 0.05.
  604. X
  605. X  -m _n    Selects between available non-linear maps of the unit interval. A
  606. X          value of 0 specifies the logistic map. A value of 1, the circle
  607. X          map. A value of 2, the left-logistic. A value of 3, the right-
  608. X          logistic. A value of 4, the double-logistic. The default is 0, the
  609. X          logistic map.
  610. X
  611. X  -o _f_i_l_e_n_a_m_e
  612. X          Specifies the output filename to be used. If the -o option is
  613. X          given, this file will automatically be written out at the comple-
  614. X          tion of the drawing.  If it is not specified, a default filename of
  615. X          lyap.out is used and only written if the 'f' or 'F' keys are
  616. X          pressed during a run. The format of the output file is PPM for
  617. X          color and PGM for monochrom. The parameters used to calculate the
  618. X          picture are included as comments at the beginning of the output
  619. X          file.
  620. X
  621. X  -p      Switches color indices for negative and positive exponents. Gen-
  622. X          erally, causes negative exponents to be displayed in more detail
  623. X          while darkening and narrowing the color range for positive
  624. X          exponents. This can be toggled during runtime by pressing the 'p'
  625. X          key.
  626. X
  627. X  -r _n    Specifies the maximum rgb value to be used. Default is 35000.
  628. X
  629. X  -s _n    Specifies the length of the color wheel spin.
  630. X
  631. X  -u      Produces a usage message.
  632. X
  633. X  -v      Prints out the various values to be used and exits.
  634. X
  635. X  -w _r    Specifies the real value to be used as the range over which the
  636. X          horizontal parameter values vary. The default is 1.0.
  637. X
  638. X  -x _n    Specifies the x screen coordinate of the window (default is 256).
  639. X
  640. X  -y _n    Specifies the y screen coordinate of the window (default is 256).
  641. X
  642. X
  643. X
  644. NOTES
  645. X
  646. X  During display, pressing any mouse button allows you to select the area to
  647. X  be investigated with the mouse. The upper left hand corner of the desired
  648. X  area is the location of the cursor when the button is pressed. The lower
  649. X  right hand corner is specified by the cursor when the button is released.
  650. X
  651. X
  652. X  Use of the keys _b_B_e_E_f_F_k_K_j_J_m_n_r_R_s_S_w_W_x_X_q_Q indicates:
  653. X
  654. X          (<) Halve dwell value.
  655. X          (>) Double dwell value.
  656. X          ([) Halve settle value.
  657. X          (]) Double settle value.
  658. X          (B or b) Toggle button display on/off
  659. X          (E or e) Recalculate the indices into the color wheel using a dif-
  660. X  ferent method
  661. X          (F or f) Save current screen to ouput file (not yet implemented)
  662. X          (H or h or ?) Display brief help message
  663. X          (i) Decrement the interval between stripes for the striped color
  664. X  map.
  665. X          (I) Increment the interval between stripes for the striped color
  666. X  map.
  667. X          (K) Decrease value exponents are compared against by 0.05.
  668. X          (J) Increase value exponents are compared against by 0.05.
  669. X          (M) Decrease value exponents are compared against by 0.005.
  670. X          (N) Increase value exponents are compared against by 0.005.
  671. X          (m) Increment the map index, changing the map to be iterated.
  672. X          (P or p) Toggle positive/negative exponent display.
  673. X          (r) Redraw the window using previously calculated exponents.
  674. X          (R) Redraw the window using the newly set dwell and/or settle
  675. X  values.
  676. X          (S) Spin the color wheel
  677. X          (s) Halve the length of the spin and spin the color wheel
  678. X          (u) Go up to the window just prior to the most recent zoom.
  679. X          (U) Go all the way up to the original window.
  680. X          (V or v) Display values of various parameters currently in use
  681. X          (W or w) Use next color map.
  682. X          (X or x) Clear window
  683. X          (Q or q) quit
  684. X
  685. X
  686. X
  687. AUTHOR
  688. X          Ronald Joe Record
  689. X       The Santa Cruz Operation
  690. X            P.O. Box 1900
  691. X         Santa Cruz, CA 95061
  692. X              rr@sco.com
  693. X
  694. X
  695. X
  696. ACKNOWLEDGEMENTS
  697. X
  698. X  The algorithm was taken from the September 1991 Scientific American article
  699. X  by A. K. Dewdney who gives credit to Mario Markus of the Max Planck Insti-
  700. X  tute for its creation. Additional information and ideas were gleaned from
  701. X  the discussion on alt.fractals involving Stephen Hall, Ed Kubaitis, Dave
  702. X  Platt and Baback Moghaddam. Assistance with colormaps and spinning color
  703. X  wheels and X was gleaned from Hiram Clawson. Rubber banding code was
  704. X  adapted from an existing Mandelbrot program written by Stacey Campbell.
  705. X
  706. X
  707. X
  708. X
  709. X
  710. X
  711. X
  712. X
  713. X
  714. X
  715. X
  716. X
  717. X
  718. X
  719. X
  720. X
  721. X
  722. X
  723. X
  724. X
  725. X
  726. X
  727. X
  728. X
  729. X
  730. X
  731. SHAR_EOF
  732. chmod 0644 lyap.6X ||
  733. echo 'restore of lyap.6X failed'
  734. Wc_c="`wc -c < 'lyap.6X'`"
  735. test 7181 -eq "$Wc_c" ||
  736.     echo 'lyap.6X: original size 7181, current size' "$Wc_c"
  737. rm -f _shar_wnt_.tmp
  738. fi
  739. # ============= lyap.c ==============
  740. if test -f 'lyap.c' -a X"$1" != X"-c"; then
  741.     echo 'x - skipping lyap.c (File already exists)'
  742.     rm -f _shar_wnt_.tmp
  743. else
  744. > _shar_wnt_.tmp
  745. echo 'x - extracting lyap.c (Text)'
  746. sed 's/^X//' << 'SHAR_EOF' > 'lyap.c' &&
  747. /* Lyap - calculate and display Lyapunov exponents */
  748. X
  749. /* Written by Ron Record (rr@sco) 03 Sep 1991 */
  750. X
  751. /* The idea here is to calculate the Lyapunov exponent for a periodically
  752. X * forced logistic map (later i added several other nonlinear maps of the unit
  753. X * interval). In order to turn the 1-dimensional parameter space of the
  754. X * logistic map into a 2-dimensional parameter space, select two parameter
  755. X * values ('a' and 'b') then alternate the iterations of the logistic map using
  756. X * first 'a' then 'b' as the parameter. This program accepts an argument to 
  757. X * specify a forcing function, so instead of just alternating 'a' and 'b', you
  758. X * can use 'a' as the parameter for say 6 iterations, then 'b' for 6 iterations
  759. X * and so on. An interesting forcing function to look at is abbabaab (the
  760. X * Morse-Thue sequence, an aperiodic self-similar, self-generating sequence).
  761. X * Anyway, step through all the values of 'a' and 'b' in the ranges you want,
  762. X * calculating the Lyapunov exponent for each pair of values. The exponent
  763. X * is calculated by iterating out a ways (specified by the variable "settle")
  764. X * then on subsequent iterations calculating an average of the logarithm of
  765. X * the absolute value of the derivative at that point. Points in parameter
  766. X * space with a negative Lyapunov exponent are colored one way (using the
  767. X * value of the exponent to index into a color map) while points with a
  768. X * non-negative exponent are colored differently. 
  769. X * 
  770. X * The algorithm was taken from the September 1991 Scientific American article
  771. X * by A. K. Dewdney who gives credit to Mario Markus of the Max Planck Institute
  772. X * for its creation. Additional information and ideas were gleaned from the
  773. X * discussion on alt.fractals involving Stephen Hall, Ed Kubaitis, Dave Platt
  774. X * and Baback Moghaddam. Assistance with colormaps and spinning color wheels
  775. X * and X was gleaned from Hiram Clawson. Rubber banding code was adapted from
  776. X * an existing Mandelbrot program written by Stacey Campbell.
  777. X */
  778. X
  779. #include "lyap.h"
  780. X
  781. static char *version = LYAP_VERSION;
  782. X
  783. main(ac, av)
  784. X    int ac;
  785. X    char **av;
  786. {
  787. X    int i;
  788. X    XSizeHints hint;
  789. X    extern void init_canvas(), init_data(), init_color(), parseargs();
  790. X    extern void Clear();
  791. X
  792. X    parseargs(ac, av);
  793. X        dpy = XOpenDisplay("");
  794. X        screen = DefaultScreen(dpy);
  795. X    background = BlackPixel(dpy, screen);
  796. X    setupmem();
  797. X    init_data();
  798. X    if (displayplanes > 1)
  799. X        foreground = startcolor;
  800. X    else
  801. X        foreground = WhitePixel(dpy,XDefaultScreen(dpy));
  802. X    hint.x = xposition;
  803. X    hint.y = yposition;
  804. X    hint.width = width;
  805. X    hint.height = height;
  806. X    hint.flags = PPosition | PSize;
  807. X    /*
  808. X     * Create the window to display the Lyapunov exponents 
  809. X     */
  810. X    canvas = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
  811. X        hint.x, hint.y, hint.width, hint.height,
  812. X        5, foreground, background);
  813. X    XSetStandardProperties(dpy, canvas, "Lyap by Ron Record", 
  814. X        "Lyap", None, av, ac, &hint);
  815. X    init_canvas();
  816. X    XSelectInput(dpy,canvas,KeyPressMask|ButtonPressMask|ButtonMotionMask|
  817. X        ButtonReleaseMask|ExposureMask|StructureNotifyMask);
  818. X    XMapRaised(dpy, canvas);
  819. X    if (displayplanes > 1) {
  820. X        init_color();
  821. X        /* install new color map */
  822. X        XSetWindowColormap(dpy, canvas, cmap);
  823. X    }
  824. X    else {
  825. X        XQueryColors(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), 
  826. X                Colors, numcolors);
  827. X    }
  828. X    pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), 
  829. X            width, height, DefaultDepth(dpy, screen));
  830. X    rubber_data.band_cursor=XCreateFontCursor(dpy, XC_hand2);
  831. X    CreateXorGC();
  832. X    Clear();
  833. X    for(;;)
  834. X        main_event();
  835. }
  836. X
  837. main_event()
  838. {
  839. X    int n;
  840. X    XEvent event;
  841. X
  842. X    if (complyap() == TRUE)
  843. X        run=0;
  844. X    n = XEventsQueued(dpy, QueuedAfterFlush);
  845. X    while (n--) {
  846. X            XNextEvent(dpy, &event);
  847. X            switch(event.type) 
  848. X            {
  849. X            case KeyPress:
  850. X        Getkey(&event);
  851. X        break;
  852. X            case Expose:
  853. X        redisplay(canvas, &event);
  854. X            break;
  855. X            case ConfigureNotify:
  856. X        resize();
  857. X            break;
  858. X            case ButtonPress:
  859. X        StartRubberBand(canvas, &rubber_data, &event);
  860. X            break;
  861. X            case MotionNotify:
  862. X        TrackRubberBand(canvas, &rubber_data, &event);
  863. X            break;
  864. X            case ButtonRelease:
  865. X        EndRubberBand(canvas, &rubber_data, &event);
  866. X            break;
  867. X            }
  868. X        }
  869. }
  870. X
  871. /* complyap() is the guts of the program. This is where the Lyapunov exponent
  872. X * is calculated. For each iteration (past some large number of iterations)
  873. X * calculate the logarithm of the absolute value of the derivative at that
  874. X * point. Then average them over some large number of iterations. Some small
  875. X * speed up is achieved by utilizing the fact that log(a*b) = log(a) + log(b).
  876. X */
  877. complyap()
  878. {
  879. X    register i, bindex, findex;
  880. X    double total, prod, x, r;
  881. X    extern void save_to_file();
  882. X
  883. X    if (!run)
  884. X        return TRUE;
  885. X    a += a_inc;
  886. X    if (a >= max_a)
  887. X        if (sendpoint(lyapunov) == TRUE)
  888. X            return FALSE;
  889. X        else {
  890. X            FlushBuffer();
  891. X            if (savefile)
  892. X                save_to_file();
  893. X            return TRUE;
  894. X        }
  895. X    if (b >= max_b) {
  896. X        FlushBuffer();
  897. X        if (savefile)
  898. X            save_to_file();
  899. X        return TRUE;
  900. X    }
  901. X    prod = 1.0;
  902. X    total = 0.0;
  903. X    bindex = 0;
  904. X    x = start_x;
  905. X    r = (forcing[bindex]) ? b : a;
  906. #ifdef MAPS
  907. X    findex = 0;
  908. X    map = Maps[Forcing[findex]];
  909. #endif
  910. X    for (i=0;i<settle;i++) {       /* Here's where we let the thing */
  911. X        x = (*map)(x, r);       /* "settle down". There is usually */
  912. X        if (++bindex >= maxindex) { /* some initial "noise" in the */
  913. X            bindex = 0;       /* iterations. How can we optimize */
  914. X            if (Rflag)        /* the value of settle ??? */
  915. X                setforcing();
  916. X        }
  917. X        r = (forcing[bindex]) ? b : a;
  918. #ifdef MAPS
  919. X        if (++findex >= funcmaxindex)
  920. X            findex = 0;
  921. X        map = Maps[Forcing[findex]];
  922. #endif
  923. X    }
  924. #ifdef MAPS
  925. X    deriv = Derivs[Forcing[findex]];
  926. #endif
  927. X    if (useprod) {            /* using log(a*b) */
  928. X        for (i=0;i<dwell;i++) {
  929. X            x = (*map)(x, r);
  930. X            prod *= ABS((*deriv)(x, r));
  931. X            /* we need to prevent overflow and underflow */
  932. X            if ((prod > 1.0e12) || (prod < 1.0e-12)) {
  933. X                total += log(prod);
  934. X                prod = 1.0;
  935. X            }
  936. X            if (++bindex >= maxindex) {
  937. X                bindex = 0;
  938. X                if (Rflag)
  939. X                    setforcing();
  940. X            }
  941. X            r = (forcing[bindex]) ? b : a;
  942. #ifdef MAPS
  943. X            if (++findex >= funcmaxindex)
  944. X                findex = 0;
  945. X            map = Maps[Forcing[findex]];
  946. X            deriv = Derivs[Forcing[findex]];
  947. #endif
  948. X        }
  949. X        total += log(prod);
  950. X        lyapunov = (total * M_LOG2E) / (double)dwell;
  951. X    }
  952. X    else {                /* use log(a) + log(b) */
  953. X        for (i=0;i<dwell;i++) {
  954. X            x = (*map)(x, r);
  955. X            total += log(ABS((*deriv)(x, r)));
  956. X            if (++bindex >= maxindex) {
  957. X                bindex = 0;
  958. X                if (Rflag)
  959. X                    setforcing();
  960. X            }
  961. X            r = (forcing[bindex]) ? b : a;
  962. #ifdef MAPS
  963. X            if (++findex >= funcmaxindex)
  964. X                findex = 0;
  965. X            map = Maps[Forcing[findex]];
  966. X            deriv = Derivs[Forcing[findex]];
  967. #endif
  968. X        }
  969. X        lyapunov = (total * M_LOG2E) / (double)dwell;
  970. X    }
  971. X    if (sendpoint(lyapunov) == TRUE)
  972. X        return FALSE;
  973. X    else {
  974. X        FlushBuffer();
  975. X        if (savefile)
  976. X            save_to_file();
  977. X        return TRUE;
  978. X    }
  979. }
  980. X
  981. double
  982. logistic(x, r)            /* the familiar logistic map */
  983. double x, r;
  984. {
  985. X    return(r * x * (1.0 - x));
  986. }
  987. X
  988. double
  989. dlogistic(x, r)            /* the derivative of logistic map */
  990. double x, r;
  991. {
  992. X    return(r - (2.0 * r * x));
  993. }
  994. X
  995. double
  996. circle(x, r)            /* sin() hump or sorta like the circle map */
  997. double x, r;
  998. {
  999. X    extern double sin();
  1000. X
  1001. X    return(r * sin(M_PI * x));
  1002. }
  1003. X
  1004. double
  1005. dcircle(x, r)            /* derivative of the "sin() hump" */
  1006. double x, r;
  1007. {
  1008. X    extern double cos();
  1009. X
  1010. X    return(r * M_PI * cos(M_PI * x));
  1011. }
  1012. X
  1013. double
  1014. leftlog(x, r)            /* left skewed logistic */
  1015. double x, r;
  1016. {
  1017. X    double d;
  1018. X
  1019. X    d = 1.0 - x;
  1020. X    return(r * x * d * d);
  1021. }
  1022. X
  1023. double
  1024. dleftlog(x, r)            /* derivative of the left skewed logistic */
  1025. double x, r;
  1026. {
  1027. X    return(r * (1.0 - (4.0 * x) + (3.0 * x * x)));
  1028. }
  1029. X
  1030. double
  1031. rightlog(x, r)            /* right skewed logistic */
  1032. double x, r;
  1033. {
  1034. X    return(r * x * x * (1.0 - x));
  1035. }
  1036. X
  1037. double
  1038. drightlog(x, r)            /* derivative of the right skewed logistic */
  1039. double x, r;
  1040. {
  1041. X    return(r * ((2.0 * x) - (3.0 * x * x)));
  1042. }
  1043. X
  1044. double
  1045. doublelog(x, r)            /* double logistic */
  1046. double x, r;
  1047. {
  1048. X    double d;
  1049. X
  1050. X    d = 1.0 - x;
  1051. X    return(r * x * x * d * d);
  1052. }
  1053. X
  1054. double
  1055. ddoublelog(x, r)        /* derivative of the double logistic */
  1056. double x, r;
  1057. {
  1058. X    double d;
  1059. X
  1060. X    d = x * x;
  1061. X    return(r * ((2.0 * x) - (6.0 * d) + (4.0 * x * d)));
  1062. }
  1063. X
  1064. void
  1065. init_data()
  1066. {
  1067. X    static int i;
  1068. X
  1069. X    numcolors = XDisplayCells(dpy, XDefaultScreen(dpy));
  1070. X    displayplanes = DisplayPlanes(dpy, XDefaultScreen(dpy));
  1071. X    if (numcolors > maxcolor)
  1072. X        numcolors = maxcolor;
  1073. X    numfreecols = numcolors - mincolindex;
  1074. X    lowrange = mincolindex - startcolor;
  1075. X    a_inc = a_range / (double)width;
  1076. X    b_inc = b_range / (double)height;
  1077. X    point.x = -1;
  1078. X    point.y = 0;
  1079. X    a = rubber_data.p_min = min_a;
  1080. X    b = rubber_data.q_min = min_b;
  1081. X    rubber_data.p_max = max_a;
  1082. X    rubber_data.q_max = max_b;
  1083. X    if (show)
  1084. X        show_defaults();
  1085. X    InitBuffer();
  1086. X    srand48(time(0));
  1087. }
  1088. X
  1089. void
  1090. init_canvas()
  1091. {
  1092. X    static int i;
  1093. X
  1094. X    /*
  1095. X     * create default, writable, graphics contexts for the canvas.
  1096. X     */
  1097. X        for (i=0; i<maxcolor; i++) {
  1098. X            Data_GC[i] = XCreateGC(dpy, DefaultRootWindow(dpy),
  1099. X                (unsigned long) NULL, (XGCValues *) NULL);
  1100. X            /* set the background to black */
  1101. X            XSetBackground(dpy,Data_GC[i],BlackPixel(dpy,XDefaultScreen(dpy)));
  1102. X            /* set the foreground of the ith context to i */
  1103. X            XSetForeground(dpy, Data_GC[i], i);
  1104. X        }
  1105. X        if (displayplanes == 1) {
  1106. X            XSetForeground(dpy,Data_GC[0],BlackPixel(dpy,XDefaultScreen(dpy)));
  1107. X            XSetForeground(dpy,Data_GC[1],WhitePixel(dpy,XDefaultScreen(dpy)));
  1108. X        }
  1109. }
  1110. X
  1111. void
  1112. init_color()
  1113. {
  1114. X    static int i, j, colgap, leg, step;
  1115. X    static Visual *visual;
  1116. X    Colormap def_cmap;
  1117. X    int hls[3], rgb[3];
  1118. X    extern void hls2rgb( int[3], int[3]);
  1119. X
  1120. X    def_cmap = DefaultColormap(dpy, DefaultScreen(dpy));
  1121. X    for (i=0; i<numcolors; i++) {
  1122. X        Colors[i].pixel = i;
  1123. X        Colors[i].flags = DoRed|DoGreen|DoBlue;
  1124. X    }
  1125. X
  1126. X    /* Try to write into a new color map */
  1127. X    visual = DefaultVisual(dpy, DefaultScreen(dpy));
  1128. X    cmap = XCreateColormap(dpy, canvas, visual, AllocAll);
  1129. X    XQueryColors(dpy, def_cmap, Colors, numcolors);
  1130. X    if (mincolindex)
  1131. X        colgap = rgb_max / mincolindex;
  1132. X    else
  1133. X        colgap = rgb_max;
  1134. X    hls[0] = 50;    /* Hue in low range */
  1135. X    hls[2] = 1000;    /* Fully saturated */
  1136. X    for (i=startcolor; i<lowrange + startcolor; i++) {
  1137. X        hls[1] = 1000L * (i-startcolor) / lowrange;
  1138. X        hls2rgb(hls, rgb);
  1139. X        Colors[i].red = rgb[0];
  1140. X        Colors[i].green = rgb[1];
  1141. X        Colors[i].blue = rgb[2];
  1142. X    }
  1143. X    colgap = rgb_max / numcolors;
  1144. X    if (numwheels == 0)
  1145. X        XQueryColors(dpy, def_cmap, Colors, numcolors);
  1146. X    else if (numwheels == 1) {
  1147. X        colgap = 2*rgb_max/(numcolors - color_offset);
  1148. X        for (i=mincolindex; i<(numcolors/2); i++) {
  1149. X            Colors[i].blue = 0;
  1150. X            Colors[i].green=((i+color_offset)*colgap);
  1151. X            Colors[i].red=((i+color_offset)*colgap);
  1152. X        }
  1153. X        for (i=(numcolors/2); i<(numcolors); i++) {
  1154. X            Colors[i].blue = 0;
  1155. X            Colors[i].green=(((numcolors-i)+color_offset)*colgap);
  1156. X            Colors[i].red=(((numcolors-i)+color_offset)*colgap);
  1157. X        }
  1158. X    }
  1159. X    else if (numwheels == 2) {
  1160. X            hls[0] = 800;    /* Hue in mid range */
  1161. X            hls[2] = 1000;    /* Fully saturated */
  1162. X            for (i=startcolor; i<lowrange + startcolor; i++) {
  1163. X            hls[1] = 1000L * (i-startcolor) / lowrange;
  1164. X            hls2rgb(hls, rgb);
  1165. X            Colors[i].red = rgb[0];
  1166. X            Colors[i].green = rgb[1];
  1167. X            Colors[i].blue = rgb[2];
  1168. X            }
  1169. X        for (i=mincolindex; i<(numcolors/2); i++) {
  1170. X            Colors[i].blue = rgb_max;
  1171. X            Colors[i].green = 0;
  1172. X            Colors[i].red=(i*2*rgb_max/numcolors);
  1173. X        }
  1174. X        for (i=(numcolors/2); i<numcolors; i++) {
  1175. X            Colors[i].blue = rgb_max;
  1176. X            Colors[i].green = 0;
  1177. X            Colors[i].red=((numcolors - i)*2*rgb_max/numcolors);
  1178. X        }
  1179. X    }
  1180. X    else if (numwheels == 3) {
  1181. X            hls[0] = 800;    /* Hue in mid range */
  1182. X            hls[2] = 1000;    /* Fully saturated */
  1183. X            for (i=startcolor; i<lowrange + startcolor; i++) {
  1184. X            hls[1] = 1000L * (i-startcolor) / lowrange;
  1185. X            hls2rgb(hls, rgb);
  1186. X            Colors[i].red = rgb[0];
  1187. X            Colors[i].green = rgb[1];
  1188. X            Colors[i].blue = rgb[2];
  1189. X            }
  1190. X        colgap = 4*rgb_max/numcolors;
  1191. X        for (i=mincolindex; i<(numcolors/4); i++) {
  1192. X            Colors[i].blue = rgb_max;
  1193. X            Colors[i].green = 0;
  1194. X            Colors[i].red=(i*colgap);
  1195. X        }
  1196. X        for (i=(numcolors/4); i<(numcolors/2); i++) {
  1197. X            Colors[i].red = rgb_max;
  1198. X            Colors[i].green = 0;
  1199. X            Colors[i].blue=((numcolors/2) - i) * colgap;
  1200. X        }
  1201. X        for (i=(numcolors/2); i<(0.75*numcolors); i++) {
  1202. X            Colors[i].red = rgb_max;
  1203. X            Colors[i].blue=(i * colgap);
  1204. X            Colors[i].green = 0;
  1205. X        }
  1206. X        for (i=(0.75*numcolors); i<numcolors; i++) {
  1207. X            Colors[i].blue = rgb_max;
  1208. X            Colors[i].green = 0;
  1209. X            Colors[i].red=(numcolors-i)*colgap;
  1210. X        }
  1211. X    }
  1212. X    else if (numwheels == 4) {
  1213. X            hls[0] = 800;    /* Hue in mid range */
  1214. X            hls[2] = 1000;    /* Fully saturated */
  1215. X            for (i=startcolor; i<lowrange + startcolor; i++) {
  1216. X            hls[1] = 1000L * (i-startcolor) / lowrange;
  1217. X            hls2rgb(hls, rgb);
  1218. X            Colors[i].red = rgb[0];
  1219. X            Colors[i].green = rgb[1];
  1220. X            Colors[i].blue = rgb[2];
  1221. X            }
  1222. X        colgap = numwheels * rgb_max / numcolors;
  1223. X        for (i=mincolindex; i<(numcolors/numwheels); i++) {
  1224. X            Colors[i].blue = rgb_max;
  1225. X            Colors[i].green = 0;
  1226. X            Colors[i].red=(i*colgap);
  1227. X        }
  1228. X        for (i=(numcolors/numwheels); i<(2*numcolors/numwheels); i++) {
  1229. X            Colors[i].red = rgb_max;
  1230. X            Colors[i].green = 0;
  1231. X            Colors[i].blue=((2*numcolors/numwheels) - i) * colgap;
  1232. X        }
  1233. X        for (i=(2*numcolors/numwheels); i<numcolors; i++) {
  1234. X            Colors[i].red = rgb_max;
  1235. X            Colors[i].green=(i - (2*numcolors/numwheels)) * colgap;
  1236. X            Colors[i].blue = 0;
  1237. X        }
  1238. X    }
  1239. X    else if (numwheels == 5) {
  1240. X        hls[1] = 700;    /* Lightness in midrange */
  1241. X        hls[2] = 1000;    /* Fully saturated */
  1242. X        for (i=mincolindex; i<numcolors; i++) {
  1243. X            hls[0] = 3600L * i / numcolors;
  1244. X            hls2rgb(hls, rgb);
  1245. X            Colors[i].red = rgb[0];
  1246. X            Colors[i].green = rgb[1];
  1247. X            Colors[i].blue = rgb[2];
  1248. X        }
  1249. X        for (i=mincolindex; i<numcolors; i+=stripe_interval) {
  1250. X            hls[0] = 3600L * i / numcolors;
  1251. X            hls2rgb(hls, rgb);
  1252. X            Colors[i].red = rgb[0] / 2;
  1253. X            Colors[i].green = rgb[1] / 2;
  1254. X            Colors[i].blue = rgb[2] / 2;
  1255. X        }
  1256. X    }
  1257. X    else if (numwheels == 6) {
  1258. X        hls[0] = 800;    /* Hue in mid range */
  1259. X        hls[2] = 1000;    /* Fully saturated */
  1260. X        for (i=startcolor; i<lowrange + startcolor; i++) {
  1261. X        hls[1] = 1000L * (i-startcolor) / lowrange;
  1262. X        hls2rgb(hls, rgb);
  1263. X        Colors[i].red = rgb[0];
  1264. X        Colors[i].green = rgb[1];
  1265. X        Colors[i].blue = rgb[2];
  1266. X        }
  1267. X        step = numfreecols / 3;
  1268. X        leg = step+mincolindex;
  1269. X        for (i = mincolindex; i < leg; ++i)
  1270. X        {
  1271. X        Colors[i].pixel = i;
  1272. X        Colors[i].red = fabs(65535 - (double)i / step * 65535.0);
  1273. X        Colors[i].blue = (double)i / step * 65535.0;
  1274. X        Colors[i].green = 0;
  1275. X        Colors[i].flags = DoRed | DoGreen | DoBlue;
  1276. X        }
  1277. X        for (j = 0, i = leg, leg += step; i < leg; ++i, ++j)
  1278. X        {
  1279. X        Colors[i].pixel = i;
  1280. X        Colors[i].red = (double)j / step * 65535.0;
  1281. X        Colors[i].blue = 65535;
  1282. X        Colors[i].green = Colors[i].red;
  1283. X        Colors[i].flags = DoRed | DoGreen | DoBlue;
  1284. X        }
  1285. X        for (j = 0, i = leg, leg += step; i < leg; ++i, ++j)
  1286. X        {
  1287. X        Colors[i].pixel = i;
  1288. X        Colors[i].red = 65535;
  1289. X        Colors[i].blue = fabs(65535 - (double)j / step * 65535.0);
  1290. X        Colors[i].green = Colors[i].blue;
  1291. X        Colors[i].flags = DoRed | DoGreen | DoBlue;
  1292. X        }
  1293. X    }
  1294. X    else if (numwheels == MAXWHEELS) {    /* rainbow palette */
  1295. X        hls[1] = 500;    /* Lightness in midrange */
  1296. X        hls[2] = 1000;    /* Fully saturated */
  1297. X        for (i=mincolindex; i<numcolors; i++) {
  1298. X            hls[0] = 3600L * i / numcolors;
  1299. X            hls2rgb(hls, rgb);
  1300. X            Colors[i].red = rgb[0];
  1301. X            Colors[i].green = rgb[1];
  1302. X            Colors[i].blue = rgb[2];
  1303. X        }
  1304. X    }
  1305. X    XStoreColors(dpy, cmap, Colors, numcolors);
  1306. }
  1307. X
  1308. void
  1309. parseargs(ac, av)
  1310. int ac;
  1311. char **av;
  1312. {
  1313. X    static int c;
  1314. X    static int i;
  1315. X    int bindex=0, findex;
  1316. X    char *ch;
  1317. X    extern int optind;
  1318. X    extern char *optarg;
  1319. X    extern double atof();
  1320. X    extern void check_params(), usage();
  1321. X
  1322. X    map = Maps[0];
  1323. X    deriv = Derivs[0];
  1324. X    maxexp=minlyap; minexp= -1.0 * minlyap;
  1325. X
  1326. X    while ((c=getopt(ac,av,
  1327. X        "Lpuvc:i:m:C:W:H:M:N:O:R:S:a:b:D:F:f:o:w:h:r:s:x:y:"))!=EOF){
  1328. X        switch (c) {
  1329. X        case 'C':    mincolindex=atoi(optarg); break;
  1330. X        case 'D':    dwell=atoi(optarg); break;
  1331. #ifdef MAPS
  1332. X        case 'F':    funcmaxindex = strlen(optarg);
  1333. X                if (funcmaxindex > FUNCMAXINDEX)
  1334. X                    usage();
  1335. X                ch = optarg;
  1336. X                Force++;
  1337. X                for (findex=0;findex<funcmaxindex;findex++) {
  1338. X                    Forcing[findex] = (int)(*ch++ - '0');;
  1339. X                    if (Forcing[findex] >= NUMMAPS)
  1340. X                        usage();
  1341. X                }
  1342. X                break;
  1343. #endif
  1344. X        case 'H':    height=atoi(optarg); break;
  1345. X        case 'L':    useprod=0; break;
  1346. X        case 'M':    minlyap=ABS(atof(optarg)); 
  1347. X                maxexp=minlyap; minexp= -1.0 * minlyap; break;
  1348. X        case 'N':    maxcolor=ABS(atoi(optarg)); 
  1349. X                if ((maxcolor - startcolor) <= 0)
  1350. X                    startcolor = 0;
  1351. X                if ((maxcolor - mincolindex) <= 0) {
  1352. X                    mincolindex = 1;
  1353. X                    color_offset = 0;
  1354. X                }
  1355. X                break;
  1356. X        case 'O':    color_offset=atoi(optarg); break;
  1357. X        case 'R':    prob=atof(optarg); Rflag++; setforcing(); break;
  1358. X        case 'S':    settle=atoi(optarg); break;
  1359. X        case 'W':    width=atoi(optarg); break;
  1360. X        case 'a':    min_a=atof(optarg); aflag++; break;
  1361. X        case 'b':    min_b=atof(optarg); bflag++; break;
  1362. X        case 'c':    numwheels=atoi(optarg); break;
  1363. X        case 'f':    maxindex = strlen(optarg);
  1364. X                if (maxindex > MAXINDEX)
  1365. X                    usage();
  1366. X                ch = optarg;
  1367. X                force++;
  1368. X                while (bindex < maxindex) {
  1369. X                    if (*ch == 'a')
  1370. X                        forcing[bindex++] = 0;
  1371. X                    else if (*ch == 'b')
  1372. X                        forcing[bindex++] = 1;
  1373. X                    else
  1374. X                        usage();
  1375. X                    ch++;
  1376. X                }
  1377. X                break;
  1378. X        case 'h':    b_range=atof(optarg); hflag++; break;
  1379. X        case 'i':    start_x=atof(optarg); break;
  1380. X        case 'm':    mapindex=atoi(optarg); 
  1381. X                if ((mapindex >= NUMMAPS) || (mapindex < 0))
  1382. X                    usage();
  1383. X                map = Maps[mapindex];
  1384. X                deriv = Derivs[mapindex];
  1385. X                if (!aflag)
  1386. X                    min_a = amins[mapindex];
  1387. X                if (!wflag)
  1388. X                    a_range = aranges[mapindex];
  1389. X                if (!bflag)
  1390. X                    min_b = bmins[mapindex];
  1391. X                if (!hflag)
  1392. X                    b_range = branges[mapindex];
  1393. X                if (!Force)
  1394. X                    for (i=0;i<FUNCMAXINDEX;i++)
  1395. X                        Forcing[i] = mapindex;
  1396. X                break;
  1397. X        case 'o':    savefile++; outname=optarg; break;
  1398. X        case 'p':    negative--; break;
  1399. X        case 'r':    rgb_max=atoi(optarg); break;
  1400. X        case 's':    spinlength=atoi(optarg); break;
  1401. X        case 'u':    usage(); break;
  1402. X        case 'v':    show=1; break;
  1403. X        case 'w':    a_range=atof(optarg); wflag++; break;
  1404. X        case 'x':    xposition=atoi(optarg); break;
  1405. X        case 'y':    yposition=atoi(optarg); break;
  1406. X        case '?':    usage(); break;
  1407. X        }
  1408. X    }
  1409. X    max_a = min_a + a_range;
  1410. X    max_b = min_b + b_range;
  1411. X        a_minimums[0] = min_a; b_minimums[0] = min_b;
  1412. X        a_maximums[0] = max_a; b_maximums[0] = max_b;
  1413. X    if (Force)
  1414. X        if (maxindex == funcmaxindex)
  1415. X            for (findex=0;findex<funcmaxindex;findex++)
  1416. X            check_params(Forcing[findex],forcing[findex]);
  1417. X        else
  1418. X            fprintf(stderr, "Warning! Unable to check parameters\n");
  1419. X    else
  1420. X        check_params(mapindex,2);
  1421. }
  1422. X
  1423. void
  1424. check_params(mapnum, parnum)
  1425. int mapnum;
  1426. int parnum;
  1427. {
  1428. X
  1429. X    if (parnum != 1) {
  1430. X        if ((max_a > pmaxs[mapnum]) || (min_a < pmins[mapnum])) {
  1431. X        fprintf(stderr, "Warning! Parameter 'a' out of range.\n");
  1432. X        fprintf(stderr, "You have requested a range of (%f,%f).\n",
  1433. X            min_a,max_a);
  1434. X        fprintf(stderr, "Valid range is (%f,%f).\n",
  1435. X            pmins[mapnum],pmaxs[mapnum]);
  1436. X        }
  1437. X    }
  1438. X    if (parnum != 0) {
  1439. X        if ((max_b > pmaxs[mapnum]) || (min_b < pmins[mapnum])) {
  1440. X        fprintf(stderr, "Warning! Parameter 'b' out of range.\n");
  1441. X        fprintf(stderr, "You have requested a range of (%f,%f).\n",
  1442. X            min_b,max_b);
  1443. X        fprintf(stderr, "Valid range is (%f,%f).\n",
  1444. X            pmins[mapnum],pmaxs[mapnum]);
  1445. X        }
  1446. X    }
  1447. }
  1448. X
  1449. void
  1450. usage()
  1451. {
  1452. X    fprintf(stderr,"lyap [-BLs][-W#][-H#][-a#][-b#][-w#][-h#][-x xstart]\n");
  1453. X    fprintf(stderr,"\t[-M#][-S#][-D#][-f string][-r#][-O#][-C#][-c#][-m#]\n");
  1454. #ifdef MAPS
  1455. X    fprintf(stderr,"\t[-F string]\n");
  1456. #endif
  1457. X    fprintf(stderr,"\tWhere: -C# specifies the minimum color index\n");
  1458. X    fprintf(stderr,"\t       -r# specifies the maxzimum rgb value\n");
  1459. X    fprintf(stderr,"\t       -u displays this message\n");
  1460. X    fprintf(stderr,"\t       -a# specifies the minimum horizontal parameter\n");
  1461. X    fprintf(stderr,"\t       -b# specifies the minimum vertical parameter\n");
  1462. X    fprintf(stderr,"\t       -w# specifies the horizontal parameter range\n");
  1463. X    fprintf(stderr,"\t       -h# specifies the vertical parameter range\n");
  1464. X    fprintf(stderr,"\t       -D# specifies the dwell\n");
  1465. X    fprintf(stderr,"\t       -S# specifies the settle\n");
  1466. X    fprintf(stderr,"\t       -H# specifies the initial window height\n");
  1467. X    fprintf(stderr,"\t       -W# specifies the initial window width\n");
  1468. X    fprintf(stderr,"\t       -O# specifies the color offset\n");
  1469. X    fprintf(stderr,"\t       -c# specifies the desired color wheel\n");
  1470. X    fprintf(stderr,"\t       -m# specifies the desired map (0-4)\n");
  1471. X    fprintf(stderr,"\t       -f aabbb specifies a forcing function of 00111\n");
  1472. #ifdef MAPS
  1473. X    fprintf(stderr,"\t       -F 00111 specifies the function forcing function\n");
  1474. #endif
  1475. X    fprintf(stderr,"\t       -L indicates use log(x)+log(y) rather than log(xy)\n");
  1476. X    fprintf(stderr,"\tDuring display :\n");
  1477. X    fprintf(stderr,"\t     Use the mouse to zoom in on an area\n");
  1478. X    fprintf(stderr,"\t     e or E recalculates color indices\n");
  1479. X    fprintf(stderr,"\t     f or F saves exponents to a file\n");
  1480. X    fprintf(stderr,"\t     KJmn increase/decrease minimum negative exponent\n");
  1481. X    fprintf(stderr,"\t     r or R redraws\n");
  1482. X    fprintf(stderr,"\t     s or S spins the colorwheel\n");
  1483. X    fprintf(stderr,"\t     w or W changes the color wheel\n");
  1484. X    fprintf(stderr,"\t     x or X clears the window\n");
  1485. X    fprintf(stderr,"\t     q or Q exits\n");
  1486. X    exit(1);
  1487. }
  1488. X
  1489. Cycle_frames()
  1490. {
  1491. X    static int i;
  1492. X    extern void redraw();
  1493. X
  1494. X    for (i=0;i<=maxframe;i++)
  1495. X        redraw(exponents[i], expind[i], 1); 
  1496. }
  1497. X        
  1498. void
  1499. Spin(w)
  1500. Window w;
  1501. {
  1502. X    static int i, j;
  1503. X    long tmpxcolor;
  1504. X
  1505. X    if (displayplanes > 1) {
  1506. X        for (j=0;j<spinlength;j++) {
  1507. X            tmpxcolor = Colors[mincolindex].pixel;
  1508. X            for (i=mincolindex;i<numcolors-1;i++)
  1509. X                Colors[i].pixel = Colors[i+1].pixel;
  1510. X            Colors[numcolors-1].pixel = tmpxcolor;
  1511. X            XStoreColors(dpy, cmap, Colors, numcolors);
  1512. X        }
  1513. X        for (j=0;j<spinlength;j++) {
  1514. X            tmpxcolor = Colors[numcolors-1].pixel;
  1515. X            for (i=numcolors-1;i>mincolindex;i--)
  1516. X                Colors[i].pixel = Colors[i-1].pixel;
  1517. X            Colors[mincolindex].pixel = tmpxcolor;
  1518. X            XStoreColors(dpy, cmap, Colors, numcolors);
  1519. X        }
  1520. X    }
  1521. }
  1522. X
  1523. Getkey(event)
  1524. XXKeyEvent *event;
  1525. {
  1526. X    unsigned char key;
  1527. X    static int i;
  1528. X    extern void init_color(), recalc(), print_values(), print_help();
  1529. X    extern void go_init(), go_back(), go_down(), Clear();
  1530. X    extern void save_to_file(), Redraw(), redraw();
  1531. X
  1532. X        if (XLookupString(event, (char *)&key, sizeof(key), (KeySym *)0,
  1533. X            (XComposeStatus *) 0) > 0)
  1534. X                switch (key) {
  1535. X    case '<': dwell /= 2; if (dwell < 1) dwell = 1; break;
  1536. X    case '>': dwell *= 2; break;
  1537. X    case '[': settle /= 2; if (settle < 1) settle = 1; break;
  1538. X    case ']': settle *= 2; break;
  1539. X    case 'd': go_down(); break;
  1540. X    case 'D': FlushBuffer(); break;
  1541. X    case 'e':
  1542. X    case 'E': FlushBuffer();
  1543. X          dorecalc = (!dorecalc);
  1544. X          if (dorecalc)
  1545. X            recalc(); 
  1546. X          else {
  1547. X            maxexp = minlyap; minexp = -1.0 * minlyap;
  1548. X          }
  1549. X          redraw(exponents[frame], expind[frame], 1);
  1550. X          break;
  1551. X    case 'f':
  1552. X    case 'F': save_to_file(); break;
  1553. X    case 'i': if (stripe_interval > 0) {
  1554. X            stripe_interval--;
  1555. X              if (displayplanes > 1) {
  1556. X                  init_color(); 
  1557. X                  XSetWindowColormap(dpy, canvas, cmap);
  1558. X              }
  1559. X          }
  1560. X          break;
  1561. X    case 'I': stripe_interval++;
  1562. X          if (displayplanes > 1) {
  1563. X              init_color(); 
  1564. X              XSetWindowColormap(dpy, canvas, cmap);
  1565. X          }
  1566. X          break;
  1567. X    case 'K': if (minlyap > 0.05)
  1568. X            minlyap -= 0.05;
  1569. X           break;
  1570. X    case 'J': minlyap += 0.05; 
  1571. X           break;
  1572. X    case 'm': mapindex++;
  1573. X                  if (mapindex >= NUMMAPS)
  1574. X                        mapindex=0;
  1575. X                  map = Maps[mapindex];
  1576. X                  deriv = Derivs[mapindex];
  1577. X          if (!aflag)
  1578. X                        min_a = amins[mapindex];
  1579. X                  if (!wflag)
  1580. X                        a_range = aranges[mapindex];
  1581. X                  if (!bflag)
  1582. X                        min_b = bmins[mapindex];
  1583. X                  if (!hflag)
  1584. X                        b_range = branges[mapindex];
  1585. X                  if (!Force)
  1586. X                        for (i=0;i<FUNCMAXINDEX;i++)
  1587. X                             Forcing[i] = mapindex;
  1588. X              max_a = min_a + a_range;
  1589. X              max_b = min_b + b_range;
  1590. X              a_minimums[0] = min_a; b_minimums[0] = min_b;
  1591. X              a_maximums[0] = max_a; b_maximums[0] = max_b;
  1592. X              a_inc = a_range / (double)width;
  1593. X              b_inc = b_range / (double)height;
  1594. X              point.x = -1;
  1595. X              point.y = 0;
  1596. X              a = rubber_data.p_min = min_a;
  1597. X              b = rubber_data.q_min = min_b;
  1598. X              rubber_data.p_max = max_a;
  1599. X              rubber_data.q_max = max_b;
  1600. X                  Clear();
  1601. X                  break;
  1602. X    case 'M': if (minlyap > 0.005)
  1603. X            minlyap -= 0.005;
  1604. X           break;
  1605. X    case 'N': minlyap += 0.005;
  1606. X           break;
  1607. X    case 'p':
  1608. X    case 'P': negative = (!negative); 
  1609. X          FlushBuffer(); redraw(exponents[frame], expind[frame], 1); 
  1610. X          break;
  1611. X    case 'r': FlushBuffer(); redraw(exponents[frame], expind[frame], 1); 
  1612. X          break;
  1613. X    case 'R': FlushBuffer(); Redraw(); break;
  1614. X    case 's':
  1615. X           spinlength=spinlength/2;
  1616. X    case 'S': if (displayplanes > 1) 
  1617. X            Spin(canvas); 
  1618. X           spinlength=spinlength*2; break;
  1619. X    case 'u': go_back(); break;
  1620. X    case 'U': go_init(); break;
  1621. X    case 'v':
  1622. X    case 'V': print_values(); break;
  1623. X    case 'W': if (numwheels < MAXWHEELS)
  1624. X            numwheels++;
  1625. X           else
  1626. X            numwheels = 0;
  1627. X           if (displayplanes > 1) {
  1628. SHAR_EOF
  1629. true || echo 'restore of lyap.c failed'
  1630. fi
  1631. echo 'End of  part 1'
  1632. echo 'File lyap.c is continued in part 2'
  1633. echo 2 > _shar_seq_.tmp
  1634. exit 0
  1635. -- 
  1636. --
  1637. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1638. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1639. Sunnyvale, California 94086            at&t: 408/522-9236
  1640.