char *progclass = "XLyap";
char *defaults [] = {
- "XLyap.background: black", /* to placate SGI */
+ ".background: black",
+ ".foreground: white",
"*randomize: false",
"*builtin: -1",
"*minColor: 1",
#ifdef SIXTEEN_COLORS
#define MAXPOINTS 128
+#ifdef BIGMEM
#define MAXFRAMES 4
+#else
+#define MAXFRAMES 2
+#endif
#define MAXCOLOR 16
static int maxcolor=16, startcolor=0, color_offset=0, mincolindex=1;
static int dwell=50, settle=25;
static int width=128, height=128, xposition=128, yposition=128;
#else
#define MAXPOINTS 256
+#ifdef BIGMEM
#define MAXFRAMES 8
+#else
+#define MAXFRAMES 2
+#endif
#define MAXCOLOR 256
static int maxcolor=256, startcolor=17, color_offset=96, mincolindex=33;
static int dwell=100, settle=50;
break;
case ButtonRelease:
EndRubberBand(canvas, &rubber_data, &event);
+ break;
+ default:
+ screenhack_handle_event (dpy, &event);
break;
}
}
static int
complyap(void)
{
- register i, bindex;
- double total, prod, x, r;
+ int i, bindex;
+ double total, prod, x, dx, r;
if (!run)
return TRUE;
a += a_inc;
- if (a >= max_a)
+ if (a >= max_a) {
if (sendpoint(lyapunov) == TRUE)
return FALSE;
else {
save_to_file();
return TRUE;
}
+ }
if (b >= max_b) {
FlushBuffer();
if (savefile)
if (useprod) { /* using log(a*b) */
for (i=0;i<dwell;i++) {
x = (*map)(x, r);
- prod *= ABS((*deriv)(x, r));
+ dx = (*deriv)(x, r); /* ABS is a macro, so don't be fancy */
+ dx = ABS(dx);
+ if (dx == 0.0) /* log(0) is nasty so break out. */
+ {
+ i++;
+ break;
+ }
+ prod *= dx;
/* we need to prevent overflow and underflow */
if ((prod > 1.0e12) || (prod < 1.0e-12)) {
total += log(prod);
#endif
}
total += log(prod);
- lyapunov = (total * M_LOG2E) / (double)dwell;
+ lyapunov = (total * M_LOG2E) / (double)i;
}
else { /* use log(a) + log(b) */
for (i=0;i<dwell;i++) {
x = (*map)(x, r);
- total += log(ABS((*deriv)(x, r)));
+ dx = (*deriv)(x, r); /* ABS is a macro, so don't be fancy */
+ dx = ABS(dx);
+ if (x == 0.0) /* log(0) check */
+ {
+ i++;
+ break;
+ }
+ total += log(dx);
if (++bindex >= maxindex) {
bindex = 0;
if (Rflag)
deriv = Derivs[Forcing[findex]];
#endif
}
- lyapunov = (total * M_LOG2E) / (double)dwell;
+ lyapunov = (total * M_LOG2E) / (double)i;
}
+
if (sendpoint(lyapunov) == TRUE)
return FALSE;
else {
if (show)
show_defaults();
InitBuffer();
- ya_rand_init(0);
}
static void
static int index;
static double tmpexpo;
+#if 0
+/* The relationship minexp <= expo <= maxexp should always be true. This test
+ enforces that. But maybe not enforcing it makes better pictures. */
+ if (expo < minexp)
+ expo = minexp;
+ else if (expo > maxexp)
+ expo = maxexp;
+#endif
+
point.x++;
tmpexpo = (negative) ? expo : -1.0 * expo;
if (tmpexpo > 0) {
static void
BufferPoint(Display *display, Window window, int color, int x, int y)
{
+
+/* Guard against bogus color values. Shouldn't be necessary but paranoia
+ is good. */
+ if (color < 0)
+ color = 0;
+ else if (color >= maxcolor)
+ color = maxcolor - 1;
+
if (Points.npoints[color] == MAXPOINTS)
{
XDrawPoints(display, window, Data_GC[color],
{
static int i;
for (i=0;i<MAXINDEX;i++)
- forcing[i] = (ya_random() > prob) ? 0 : 1;
+ forcing[i] = (random() > prob) ? 0 : 1;
}