#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Makefile Makefile.example symcon.c tree.c tree.h
# Wrapped by karin@borodin on Wed Jul 24 21:43:25 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(1995 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XCFLAGS = ${DFLAGS} -g -Bstatic
XLFLAGS = $(DFLAGS) -g
XPROGRAM = symcon
XOBJS = $(PROGRAM).o graphic.o postscript.o matalloc.o matutil.o matio.o mattrans.o\
X        fileio.o group.o general.o\
X        tree.o gauss_newton.o break.o no_break.o continuation.o
Xdefault: all
X
XUSEROBJS =  brussD4.o
X
Xdefault: all
X
X$(USEROBJS):    group.h general.h matalloc.h macros.h 
Xmatalloc.o:     macros.h matalloc.h matalloc.c
Xmatutil.o:      macros.h matutil.h matutil.c matalloc.h matalloc.c
Xmatio.o:        macros.h matio.h matio.c
Xmattrans.o:     macros.h matalloc.h matutil.h mattrans.h mattrans.c
Xgauss_newton.o: macros.h matalloc.h matutil.h mattrans.h gauss_newton.h \
X                gauss_newton.c
Xgraphic.o:      macros.h graphic.h graphic.c
Xpostscript.o:   macros.h graphic.h postscript.h postscript.c
Xgroup.o:        macros.h matalloc.h matio.h general.h group.h group.c
Xtree.o:         macros.h matalloc.h matutil.h graphic.h group.h tree.h tree.c
Xcontinuation.o: macros.h group.h tree.h gauss_newton.h general.h \
X                continuation.h continuation.c
Xbreak.o:        macros.h matalloc.h matutil.h mattrans.h \
X                group.h tree.h general.h continuation.h gauss_newton.h \
X                break.h break.c
Xno_break.o:     macros.h matalloc.h matutil.h mattrans.h \
X                group.h tree.h general.h continuation.h gauss_newton.h \
X                break.h no_break.h no_break.c
Xgeneral.o:      macros.h matalloc.h matutil.h mattrans.h \
X                group.h tree.h gauss_newton.h break.h no_break.h \
X                continuation.h general.h general.c
Xfileio.o:       macros.h fileio.h fileio.c
Xsymcon.o:         macros.h graphic.h postscript.h matalloc.h  matutil.h\
X                mattrans.h fileio.h group.h\
X                tree.h gauss_newton.h break.h no_break.h continuation.h\
X                general.h symcon.c
X
Xall: $(PROGRAM) 
X
X$(PROGRAM): $(OBJS) $(USEROBJS) Makefile
X	cc $(CFLAGS) $(OBJS) $(USEROBJS) -o $(PROGRAM) -lm -lsuntool -lsunwindow -lpixrect
X
X
X
X
X
X
X
X
END_OF_FILE
if test 1995 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'Makefile.example' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile.example'\"
else
echo shar: Extracting \"'Makefile.example'\" \(1995 characters\)
sed "s/^X//" >'Makefile.example' <<'END_OF_FILE'
XCFLAGS = ${DFLAGS} -g -Bstatic
XLFLAGS = $(DFLAGS) -g
XPROGRAM = symcon
XOBJS = $(PROGRAM).o graphic.o postscript.o matalloc.o matutil.o matio.o mattrans.o\
X        fileio.o group.o general.o\
X        tree.o gauss_newton.o break.o no_break.o continuation.o
Xdefault: all
X
XUSEROBJS =  example.o
X
Xdefault: all
X
X$(USEROBJS):    group.h general.h matalloc.h macros.h 
Xmatalloc.o:     macros.h matalloc.h matalloc.c
Xmatutil.o:      macros.h matutil.h matutil.c matalloc.h matalloc.c
Xmatio.o:        macros.h matio.h matio.c
Xmattrans.o:     macros.h matalloc.h matutil.h mattrans.h mattrans.c
Xgauss_newton.o: macros.h matalloc.h matutil.h mattrans.h gauss_newton.h \
X                gauss_newton.c
Xgraphic.o:      macros.h graphic.h graphic.c
Xpostscript.o:   macros.h graphic.h postscript.h postscript.c
Xgroup.o:        macros.h matalloc.h matio.h general.h group.h group.c
Xtree.o:         macros.h matalloc.h matutil.h graphic.h group.h tree.h tree.c
Xcontinuation.o: macros.h group.h tree.h gauss_newton.h general.h \
X                continuation.h continuation.c
Xbreak.o:        macros.h matalloc.h matutil.h mattrans.h \
X                group.h tree.h general.h continuation.h gauss_newton.h \
X                break.h break.c
Xno_break.o:     macros.h matalloc.h matutil.h mattrans.h \
X                group.h tree.h general.h continuation.h gauss_newton.h \
X                break.h no_break.h no_break.c
Xgeneral.o:      macros.h matalloc.h matutil.h mattrans.h \
X                group.h tree.h gauss_newton.h break.h no_break.h \
X                continuation.h general.h general.c
Xfileio.o:       macros.h fileio.h fileio.c
Xsymcon.o:         macros.h graphic.h postscript.h matalloc.h  matutil.h\
X                mattrans.h fileio.h group.h\
X                tree.h gauss_newton.h break.h no_break.h continuation.h\
X                general.h symcon.c
X
Xall: $(PROGRAM) 
X
X$(PROGRAM): $(OBJS) $(USEROBJS) Makefile
X	cc $(CFLAGS) $(OBJS) $(USEROBJS) -o $(PROGRAM) -lm -lsuntool -lsunwindow -lpixrect
X
X
X
X
X
X
X
X
END_OF_FILE
if test 1995 -ne `wc -c <'Makefile.example'`; then
    echo shar: \"'Makefile.example'\" unpacked with wrong size!
fi
# end of 'Makefile.example'
fi
if test -f 'symcon.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'symcon.c'\"
else
echo shar: Extracting \"'symcon.c'\" \(50712 characters\)
sed "s/^X//" >'symcon.c' <<'END_OF_FILE'
X/* version - 0.3 A. Hohmann 24.7.91 */
X
X#include <strings.h>
X#include <stdio.h>
X#include <math.h>
X#include <malloc.h>
X
X#include <suntool/sunview.h>
X#include <suntool/canvas.h>
X#include <suntool/panel.h>
X#include <suntool/alert.h>
X#include <suntool/tty.h>
X#include <suntool/textsw.h>
X#include <suntool/scrollbar.h>
X
X#include "macros.h"
X#include "fileio.h"
X#include "graphic.h"
X#include "postscript.h"
X
X#include "matalloc.h"
X#include "matutil.h"
X#include "mattrans.h"
X
X#include "group.h"
X#include "tree.h"
X#include "gauss_newton.h"
X#include "break.h"
X#include "no_break.h"
X#include "continuation.h"
X#include "general.h"
X
X#define X_MIN       0.0
X#define X_MAX       4.0
X#define Y_MIN       0.5
X#define Y_MAX       7.5
X           
X#define REDUCTION_MAX   3
X#define RHO             0.3
X
X/*--------------------------------------------------------------------
X    local data
X----------------------------------------------------------------------*/
X
Xstatic char *y_format = "%.2lf", *par_format = "%.2lf";
X
X/*--------------------------------------------------------------------
X    file I/O    
X----------------------------------------------------------------------*/
X
Xstatic int print_options = 0;
Xstatic char print_file[30];
X
Xstatic int old_x_index, old_y_index;
X
XFILE_ERROR read_data(fname)
X    char *fname;
X{
X    FILE *f;
X    
X    if (fname == NULL) return PARS;
X    if ((f = fopen(fname, "r")) == NULL) return ROPEN;
X    if (!fread_picture(f, picture))             return READ;
X    if (!fscanf(f, "%s\n", print_file))     return FALSE;
X    if (!fread_int(f, &print_options))  return READ;
X    if (!fread_vector(f, par, 1, npar))         return READ;
X    if (!fread_vector(f, y_guess, 1, n))        return READ;
X    if (!fread_int(f, &gn_option))              return READ;
X    if (!fread_int(f, &steplength_control))     return READ;
X    if (!fread_int(f, &x_index))    return READ;
X    if (!fread_int(f, &plot_norm))  return READ;
X    if (!fread_int(f, &y_index))    return READ;
X    if (!fread_real(f, &eps))                   return READ;
X    if (!fread_real(f, &steplength))            return READ;
X    if (!fread_real(f, &tau_min))               return READ;
X    if (!fread_real(f, &tau_max))               return READ;
X    if (fclose(f) == EOF) return RCLOSE;
X    return FILE_OK;
X}
X    
XFILE_ERROR save_data(fname)
X    char *fname;
X{
X    FILE *f;
X    
X    if (fname == NULL) return PARS;
X    if ((f = fopen(fname, "w")) == NULL) return WOPEN;
X    if (!fwrite_picture(f, picture))            return WRITE;
X    if (!fprintf(f, "%s\n", print_file))        return FALSE;
X    if (!fwrite_int(f, &print_options))     return WRITE;
X    if (!fwrite_vector(f, par, 1, npar))        return WRITE;
X    if (!fwrite_vector(f, y_guess, 1, n))       return WRITE;
X    if (!fwrite_int(f, &gn_option))             return WRITE;
X    if (!fwrite_int(f, &steplength_control))    return WRITE;
X    if (!fwrite_int(f, &x_index))   return WRITE;
X    if (!fwrite_int(f, &plot_norm))     return WRITE;
X    if (!fwrite_int(f, &y_index))   return WRITE;
X    if (!fwrite_real(f, &eps))                  return WRITE;
X    if (!fwrite_real(f, &steplength))           return WRITE;
X    if (!fwrite_real(f, &tau_min))              return WRITE;
X    if (!fwrite_real(f, &tau_max))              return WRITE;
X    if (fclose(f) == EOF) return WCLOSE;
X    return FILE_OK;
X}
X    
X/*--------------------------------------------------------------------
X    file sub panel  
X----------------------------------------------------------------------*/
X
Xstatic Frame file_frame;
Xstatic Panel file_panel;
Xstatic Panel_item   io_file_item;
X
Xstatic void file_cancel_proc(), file_done_proc(), /* file_apply_proc(), */ read_proc(), save_proc();
X
Xstatic void create_file_popup()
X{
X    int i, row=0;
X    
X    file_frame = window_create(frame, FRAME, 0);
X    file_panel = window_create(file_frame, PANEL, 0);
X    
X    panel_create_item(file_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(3),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "read and save data",
X        0);
X    
X    row++;
X    io_file_item = panel_create_item(file_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "filename:",
X        PANEL_VALUE_DISPLAY_LENGTH, 20,
X        0);
X        
X    row++;  
X    panel_create_item(file_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "read data", 0, 0),
X        PANEL_NOTIFY_PROC,      read_proc,
X        0);
X    
X    panel_create_item(file_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "save data", 0, 0),
X        PANEL_NOTIFY_PROC,      save_proc,
X        0);
X    
X    row++;
X    panel_create_item(file_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Done", 0, 0),
X        PANEL_NOTIFY_PROC,      file_done_proc,
X        0);
X    
X/*  panel_create_item(file_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(10),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Apply", 0, 0),
X        PANEL_NOTIFY_PROC,      file_apply_proc,
X        0);  */
X    
X    panel_create_item(file_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(20),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Cancel", 0, 0),
X        PANEL_NOTIFY_PROC,      file_cancel_proc,
X        0);
X    
X    window_fit(file_panel);
X    window_fit(file_frame);
X}
X
Xstatic void file_popup_proc()
X{
X    panel_set_value(io_file_item, picture->io_file);
X    window_set(file_frame, WIN_SHOW, TRUE, 0);
X}
X
Xstatic void set_file_values()
X{
X    strcpy(picture->io_file, panel_get_value(io_file_item));
X}
X
XBOOLEAN old_auto_scaling;
XREAL old_x_min, old_x_max, old_y_min, old_y_max;
Xint old_scale_size;
X
Xstatic void read_proc()
X{
X    FILE_ERROR file_error;
X    
X    set_file_values();
X        old_x_index = x_index;
X        old_y_index = y_index;
X        old_auto_scaling = picture->auto_scaling;
X        old_scale_size = picture->scale_size;
X        old_x_min = picture->x_min;
X        old_x_max = picture->x_max;
X        old_y_min = picture->y_min;
X        old_y_max = picture->y_max;
X    if ((file_error = read_data(picture->io_file)) != FILE_OK) {
X        file_error_alert(frame, file_error);
X    } 
X        else {  setpar();
X                if ( x_index != old_x_index || y_index != old_y_index ||
X                     picture->auto_scaling != old_auto_scaling ||
X                     picture->scale_size != old_scale_size ||
X                    (picture->auto_scaling == FALSE && (picture->x_min != old_x_min ||
X                                                    picture->x_max != old_x_max ||
X                                                    picture->y_max != old_y_max ||
X                                                    picture->y_min != old_y_min) )
X                                                                    ) {
X        free_line(picture->line);       picture->line       = nil;
X        free_text(picture->text);       picture->marker     = nil;
X        free_marker(picture->marker);   picture->text       = nil;
X            create_axes();
X        draw_diagram();
X                }
X        }
X}
X
Xstatic void save_proc()
X{
X    FILE_ERROR file_error;
X    
X    set_file_values();
X    if ((file_error = save_data(picture->io_file)) != FILE_OK) {
X        file_error_alert(frame, file_error);
X    }
X}
X
Xstatic void file_done_proc()
X{
X    set_file_values();
X    window_set(file_frame, WIN_SHOW, FALSE, 0);
X}
X
Xstatic void data_ok_proc(), data_cancel_proc();
Xstatic void graphic_ok_proc(), graphic_cancel_proc();
Xstatic void control_ok_proc(), control_cancel_proc();
Xstatic void plot_done_proc(), plot_cancel_proc(), send_to_laserwriter(),
X            make_postscript_file();
Xstatic void print_done_proc(), print_cancel_proc(), print_group(),
X            print_bifurcations();
X
X
X/* static void file_apply_proc()
X{
X    set_file_values();
X    control_ok_proc();  
X        graphic_ok_proc();
X        plot_done_proc();
X        print_done_proc();
X        data_ok_proc();      
X} */
X
X
Xstatic void file_cancel_proc()
X{
X    window_set(file_frame, WIN_SHOW, FALSE, 0);
X}
X
X/*--------------------------------------------------------------------
X    data sub panel  
X----------------------------------------------------------------------*/
X
Xstatic Frame data_frame;
Xstatic Panel data_panel;
X
Xstatic Panel_item *y_guess_item, *par_item;
X
Xstatic void create_data_popup()
X{
X    int i, row=0;
X    
X    y_guess_item    = panel_item_vector(1, n);
X    par_item        = panel_item_vector(1, npar);
X    
X    data_frame = window_create(frame, FRAME, 0);
X    data_panel = window_create(data_frame, PANEL, 0);
X    
X    panel_create_item(data_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(15),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "Set Data",
X        0);
X    
X    panel_create_item(data_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "initial guess",
X        0);
X    
X    for (i=1, row++; i<=n; i++) {
X        sprintf(str, "y[%d] =", i);
X        if (i % 2 == 1) {
X            y_guess_item[i] = panel_create_item(data_panel, PANEL_TEXT,
X                PANEL_ITEM_X,               ATTR_COL(0),
X                PANEL_ITEM_Y,               ATTR_ROW(row),
X                PANEL_LABEL_STRING,         str,
X                PANEL_VALUE_DISPLAY_LENGTH, 10,
X                0);
X        }
X        else {
X            y_guess_item[i] = panel_create_item(data_panel, PANEL_TEXT,
X                PANEL_ITEM_X,               ATTR_COL(20),
X                PANEL_ITEM_Y,               ATTR_ROW(row++),
X                PANEL_LABEL_STRING,         str,
X                PANEL_VALUE_DISPLAY_LENGTH, 10,
X                0);
X        }
X    }
X    row+=2;
X    panel_create_item(data_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "parameters",
X        0);
X    
X    for (i=1, row++; i<=npar; i++) {
X        sprintf(str, "par[%d] = %s =", i,par_string[i-1]);
X    /*    if (i % 2 == 1) { */
X            par_item[i] = panel_create_item(data_panel, PANEL_TEXT,
X                PANEL_ITEM_X,               ATTR_COL(0),
X                PANEL_ITEM_Y,               ATTR_ROW(row++),
X                PANEL_LABEL_STRING,         str,
X                PANEL_VALUE_DISPLAY_LENGTH, 18,
X                0);
X  /*      }
X        else {
X            par_item[i] = panel_create_item(data_panel, PANEL_TEXT,
X                PANEL_ITEM_X,               ATTR_COL(20),
X                PANEL_ITEM_Y,               ATTR_ROW(row++),
X                PANEL_LABEL_STRING,         str,
X                PANEL_VALUE_DISPLAY_LENGTH, 10,
X                0);
X        } */
X    }
X    row+=2;
X    panel_create_item(data_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Ok", 0, 0),
X        PANEL_NOTIFY_PROC,      data_ok_proc,
X        0);
X    
X    panel_create_item(data_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(20),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Cancel", 0, 0),
X        PANEL_NOTIFY_PROC,      data_cancel_proc,
X        0);
X    
X    window_fit(data_panel);
X    window_fit(data_frame);
X}
X
Xstatic void data_popup_proc()
X{
X    int i;
X    
X    for (i=1; i<=n; i++) {
X        sprintf(str, y_format, y_guess[i]);
X        panel_set_value(y_guess_item[i], str);
X    }
X    for (i=1; i<=npar; i++) {
X        sprintf(str, par_format, par[i]);
X        panel_set_value(par_item[i], str);
X    }
X    window_set(data_frame, WIN_SHOW, TRUE, 0);
X}
X
Xstatic void data_ok_proc()
X{
X    int i;
X    
X    for (i=1; i<=n; i++) {
X        sscanf(panel_get_value(y_guess_item[i]), "%lf", &y_guess[i]);
X    }
X    for (i=1; i<=npar; i++) {
X        sscanf(panel_get_value(par_item[i]), "%lf", &par[i]);
X    }
X    window_set(data_frame, WIN_SHOW, FALSE, 0);
X    setpar();
X}
X
Xstatic void data_cancel_proc()
X{
X    window_set(data_frame, WIN_SHOW, FALSE, 0);
X}
X
X/*--------------------------------------------------------------------
X    graphic sub panel   
X----------------------------------------------------------------------*/
X
X#define AUTO_SCALING        0x1
X
Xstatic Frame graphic_frame;
Xstatic Panel graphic_panel;
Xstatic Panel_item   graphic_toggle_item, scale_size_item,
X                    x_min_item, x_max_item, y_min_item, y_max_item;
X
Xstatic void create_graphic_popup()
X{
X    int i, row=0;
X    
X    graphic_frame = window_create(frame, FRAME, 0);
X    graphic_panel = window_create(graphic_frame, PANEL, 0);
X    
X    panel_create_item(graphic_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(10),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "Graphic Parameter",
X        0);
X    
X    row++;
X    graphic_toggle_item = panel_create_item(graphic_panel, PANEL_TOGGLE,
X        PANEL_LABEL_X,              ATTR_COL(0),
X        PANEL_LABEL_Y,              ATTR_ROW(row),
X        PANEL_VALUE_X,              ATTR_COL(2),
X        PANEL_VALUE_Y,              ATTR_ROW(row+1),
X        PANEL_LABEL_STRING,         "options:",
X        PANEL_CHOICE_STRINGS,       "automatic scaling", 0,
X        PANEL_LAYOUT,               PANEL_VERTICAL,
X        PANEL_FEEDBACK,             PANEL_MARKED,
X        0);
X        
X    row+=3;
X    scale_size_item = panel_create_item(graphic_panel, PANEL_CYCLE,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "text size: ",
X        PANEL_CHOICE_STRINGS,       "small", "medium", "big", 0,
X        PANEL_VALUE,                0,
X        0);
X    row++;
X    x_min_item = panel_create_item(graphic_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "x_min =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    x_max_item = panel_create_item(graphic_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "x_max =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    y_min_item = panel_create_item(graphic_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "y_min =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    y_max_item = panel_create_item(graphic_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "y_max =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    row++;  
X    panel_create_item(graphic_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Ok", 0, 0),
X        PANEL_NOTIFY_PROC,      graphic_ok_proc,
X        0);
X    
X    panel_create_item(graphic_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(20),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Cancel", 0, 0),
X        PANEL_NOTIFY_PROC,      graphic_cancel_proc,
X        0);
X    
X    window_fit(graphic_panel);
X    window_fit(graphic_frame);
X}
X
Xstatic void graphic_popup_proc()
X{
X    panel_set_value(graphic_toggle_item, picture->auto_scaling);
X    panel_set_value(scale_size_item, picture->scale_size - 1);
X    sprintf(str, "%.2lf", picture->x_min);
X    panel_set_value(x_min_item, str);
X    sprintf(str, "%.2lf", picture->x_max);
X    panel_set_value(x_max_item, str);
X    sprintf(str, "%.2lf", picture->y_min);
X    panel_set_value(y_min_item, str);
X    sprintf(str, "%.2lf", picture->y_max);
X    panel_set_value(y_max_item, str);
X    window_set(graphic_frame, WIN_SHOW, TRUE, 0);
X}
X
Xstatic void graphic_ok_proc()
X{
X    int toggle_value;
X    
X    window_set(graphic_frame, WIN_SHOW, FALSE, 0);
X    toggle_value = (int) panel_get_value(graphic_toggle_item);
X    picture->auto_scaling = toggle_value & AUTO_SCALING;
X    picture->scale_size = (int) panel_get_value(scale_size_item) + 1;
X    sscanf(panel_get_value(x_min_item), "%lf", &picture->x_min);
X    sscanf(panel_get_value(x_max_item), "%lf", &picture->x_max);
X    sscanf(panel_get_value(y_min_item), "%lf", &picture->y_min);
X    sscanf(panel_get_value(y_max_item), "%lf", &picture->y_max);
X    create_axes();
X    draw_picture();
X}
X
Xstatic void graphic_cancel_proc()
X{
X    window_set(graphic_frame, WIN_SHOW, FALSE, 0);
X}
X
X/*--------------------------------------------------------------------
X    control sub panel   
X----------------------------------------------------------------------*/
X
X#define MESSAGES        0x1
X#define STATEMENTS      0x2
X#define WARNINGS        0x4
X#define FATAL_ERRORS    0x8
X
Xstatic Frame control_frame;
Xstatic Panel control_panel;
Xstatic Panel_item   steplength_control_item, eps_item, steplength_item,
X                    control_cycle_item, tau_min_item, tau_max_item,
X                    info_item, x_index_item,
X                    plot_norm_item, y_index_item;
X
Xstatic void create_control_popup()
X{
X    int i, row=0;
X    
X    control_frame = window_create(frame, FRAME, 0);
X    control_panel = window_create(control_frame, PANEL, 0);
X    
X    panel_create_item(control_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(10),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "Control Parameter",
X        0);
X    
X    row++;
X    control_cycle_item = panel_create_item(control_panel, PANEL_CYCLE,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "Gauss Newton options:",
X        PANEL_CHOICE_STRINGS,       "full Jacobian", "Broyden updates",
X                                    "simplified", 0,
X        PANEL_VALUE,                0,
X        0);
X    steplength_control_item = panel_create_item(control_panel, PANEL_CYCLE,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "steplength control:  ",
X        PANEL_CHOICE_STRINGS,       "no", "yes", 0,
X        PANEL_VALUE,                1,
X        0);
X    row++;
X    eps_item = panel_create_item(control_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "accuracy =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    tau_min_item = panel_create_item(control_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "tau_min  =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    tau_max_item = panel_create_item(control_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "tau_max  =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    row++;
X    x_index_item = panel_create_item(control_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "index of x-coordinate =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    plot_norm_item = panel_create_item(control_panel, PANEL_CYCLE,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "y-coordinate:  ",
X        PANEL_CHOICE_STRINGS,       "index","Euclidian norm", 0,
X        PANEL_VALUE,                1,
X        0);
X
X    y_index_item = panel_create_item(control_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "index of y-coordinate =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    row++;
X    steplength_item = panel_create_item(control_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "initial steplength =",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    row++;
X    info_item = panel_create_item(control_panel, PANEL_TOGGLE,
X        PANEL_LABEL_X,              ATTR_COL(0),
X        PANEL_LABEL_Y,              ATTR_ROW(row),
X        PANEL_VALUE_X,              ATTR_COL(2),
X        PANEL_VALUE_Y,              ATTR_ROW(row+1),
X        PANEL_LABEL_STRING,         "numerical infos:",
X        PANEL_CHOICE_STRINGS,       "messages", "statements",
X                                    "warnings", "fatal errors", 0,
X        PANEL_LAYOUT,               PANEL_VERTICAL,
X        PANEL_FEEDBACK,             PANEL_MARKED,
X        0);
X        
X    row+=7;
X    panel_create_item(control_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X/*      PANEL_LABEL_IMAGE,      panel_button_image(panel, "Ok", 0, 0), */
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Apply", 0, 0),
X        PANEL_NOTIFY_PROC,      control_ok_proc,
X        0);
X    
X    panel_create_item(control_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(30),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X/*      PANEL_LABEL_IMAGE,      panel_button_image(panel, "Cancel", 0, 0),
X*/
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Done", 0, 0),
X        PANEL_NOTIFY_PROC,      control_cancel_proc,
X        0);
X    
X    window_fit(control_panel);
X    window_fit(control_frame);
X}
X
Xstatic void control_popup_proc()
X{
X    int info_value = 0;
X    
X    panel_set_value(control_cycle_item, gn_option - 1);
X    
X    sprintf(str, "%.2lg", eps);
X    panel_set_value(eps_item, str);
X    sprintf(str, "%.2lf", tau_min);
X    panel_set_value(tau_min_item, str);
X    sprintf(str, "%.2lf", tau_max);
X    panel_set_value(tau_max_item, str);
X
X    sprintf(str, "%d", x_index);
X    panel_set_value(x_index_item, str);
X    sprintf(str, "%d", y_index);
X    panel_set_value(y_index_item, str);
X    
X    panel_set_value(steplength_control_item, steplength_control);
X    panel_set_value(plot_norm_item, plot_norm);
X    
X    sprintf(str, "%.2lf", steplength);
X    panel_set_value(steplength_item, str);
X    
X    if (print_messages)     info_value |= MESSAGES;
X    if (print_statements)   info_value |= STATEMENTS;
X    if (print_warnings)     info_value |= WARNINGS;
X    if (print_fatal_errors) info_value |= FATAL_ERRORS;
X    panel_set_value(info_item, info_value);
X    
X    window_set(control_frame, WIN_SHOW, TRUE, 0);
X}
X
Xstatic void control_ok_proc()
X{
X    int info_value = 0, i;
X    BOOLEAN xchanged = FALSE;
X    BOOLEAN ychanged = FALSE;
X    BOOLEAN old_plot_norm = plot_norm;
X    
X/*  window_set(control_frame, WIN_SHOW, FALSE, 0); */
X    window_set(control_frame, WIN_SHOW, TRUE, 0); 
X    
X    gn_option = (int) panel_get_value(control_cycle_item) + 1;
X    
X    sscanf(panel_get_value(eps_item), "%lf", &eps);
X    sscanf(panel_get_value(tau_min_item), "%lf", &tau_min);
X    sscanf(panel_get_value(tau_max_item), "%lf", &tau_max);
X
X    sscanf(panel_get_value(x_index_item), "%d", &i);
X    if (1 <= i && i<=n) {
X        xchanged = (x_index != i);
X        x_index = i;
X    }
X    sscanf(panel_get_value(y_index_item), "%d", &i);
X    plot_norm = (int) panel_get_value(plot_norm_item);
X
X    if (1 <= i && i<=n) {  
X/*  if (0 <= i && i<=n) { */
X        ychanged = (y_index != i || old_plot_norm != plot_norm);
X        y_index = i;
X    }
X    
X    steplength_control = (int) panel_get_value(steplength_control_item);
X
X    sscanf(panel_get_value(steplength_item), "%lf", &steplength);
X    
X    info_value = (int) panel_get_value(info_item);
X    print_messages      = info_value & MESSAGES;     
X    print_statements    = info_value & STATEMENTS;
X    print_warnings      = info_value & WARNINGS;
X    print_fatal_errors  = info_value & FATAL_ERRORS;
X    
X    if (xchanged || ychanged) {
X        free_line(picture->line);       picture->line       = nil;
X        free_text(picture->text);       picture->marker     = nil;
X        free_marker(picture->marker);   picture->text       = nil;
X        draw_diagram();
X    }
X}
X
Xstatic void control_cancel_proc()
X{
X    window_set(control_frame, WIN_SHOW, FALSE, 0);
X}
X
X/*--------------------------------------------------------------------
X    plot sub panel  
X----------------------------------------------------------------------*/
X
X#define PLOT_COLORS         0x1
X#define PLOT_SCALE          0x2
X#define PLOT_DOTS           0x4
X#define INCLUDE_SHOWPAGE    0x8
X
Xstatic Frame plot_frame;
Xstatic Panel plot_panel;
Xstatic Panel_item   plot_toggle_item, ps_height_item, ps_width_item,
X                    ps_file_item;
X
X
Xstatic void create_plot_popup()
X{
X    int i, row=0;
X    
X    plot_frame = window_create(frame, FRAME, 0);
X    plot_panel = window_create(plot_frame, PANEL, 0);
X    
X    panel_create_item(plot_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(3),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "Postscript plot",
X        0);
X    
X    row++;
X    ps_file_item = panel_create_item(plot_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "postscript file:",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    plot_toggle_item = panel_create_item(plot_panel, PANEL_TOGGLE,
X        PANEL_LABEL_X,              ATTR_COL(0),
X        PANEL_LABEL_Y,              ATTR_ROW(row),
X        PANEL_VALUE_X,              ATTR_COL(2),
X        PANEL_VALUE_Y,              ATTR_ROW(row+1),
X        PANEL_LABEL_STRING,         "options:",
X        PANEL_CHOICE_STRINGS,       "plot colors (dashed)", "plot scale",
X                                    "plot dots", "include showpage", 0,
X        PANEL_LAYOUT,               PANEL_VERTICAL,
X        PANEL_FEEDBACK,             PANEL_MARKED,
X        0);
X        
X    row+=7;
X    ps_height_item = panel_create_item(plot_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "postscript height [cm]",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    ps_width_item = panel_create_item(plot_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "postscript width  [cm]",
X        PANEL_VALUE_DISPLAY_LENGTH, 10,
X        0);
X    
X    row++;  
X    panel_create_item(plot_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel,
X                                            "make postscript file", 0, 0),
X        PANEL_NOTIFY_PROC,      make_postscript_file,
X        0);
X    
X    panel_create_item(plot_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel,
X                                            "send to laserwriter ", 0, 0),
X        PANEL_NOTIFY_PROC,      send_to_laserwriter,
X        0);
X    
X    row++;
X    panel_create_item(plot_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Done", 0, 0),
X        PANEL_NOTIFY_PROC,      plot_done_proc,
X        0);
X    
X    panel_create_item(plot_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(20),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Cancel", 0, 0),
X        PANEL_NOTIFY_PROC,      plot_cancel_proc,
X        0);
X    
X    window_fit(plot_panel);
X    window_fit(plot_frame);
X}
X
Xstatic void plot_popup_proc()
X{
X    int toggle_value = 0;
X    
X    panel_set_value(ps_file_item, picture->ps_file);
X    if (picture->plot_colors)       toggle_value |= PLOT_COLORS;
X    if (picture->plot_scale)        toggle_value |= PLOT_SCALE;
X    if (picture->plot_dots)         toggle_value |= PLOT_DOTS;
X    if (picture->include_showpage)  toggle_value |= INCLUDE_SHOWPAGE;
X    panel_set_value(plot_toggle_item, toggle_value);
X    
X    sprintf(str, "%.2lf", picture->ps_height);
X    panel_set_value(ps_height_item, str);
X    sprintf(str, "%.2lf", picture->ps_width);
X    panel_set_value(ps_width_item, str);
X    
X    window_set(plot_frame, WIN_SHOW, TRUE, 0);
X}
X
Xstatic void set_plot_values()
X{
X    int toggle_value;
X    
X    strcpy(picture->ps_file, panel_get_value(ps_file_item));
X    toggle_value = (int) panel_get_value(plot_toggle_item);
X    picture->plot_colors        = toggle_value & PLOT_COLORS;
X    picture->plot_scale         = toggle_value & PLOT_SCALE;
X    picture->plot_dots          = toggle_value & PLOT_DOTS;
X    picture->include_showpage   = toggle_value & INCLUDE_SHOWPAGE;
X    sscanf(panel_get_value(ps_height_item), "%lf", &picture->ps_height);
X    sscanf(panel_get_value(ps_width_item), "%lf", &picture->ps_width);
X}
X
Xstatic void plot_done_proc()
X{
X    set_plot_values();
X    window_set(plot_frame, WIN_SHOW, FALSE, 0);
X}
X
Xstatic void make_postscript_file()
X{
X    set_plot_values();
X    ps_draw_picture();
X}
X
Xstatic void send_to_laserwriter()
X{
X    set_plot_values();
X    sprintf(str, "Does '%s' contain showpage? If not, cancel.",
X            picture->ps_file);
X    if (alert_prompt(plot_frame, NULL,
X            ALERT_MESSAGE_STRINGS, str, 0,
X            ALERT_BUTTON_YES, "Yes, send file",
X            ALERT_BUTTON_NO,    "No, cancel",
X            0)) {   
X        sprintf(str, "lpr -Plw -h %s", picture->ps_file);
X        system(str);
X        sprintf(str, "postscript file %s sent to laserprinter\n",
X                                                    picture->ps_file);
X        textsw_insert(textsw, str, strlen(str));
X    }
X}
X
Xstatic void plot_cancel_proc()
X{
X    window_set(plot_frame, WIN_SHOW, FALSE, 0);
X}
X
X/*--------------------------------------------------------------------
X    print sub panel 
X----------------------------------------------------------------------*/
X
X#define ALL_SOLUTIONS       0x1
X
Xstatic Frame print_frame;
Xstatic Panel print_panel;
Xstatic Panel_item   print_file_item, print_options_item;
X
Xstatic void create_print_popup()
X{
X    int i, row=0;
X    
X    print_frame = window_create(frame, FRAME, 0);
X    print_panel = window_create(print_frame, PANEL, 0);
X    
X    panel_create_item(print_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(3),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "Print",
X        0);
X    
X    row++;
X    print_file_item = panel_create_item(print_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "file:",
X        PANEL_VALUE_DISPLAY_LENGTH, 20,
X        0);
X    
X    row+=1;
X    print_options_item = panel_create_item(print_panel, PANEL_TOGGLE,
X        PANEL_LABEL_X,              ATTR_COL(0),
X        PANEL_LABEL_Y,              ATTR_ROW(row),
X        PANEL_VALUE_X,              ATTR_COL(2),
X        PANEL_VALUE_Y,              ATTR_ROW(row+1),
X        PANEL_LABEL_STRING,         "options:",
X        PANEL_CHOICE_STRINGS,       "all solutions", 0,
X        PANEL_LAYOUT,               PANEL_VERTICAL,
X        PANEL_FEEDBACK,             PANEL_MARKED,
X        0);
X        
X    row+=3;
X    panel_create_item(print_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel,
X                                            "print group", 0, 0),
X        PANEL_NOTIFY_PROC,      print_group,
X        0);
X    
X    panel_create_item(print_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel,
X                                            "print bifurcations", 0, 0),
X        PANEL_NOTIFY_PROC,      print_bifurcations,
X        0);
X    
X    row++;
X    panel_create_item(print_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Done", 0, 0),
X        PANEL_NOTIFY_PROC,      print_done_proc,
X        0);
X    
X    panel_create_item(print_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(20),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Cancel", 0, 0),
X        PANEL_NOTIFY_PROC,      print_cancel_proc,
X        0);
X    
X    window_fit(print_panel);
X    window_fit(print_frame);
X}
X
Xstatic void print_popup_proc()
X{
X    panel_set_value(print_file_item, print_file);
X    panel_set_value(print_options_item, print_options);
X    
X    window_set(print_frame, WIN_SHOW, TRUE, 0);
X}
X
Xstatic void set_print_values()
X{
X    strcpy(print_file, panel_get_value(print_file_item));
X    print_options = (int) panel_get_value(print_options_item);
X}
X
Xstatic void print_done_proc()
X{
X    set_print_values();
X    window_set(print_frame, WIN_SHOW, FALSE, 0);
X}
X
Xstatic void print_group()
X{
X    FILE *f;
X    
X    set_print_values();
X    f = fopen(print_file, "w"); 
X    fprint_group(f, group);
X    fclose(f);
X}
X
Xstatic void print_bifurcations()
X{
X    FILE *f;
X    
X    set_print_values();
X    f = fopen(print_file, "w"); 
X    fprint_bifurcations(f);
X    fclose(f);
X}
X
Xstatic void print_cancel_proc()
X{
X    window_set(print_frame, WIN_SHOW, FALSE, 0);
X}
X
X/*--------------------------------------------------------------------
X    text sub panel  
X----------------------------------------------------------------------*/
X
Xstatic Frame text_frame;
Xstatic Panel text_panel;
X
Xstatic Panel_item text_item, size_item, halign_item, valign_item;
X
Xstatic void text_ok_proc(), text_cancel_proc(), text_canvas_event_proc();
X/*          orig_cursor_proc(), crosshair_cursor_proc();
X*/
Xstatic void create_text_popup()
X{
X    int i, row=0;
X    char label_str[30];
X    
X    text_frame = window_create(frame, FRAME, 0);
X    text_panel = window_create(text_frame, PANEL, 0);
X    
X    panel_create_item(text_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(24),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_BOLD,       TRUE,
X        PANEL_LABEL_STRING,     "Plot Text",
X        0);
X    
X    row++;
X    panel_create_item(text_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_STRING,     "After pushing 'Ok' move the mouse to\
X                                 where the text",
X        0);
X    
X    panel_create_item(text_panel, PANEL_MESSAGE,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row++),
X        PANEL_LABEL_STRING,     "should be plot and click\
X                                 the left mouse button.",
X        0);
X    
X    row++;
X    text_item = panel_create_item(text_panel, PANEL_TEXT,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "text:",
X        PANEL_VALUE_DISPLAY_LENGTH, 20,
X        0);
X    
X    size_item = panel_create_item(text_panel, PANEL_CYCLE,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "text size:           ",
X        PANEL_CHOICE_STRINGS,       "small", "medium", "big", 0,
X        PANEL_VALUE,                0,
X        0);
X    
X    halign_item = panel_create_item(text_panel, PANEL_CYCLE,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "horizontal alignment:",
X        PANEL_CHOICE_STRINGS,       "left", "center", "right", 0,
X        PANEL_VALUE,                0,
X        0);
X    
X    valign_item = panel_create_item(text_panel, PANEL_CYCLE,
X        PANEL_ITEM_X,               ATTR_COL(0),
X        PANEL_ITEM_Y,               ATTR_ROW(row++),
X        PANEL_LABEL_STRING,         "vertical alignment:  ",
X        PANEL_CHOICE_STRINGS,       "top", "center", "bottom", 0,
X        PANEL_VALUE,                2,
X        0);
X    
X    row++;
X    panel_create_item(text_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(0),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Ok", 0, 0),
X        PANEL_NOTIFY_PROC,      text_ok_proc,
X        0);
X    
X    panel_create_item(text_panel, PANEL_BUTTON,
X        PANEL_ITEM_X,           ATTR_COL(50),
X        PANEL_ITEM_Y,           ATTR_ROW(row),
X        PANEL_LABEL_IMAGE,      panel_button_image(panel, "Cancel", 0, 0),
X        PANEL_NOTIFY_PROC,      text_cancel_proc,
X        0);
X    
X    window_fit(text_panel);
X    window_fit(text_frame);
X}
X
Xstatic void text_popup_proc()
X{
X    window_set(text_frame, WIN_SHOW, TRUE, 0);
X}
X
Xstatic void text_ok_proc()
X{
X    window_set(text_frame, WIN_SHOW, FALSE, 0);
X    crosshair_cursor_proc();
X    window_set(canvas, WIN_EVENT_PROC, text_canvas_event_proc, 0);
X}
X
Xstatic void text_cancel_proc()
X{
X    window_set(text_frame, WIN_SHOW, FALSE, 0);
X}
X
Xstatic void text_canvas_event_proc(canvas, event)
X    Canvas  canvas;
X    Event   *event;
X{
X    REAL x, y;
X    char *s;
X    Text *text;
X    
X    if (event_action(event) == MS_LEFT && event_is_down(event)) {
X        x = px_to_x(event_x(event));
X        y = py_to_y(event_y(event));
X        s = panel_get_value(text_item);
X        
X        text = new_text();
X        text->col       = BLACK;
X        text->size      = (int) panel_get_value(size_item) + 1;
X        text->x         = x;
X        text->y         = y;
X        text->halign    = (int) panel_get_value(halign_item) + 1;
X        text->valign    = (int) panel_get_value(valign_item) + 1;
X        text->string    = malloc(strlen(s)+1);
X        strcpy(text->string, s);
X        draw_picture();
X
X        window_set(canvas, WIN_EVENT_PROC, canvas_event_proc, 0);
X        orig_cursor_proc();
X    }
X    else window_default_event_proc(canvas, event, 0);
X}
X
X/*--------------------------------------------------------------------
X    main panel  
X----------------------------------------------------------------------*/
X
X#define FIRST_OPTION    0x1     /* bit masks for toggle panel   */
X#define SECOND_OPTION   0x2
X#define THIRD_OPTION    0x4
X
Xstatic Panel_item   notify_text_item, choice_item;
X
Xstatic void new_diagram_proc(), branch_next_point(), print_point_proc(),
X        branch_next_branch(), branch_skip_branch(), draw_diagram_proc();
X        
Xstatic int follow_branch();
X    
X
Xvoid create_panel_items()
X{
X    panel_create_item(panel, PANEL_BUTTON,
X        PANEL_ITEM_X,       ATTR_COL(0),
X        PANEL_ITEM_Y,       ATTR_ROW(1),
X        PANEL_LABEL_IMAGE,  panel_button_image(panel, "print point", 5, 0),
X        PANEL_NOTIFY_PROC,  print_point_proc,
X        0);
X    panel_create_item(panel, PANEL_BUTTON,
X        PANEL_ITEM_X,       ATTR_COL(15),
X        PANEL_ITEM_Y,       ATTR_ROW(0),
X        PANEL_LABEL_IMAGE,  panel_button_image(panel, "new diagram", 5, 0),
X        PANEL_NOTIFY_PROC,  new_diagram_proc,
X        0);
X        
X    panel_create_item(panel, PANEL_BUTTON,
X        PANEL_ITEM_X,       ATTR_COL(15),
X        PANEL_ITEM_Y,       ATTR_ROW(1),
X        PANEL_LABEL_IMAGE,  panel_button_image(panel, "draw diagram", 0, 0),
X        PANEL_NOTIFY_PROC,  draw_diagram_proc,
X        0);
X        
X    panel_create_item(panel, PANEL_BUTTON,
X        PANEL_ITEM_X,       ATTR_COL(33),
X        PANEL_ITEM_Y,       ATTR_ROW(0),
X        PANEL_LABEL_IMAGE,  panel_button_image(panel, "next point", 0, 0),
X        PANEL_NOTIFY_PROC,  branch_next_point,
X        0);
X        
X    panel_create_item(panel, PANEL_BUTTON,
X        PANEL_ITEM_X,       ATTR_COL(33),
X        PANEL_ITEM_Y,       ATTR_ROW(1),
X        PANEL_LABEL_IMAGE,  panel_button_image(panel, "next branch", 0, 0),
X        PANEL_NOTIFY_PROC,  branch_next_branch,
X        0);
X        
X    panel_create_item(panel, PANEL_BUTTON,
X        PANEL_ITEM_X,       ATTR_COL(50),
X        PANEL_ITEM_Y,       ATTR_ROW(0),
X        PANEL_LABEL_IMAGE,  panel_button_image(panel, "skip branch", 0, 0),
X        PANEL_NOTIFY_PROC,  branch_skip_branch,
X        0);
X        
X    panel_create_item(panel, PANEL_BUTTON,
X        PANEL_ITEM_X,       ATTR_COL(50),
X        PANEL_ITEM_Y,       ATTR_ROW(1),
X        PANEL_LABEL_IMAGE,  panel_button_image(panel, "first solution", 0, 0),
X        PANEL_NOTIFY_PROC,  compute_first_solution,
X        0);
X        
X    create_file_popup();
X    create_data_popup();
X    create_graphic_popup();
X    create_control_popup();
X    create_plot_popup();
X    create_print_popup();
X    create_text_popup();
X}
X
Xstatic void print_point_proc()
X{
Xint i;
Xdouble *y_temp;
X        y_temp  = dvector(1, n);
X        sprintf(str, "original coordinates of actual point:");
X        statement(str);
X        transform(p_act -> u ,y_temp);
X    for (i=1; i<=n; i++) {
X        sprintf(str, "y[%d] = %lf",i, y_temp[i]);
X                statement(str); 
X    };
X    free_dvector(y_temp, 1, n);
X}
X
Xstatic void new_diagram_proc()
X{
X    free_line(picture->line);       picture->line = nil;
X    free_marker(picture->marker);   picture->marker = nil;
X    free_text(picture->text);       picture->text = nil;
X    
X    /* free_branch(branch_list); */ branch_list = nil;
X    /* free_branch(cont_list);  */  cont_list = nil;
X
X    draw_picture();
X}
X
Xstatic void branch_next_point()
X{
X    Branch *b;
X    BOOLEAN branch_finished = FALSE;
X    
X    if (cont_list != nil) {
X        for (b_act=cont_list; !b_act->group->implemented; b_act=b_act->next);
X        if (follow_branch(b_act, &branch_finished)) {
X            if (branch_finished) {
X                for (b=b_act; ; b=b->sym_next) {
X                    tappend_branch(b, &branch_list);
X                    delete_branch(b, &cont_list);
X                    if (b->sym_next==b_act) break;
X                }
X            }
X        }
X        else {
X            fatal_error("continuation method failed");
X        }
X    }
X    else message("diagram finished");
X}
X
Xstatic void branch_next_branch()
X{
X    Branch *b;
X    BOOLEAN branch_finished = FALSE;
X    
X    if (cont_list != nil) {
X        for (b_act=cont_list; !b_act->group->implemented; b_act=b_act->next);
X        while (!branch_finished) {
X            if (follow_branch(b_act, &branch_finished)) {
X                if (branch_finished) {
X                    for (b=b_act; ; b=b->sym_next) {
X                        tappend_branch(b, &branch_list);
X                        delete_branch(b, &cont_list);
X                        if (b->sym_next==b_act) break;
X                    }
X                }
X            }
X            else {
X                fatal_error("continuation method failed");
X                break;
X            }
X        }
X    }
X    else statement("diagram finished");
X}
X
Xstatic void branch_skip_branch()
X{
X    Branch *b, *b_first;
X    if (cont_list != nil) {
X        for (b = b_first = cont_list; ; b = b->sym_next) {
X        /*  tappend_branch(b, &branch_list); */ /* Andreas version */
X                        tappend_branch(b, &cont_list); 
X            delete_branch(b, &cont_list);
X            if (b->sym_next==b_first) break;
X        }
X    }
X    else statement("diagram finished");
X}
X 
Xstatic void draw_diagram_proc()
X{
X    Branch *b;
X    BOOLEAN branch_finished = FALSE;
X    REAL time;
X    
X    time = Seconds();
X    compute_first_solution();
X    while (cont_list != nil) {
X        for (b_act=cont_list; !b_act->group->implemented; b_act=b_act->next);
X        if (follow_branch(b_act, &branch_finished)) {
X            if (branch_finished) {
X                for (b=b_act; ; b=b->sym_next) {
X                    tappend_branch(b, &branch_list);
X                    delete_branch(b, &cont_list);
X                    if (b->sym_next==b_act) break;
X                }
X            }
X        }
X        else {
X            fatal_error("continuation method failed");
X            break;
X        }
X    }
X    if (cont_list == nil) {
X        sprintf(str, "diagram finished after %.3lg seconds", Seconds() - time);
X        statement(str);
X    }
X}
X
X/*--------------------------------------------------------------------
X    menu functions  
X----------------------------------------------------------------------*/
X
Xstatic void init_menu()
X{
X    menu = menu_create(0);
X
X    menu_set(menu,
X        MENU_ACTION_ITEM, "control parameter", control_popup_proc, 0, 0);
X    menu_set(menu,
X        MENU_ACTION_ITEM, "graphic parameter", graphic_popup_proc, 0, 0);
X    menu_set(menu,
X        MENU_ACTION_ITEM, "postscript plot", plot_popup_proc, 0, 0);
X    menu_set(menu,
X        MENU_ACTION_ITEM, "print", print_popup_proc, 0, 0);
X    menu_set(menu,
X        MENU_ACTION_ITEM, "set data", data_popup_proc, 0, 0);
X    menu_set(menu,
X        MENU_ACTION_ITEM, "plot text", text_popup_proc, 0, 0);
X    menu_set(menu,
X        MENU_ACTION_ITEM, "read & save parameter", file_popup_proc, 0, 0);
X}
X
X/*------------------------------------------------------------------
X    main control procedures
X------------------------------------------------------------------*/
X
Xstatic BOOLEAN follow_branch(branch, branch_finished)
X    Branch *branch;
X    BOOLEAN *branch_finished;
X{
X    Group *sigma_sym;
X    Branch *next_branch = nil;
X    Point *p;
X    Op *op;
X    BOOLEAN found = FALSE, break_down, break_up, no_break;
X    int i;
X
X    *branch_finished = FALSE;
X    if (branch != nil) {
X        change_group(branch->group);
X        for (p_act = branch->point; p_act->next != nil; p_act = p_act->next);
X        if (p_act->s == 0.0) {
X            message("branch finished");
X            *branch_finished = TRUE;
X            found = TRUE;
X        }
X        else {
X            b_act->active = TRUE;
X            for (i=1; i<=REDUCTION_MAX && !found; i++) {
X                if (compute_next_solution(p_act)) {
X                    handle_symmetric_solution(p_act, p_act->next);
X                    if (detect_break_up()) {
X                        if (found = look_for_break_up()) {
X                            handle_break_up(p_act);
X                        }
X                    }
X                    else if (detect_break_down()) {
X                        if (found = look_for_break_down(p_act)) {
X                            handle_break_down(p_act);
X                        }
X                    }
X                    else if (detect_no_break(p_act)) {
X                        begin_no_break(mu, nu);
X                        if (found = look_for_no_break(p_act)) {
X                            handle_no_break(p_act);
X                        }
X                        end_no_break(mu, nu);
X                    }
X                    else found = TRUE;
X                }
X                if (!found) {
X                    free_point(p_act->next);
X                    p_act->next = nil;
X                    p_act->s = RHO * p_act->s;
X                    for (p=p_act->sym_next; p!=p_act; p=p->sym_next) {
X                        free_point(p->next);
X                        p->next = nil;
X                        p->s = p_act->s;
X                    }
X                }
X                else {
X                    draw_point(sigma, p_act->next);
X                    draw_interpolant(sigma, p_act, p_act->next);
X                    if (complete_diagram) {
X                        sigma_sym = sigma;
X                        for(op=sigma->op; op->next!=nil; op=op->next) {
X                            sigma_sym = p_act->op->group(sigma_sym);
X                            p_act=p_act->sym_next;
X                            draw_point(sigma_sym, p_act->next);
X                            draw_interpolant(sigma_sym, p_act, p_act->next);
X                        }
X                    }
X                    redraw_picture();
X                }
X            }
X        }
X    }
X    return found;
X}
X
X/*---------------------------------------------------------------------------
X    init and free global data
X----------------------------------------------------------------------------*/
X
Xstatic void init_picture()
X{
X    picture = new_picture();
X    
X    picture->x_min = X_MIN;
X    picture->x_max = X_MAX;
X    picture->y_min = Y_MIN;
X    picture->y_max = Y_MAX;
X    
X    strcpy(picture->frame_label, "symcon");
X    strcpy(picture->io_file, "test.data");
X    
X    create_axes();
X}               
X
Xstatic void init_global_data()
X{
X    init_general();
X    init_gauss_newton(2*n, 2*n);
X    init_break();
X    init_no_break();
X    init_group();
X    init_group_data();
X    init_tree();
X    init_picture();
X    change_group(group);
X
X    init_continuation();
X    
X    strcpy(print_file, "test.p");
X    
X    gn_option           = JACOBIAN;
X    steplength_control  = TRUE;
X    complete_diagram    = FALSE;
X    use_projection      = FALSE;
X    plot_norm       = TRUE;
X    x_index     = n;
X    y_index     = 1;
X    eps         = 1e-7;
X    steplength  = 0.01;
X}
X
Xstatic void free_global_data()
X{
X    free_picture(picture);
X    quit_general();
X    quit_gauss_newton(2*n, 2*n);
X    quit_break();
X    quit_no_break();
X    quit_continuation();
X    quit_tree();
X    free_group_data();
X}
X
X/*------------------------------------------------------------------
X    main program
X------------------------------------------------------------------*/
X
Xvoid main()
X{
X    init_picture();
X    init_global_data();
X    init_frame();
X    init_menu();
X    window_main_loop(frame);
X    free_global_data();
X    exit(0); 
X}
X
END_OF_FILE
if test 50712 -ne `wc -c <'symcon.c'`; then
    echo shar: \"'symcon.c'\" unpacked with wrong size!
fi
# end of 'symcon.c'
fi
if test -f 'tree.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tree.c'\"
else
echo shar: Extracting \"'tree.c'\" \(15081 characters\)
sed "s/^X//" >'tree.c' <<'END_OF_FILE'
X/*----------------------------------------------------------------------
X	tree.c		structure for bifurcation diagrams		
X------------------------------------------------------------------------*/
X
X#include <strings.h>
X#include <stdio.h>
X#include <math.h>
X#include <malloc.h>
X#include <suntool/sunview.h>
X#include <suntool/canvas.h>
X#include <suntool/panel.h>
X#include <suntool/alert.h>
X#include <suntool/tty.h>
X#include <suntool/textsw.h>
X#include <suntool/scrollbar.h>
X
X#include "macros.h" 
X#include "matalloc.h"
X#include "matutil.h"
X#include "graphic.h" 
X#include "group.h"
X
X#include "tree.h"
X
X#define HERMITE		2			/* interpolation options used in  	*/		
X#define PLOT_OPTION HERMITE		/* draw_interpolant()			  	*/
X
Xstatic char str[200];
X
Xint x_index, y_index;
XBranch *branch_list = nil, *cont_list = nil, *b_act = nil;
XPoint *p_act = nil;
XBOOLEAN use_projection, complete_diagram, plot_norm;
X
X/*----------------------------------------------------------------------
X	temporary vectors for plot routines		
X------------------------------------------------------------------------*/
X  
Xstatic double *u_temp, *y_temp;
X
Xvoid init_tree()
X{
X	u_temp	= dvector(1, n);
X	y_temp	= dvector(1, n);
X}
X
Xvoid quit_tree()
X{
X	free_dvector(u_temp, 1, n);
X	free_dvector(y_temp, 1, n);
X}
X
X/*----------------------------------------------------------------------
X	allocation routines		
X------------------------------------------------------------------------*/
X  
XPoint *new_point()
X{
X	Point *point;
X
X	point = (Point *) malloc(sizeof(Point));
X	if (! point) error("Allocation failure in new_point()");
X	point->u		= nil;
X	point->tu		= nil;
X	point->det		= nil;
X	point->sym_det	= nil;
X	point->sym_sc	= nil;
X	point->next 	= nil;
X	point->op		= nil;
X	point->sym_next = point;
X	point->para 	= 0;
X	point->s 		= 0;
X	point->sc 		= 0;
X	point->type 	= 0;
X	return point;
X}
X
XBranch *new_branch()
X{
X	Branch *branch;
X	branch = (Branch *) malloc(sizeof(Branch));
X	if (! branch) error("Allocation failure in new_branch()");
X	branch->point	= nil;
X	branch->next 		= nil;
X	branch->group		= nil;
X	branch->supergroup	= nil;
X	branch->op			= nil;
X	branch->sym_next 	= branch;
X	branch->type		= 0;
X	branch->active		= FALSE;
X	return branch;
X}
X
X/*----------------------------------------------------------------------
X	deallocation routines	
X------------------------------------------------------------------------*/
X  
Xvoid free_point(point)
X	Point *point;
X{
X	if (point != nil) {
X		free_point(point->next);
X		free_dvector(point->u, 1, n);
X		free_dvector(point->tu, 1, n);
X		free_dvector(point->det, 1, n);
X		free_dvector(point->sym_det, 2, n);
X		free_dvector(point->sym_sc, 2, n);
X		free((char*)point);
X	}
X}	
X
Xvoid free_branch(branch)
X	Branch *branch;
X{
X	if (branch != nil) {
X		free_branch(branch->next);
X		free_point(branch->point);
X		free((char*)branch);
X	}
X}	
X
X/*----------------------------------------------------------------------
X	routines for lists of points and branches
X	
X		happend = append at the head of the list
X		tappend = append at the tail of the list 		
X------------------------------------------------------------------------*/
X  
Xvoid happend_point(point, point_list)
X	Point *point, **point_list;
X{
X	if (point != nil) {
X		point->next = *point_list;
X		*point_list = point;
X	}
X}
X
Xvoid tappend_point(point, point_list)
X	Point *point, **point_list;
X{
X	Point *p;
X	
X	if (point != nil) {
X		if (*point_list == nil) {
X			*point_list = point;
X		}
X		else {
X			for (p=*point_list; p->next != nil; p = p->next) ;
X			p->next = point;
X		}
X	}
X}
X
Xvoid happend_branch(branch, branch_list)
X	Branch *branch, **branch_list;
X{
X	if (branch != nil) {
X		branch->next = *branch_list;
X		*branch_list = branch;
X	}
X}
X
Xvoid tappend_branch(branch, branch_list)
X	Branch *branch, **branch_list;
X{
X	Branch *b;
X	
X	if (branch != nil) {
X		if (*branch_list == nil) {
X			*branch_list = branch;
X		}
X		else {
X			for (b=*branch_list; b->next != nil; b = b->next) ;
X			b->next = branch;
X		}
X	}
X}
X
X/*----------------------------------------------------------------------
X	insert branch according to its symmetry-group
X	
X	a) if there are branches with the same symmetry in branch_list, then
X	   insert branch behind these branches
X	   
X	b) if there are branches with the symmetry of some subgroup of
X	   branch->group, then insert in front of them.
X	   
X	c) else append branch at the tail of branch_list
X------------------------------------------------------------------------*/
X
Xvoid insert_branch(branch, branch_list)
X	Branch *branch, **branch_list;
X{
X	Branch *b;
X	Group *sigma = branch->group;
X	
X	if (branch != nil) {
X		if (*branch_list == nil) *branch_list = branch;
X		else {
X			for (b=*branch_list; b->next != nil; b = b->next) {
X				if (b->group == sigma) break;
X			}
X			if (b->group == sigma) {
X				for (; b->next != nil; b = b->next) {
X					if (b->next->group != sigma) break;
X				}
X				branch->next = b->next;
X				b->next = branch;
X			}
X			else {
X				if (look_for_subgroup(sigma, (*branch_list)->group)) {
X					branch->next = *branch_list;
X					*branch_list = branch;
X				}
X				else {
X					for (b=*branch_list; b->next != nil; b = b->next) {
X						if (look_for_subgroup(sigma, b->next->group)) break;
X					}
X					if (b->next != nil) {
X						branch->next = b->next;
X						b->next = branch;
X					}
X					else {
X						tappend_branch(branch, branch_list);
X					}
X				}
X			}	
X		}
X	}
X}
X
Xvoid delete_branch(branch, branch_list)
X	Branch *branch, **branch_list;
X{
X	Branch *b;
X	
X	if ((branch != nil) && (*branch_list != nil)) {
X		if (*branch_list == branch) {
X			*branch_list = (*branch_list)->next;
X		}
X		else {
X			for (b=*branch_list; b->next != nil; b = b->next) {
X				if (b->next == branch) {
X					b->next = b->next->next;
X					break;
X				}
X			}
X		}
X		branch->next = nil;
X	}
X}		
X
Xvoid delete_sym_branch(branch, branch_list)
X	Branch *branch, **branch_list;
X{
X	Branch *b;
X	
X	if ((branch != nil) && (*branch_list != nil)) {
X		b=*branch_list; 
X		do {
X			if (b->sym_next == branch) {
X				*branch_list = b->sym_next = b->sym_next->sym_next;
X				break;
X			}
X		} while ((b=b->sym_next) != *branch_list);
X	}
X}		
X
X/*----------------------------------------------------------------------
X	delete short branch (with only one point) without deallocating vectors
X------------------------------------------------------------------------*/
X  
Xvoid delete_bif_branch(branch, branch_list)
X	Branch *branch, **branch_list;
X{
X	Branch *b;
X	
X	if ((branch != nil) && (*branch_list != nil)) {
X		if (*branch_list == branch) {
X			*branch_list = (*branch_list)->next;
X		}
X		else {
X			for (b=*branch_list; b->next != nil; b = b->next) {
X				if (b->next == branch) {
X					b->next = b->next->next;
X					break;
X				}
X			}
X		}
X		free((char *) branch);
X	}
X}
X		
X/*----------------------------------------------------------------------
X	output of structures		
X------------------------------------------------------------------------*/
X  
Xvoid fprintf_point_list(f, format, first_point)
X	FILE *f;
X	char *format;
X	Point *first_point;
X{
X	Point *point;
X	int k = 1;
X	for (point = first_point; point != nil; point = point->next) {
X		fprintf(f, "point No %d (%d), ", k, (int) point);
X		switch (point->type) {
X			case REGULAR		:	fprintf(f, "regular point"); break;
X			case TURNING 		:	fprintf(f, "turning point"); break;
X			case BIFURCATION 	:	fprintf(f, "bifurcation"); break;
X			case BOUNDARY 		:	fprintf(f, "boundary"); break;
X			case DEAD	 		:	fprintf(f, "dead end"); break;
X			default				: 	break;
X		}
X		fprintf(f, "  s = ");		fprintf(f, format, point->s);		
X		fprintf(f, "  sc = ");		fprintf(f, format, point->sc);		
X		fprintf(f, "  para = %d", point->para);
X		fprintf(f, "  sym_next = %d", (int) point->sym_next);
X		fprintf(f, "\n    y[1..%d]  = ", n);
X		transform(point->u, y_temp);
X		fprintf_dvector(f, format, y_temp, 1, n);
X		fprintf(f, "\n    ty[1..%d]  = ", n);
X		transform(point->tu, y_temp);
X		fprintf_dvector(f, format, y_temp, 1, n);
X		fprintf(f, "\n    u[1..%d]  = ", nu);
X		fprintf_dvector(f, format, point->u, 1, nu);
X		fprintf(f, "\n    tu[1..%d] = ", nu);
X		fprintf_dvector(f, format, point->tu, 1, nu);
X		if (point->det!=nil) {
X			fprintf(f, "\n    det[1..%d]     = ", nu);
X			fprintf_dvector(f, format, point->det, 1, nu);
X		}
X		if (point->sym_det!=nil) {
X			fprintf(f, "\n    sym_det[2..%d] = ", sigma->s);
X			fprintf_dvector(f, format, point->sym_det, 2, sigma->s);
X		}
X		if (point->sym_sc!=nil) {
X			fprintf(f, "\n    sym_sc[2..%d]  = ", sigma->s);
X			fprintf_dvector(f, format, point->sym_sc, 2, sigma->s);
X		}
X		fprintf(f, "\n");
X		k++;
X	}
X}
X
Xvoid fprintf_branch(f, format, branch)
X	FILE *f;
X	char *format;
X	Branch *branch;
X{	
X	change_group(branch->group);
X	fprintf(f, "group = %s, ", sigma->label);
X	switch (branch->type) {
X		case REGULAR 	:	fprintf(f, "regular");
X							break;
X		case NO_BREAK 	:	fprintf(f, "symmetry preserving bifurcation");
X							break;
X		case BREAK_UP 	:		
X			fprintf(f, "%s to %s symmetry breaking bifurcation",
X							branch->supergroup->label, sigma->label);
X			break;
X		case BREAK_DOWN :
X			fprintf(f, "symmetry breaking bifurcation from %s with index %d",
X							sigma->label, branch->i_break);
X			break;
X		default 		:	fprintf(f, "type unknown");
X							break;
X	}
X	fprintf(f, "\n\n");
X	fprintf_point_list(f, format, branch->point);
X}
X
Xvoid fprintf_branch_list(f, format, first_branch)
X	FILE *f;
X	char *format;
X	Branch *first_branch;
X{
X	Branch *branch, *b;
X	int k = 1, l;
X	for (branch = first_branch; branch != nil; branch = branch->next) {
X		if (branch->active || complete_diagram)	{
X			fprintf(f, "branch No %d, ", k);
X			for (l=1, b=first_branch; b!=nil; b=b->next, l++) {
X				if (b==branch->sym_next) break;
X			}
X			fprintf(f, ", sym_next --> ");
X			if (b==nil) fprintf(f, "?"); else fprintf(f, "No %d", l);
X			fprintf(f, ", ");
X			fprintf_branch(f, format, branch);
X			fprintf(f, "\n");
X		}
X		k++;
X	}
X}
X
Xstatic void fprint_subgroups(f, sigma, i)
X	FILE *f;
X	Group *sigma;
X	int i;
X{
X	int k;
X	
X	for (k=1; k<=sigma->nsub[i]; k++) {
X		if (k>1) fprintf(f, ", ");
X		fprintf(f, "%s", sigma->subgroup[i][k]->label);
X	}
X}
X
Xvoid fprint_bifurcations(f)
X	FILE *f;
X{
X	Branch *branch, *b;
X	int no = 1;
X	
X	fprintf(f, "bifurcations:\n\n");
X	for (branch = branch_list; branch != nil; branch = branch->next) {
X		if (branch->active && branch->point->type == BIFURCATION) {
X			fprintf(f, "No %3d: ", no);
X			switch (branch->type) {
X				case NO_BREAK	:	
X					fprintf(f, "%4s-symmetry preserving bifurcation",
X						branch->group->label);
X					break;
X				case BREAK_DOWN	:	
X					fprintf(f, "%4s-symmetry breaking bifurcation of index %d",
X						branch->group->label, branch->i_break);
X					fprintf(f, " (");
X					fprint_subgroups(f, branch->group, branch->i_break);
X					fprintf(f, ")");
X					break;
X				case BREAK_UP	:	
X					fprintf(f, "%4s to %4s symmetry breaking bifurcation",
X						branch->supergroup->label, branch->group->label);
X					break;
X			}
X			fprintf(f, " at lambda = %.3lg\n",
X					branch->point->u[branch->group->m[1]+1]);
X			no++;
X		}
X	}
X}
X
X/*----------------------------------------------------------------------
X	choose coordinates to be plotted
X------------------------------------------------------------------------*/
X
Xstatic plot_inv_transform(sigma, u, x, y)
X	Group *sigma;
X	double *u, *x, *y;
X{
X	sigma->transform(u, y_temp);
X	if (use_projection) {
X		plot_group->inv_transform(y_temp, u_temp);
X		*x = u_temp[x_index];
X		*y = u_temp[y_index];
X	}
X	else {
X		*x = y_temp[x_index];
X		if (plot_norm) {
X                  *y = sqrt(squared_norm(y_temp,1,n)-SQR(y_temp[x_index]));
X                } else
X                { 
X                  *y = y_temp[y_index];
X                } 
X	}
X}
X
Xstatic plot_tan_inv_transform(sigma,tan, u, x, y)
X	Group *sigma;
X	double *tan, *u, *x, *y;
X{
X	sigma->transform(tan, y_temp);
X	if (use_projection) {
X		plot_group->inv_transform(y_temp, u_temp);
X		*x = u_temp[x_index];
X		*y = u_temp[y_index];
X	}
X	else {
X		sigma->transform(u, u_temp);
X		*x = y_temp[x_index];
X		if (plot_norm) {
X                  *y = (product(u_temp,y_temp,1,n)-u_temp[x_index]*y_temp[x_index])/
X                       sqrt(squared_norm(u_temp,1,n)-SQR(u_temp[x_index]));
X                } else
X                { 
X                  *y = y_temp[y_index];
X                } 
X	}
X}
X
X/*----------------------------------------------------------------------
X	draw curve between two points
X------------------------------------------------------------------------*/
X
Xvoid draw_interpolant(sigma, p, q)
X	Group *sigma;
X	Point *p, *q;
X{
X	int option = PLOT_OPTION;
X	Line *line;
X	int i, k, no;
X	double *x, *y, lp, lq, temp;
X
X	if (!complete_diagram || sigma->plot) {
X		line = new_line();
X		line->col 	= sigma->no % 7 + 1;
X		line->size	= SMALLSIZE;
X	
X		if (option == LINEAR) {
X			no = 1;	
X			line->x	= dvector(0, no);
X			line->y	= dvector(0, no);
X			plot_inv_transform(sigma, p->u, &line->x[0], &line->y[0]);
X			plot_inv_transform(sigma, q->u, &line->x[1], &line->y[1]);
X			line->n = no;
X			line->type = LINEAR;
X		}
X		else if (option == HERMITE) {
X			no = 3;	
X			x = dvector(0, no);
X			y = dvector(0, no);
X			plot_inv_transform(sigma, p->u,  &x[0], &y[0]);
X			plot_tan_inv_transform(sigma, p->tu,  p->u, &x[1], &y[1]);
X			plot_tan_inv_transform(sigma, q->tu,  q->u, &x[2], &y[2]);
X			plot_inv_transform(sigma, q->u,  &x[3], &y[3]);
X				
X			temp = sqrt(SQR(x[0]-x[3])+SQR(y[0]-y[3]));
X
X			lp = sqrt(SQR(x[1])+SQR(y[1]));
X			lp = (fabs(lp) > EPS_MACH) ? temp / (3 * lp) : 0;	
X		
X			lq = sqrt(SQR(x[2])+SQR(y[2]));
X			lq = (fabs(lq) > EPS_MACH) ? temp / (3 * lq) : 0;	
X
X			x[1] = x[0] + lp * x[1];
X			x[2] = x[3] - lq * x[2];
X		
X			y[1] = y[0] + lp * y[1];
X			y[2] = y[3] - lq * y[2];
X		
X			line->x	= x;
X			line->y	= y;
X			line->n = no;
X			line->type = BEZIER;	
X		}
X		draw_line(line);
X	}
X}
X  
Xvoid draw_point(sigma, point)
X	Group *sigma;
X	Point *point;
X{
X	Marker *marker;
X	
X	if (!complete_diagram || sigma->plot) {
X		marker = new_marker();
X		marker->col		= sigma->no % 7 + 1;
X		marker->size	= picture->scale_size;
X		switch (point->type) {
X			case REGULAR		:	marker->symbol	= DOT; break;
X			case BIFURCATION	:	marker->symbol	= STAR; break;
X			case TURNING 		:	marker->symbol	= PLUS; break;
X			case BOUNDARY 		:	marker->symbol	= CROSS; break;
X			case DEAD	 		:	marker->symbol	= PLUS; break;
X		}
X		marker->x	= (double *) malloc(sizeof(double));
X		marker->y	= (double *) malloc(sizeof(double));
X		plot_inv_transform(sigma, point->u, &marker->x[0], &marker->y[0]);
X		marker->n = 1;
X		draw_marker(marker);
X	}
X}
X
Xvoid draw_point_list(sigma, first_point)
X	Group *sigma;
X	Point *first_point;
X{
X	Point *point;
X	for (point = first_point; point != nil; point = point->next) {
X		draw_point(sigma, point);
X		if (point->next != nil)	draw_interpolant(sigma, point, point->next);
X	}
X}
X
Xvoid draw_branch(branch)
X	Branch *branch;
X{
X	if ((branch->active || (complete_diagram && branch->group->plot)) &&
X									branch->point->next != nil) {
X		draw_point_list(branch->group, branch->point);
X	}
X}
X
Xvoid draw_branch_list(first_branch)
X	Branch *first_branch;
X{
X	Branch *branch;
X	for (branch = first_branch; branch != nil; branch = branch->next) {
X		draw_branch(branch);
X	}
X}
X
Xvoid draw_diagram()
X{
X	draw_branch_list(branch_list);
X	draw_branch_list(cont_list);
X	draw_picture();
X}
X
X	
X
X
END_OF_FILE
if test 15081 -ne `wc -c <'tree.c'`; then
    echo shar: \"'tree.c'\" unpacked with wrong size!
fi
# end of 'tree.c'
fi
if test -f 'tree.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tree.h'\"
else
echo shar: Extracting \"'tree.h'\" \(3384 characters\)
sed "s/^X//" >'tree.h' <<'END_OF_FILE'
X/*----------------------------------------------------------------------
X    tree.h      structure for bifurcation diagrams      
X------------------------------------------------------------------------*/
X 
X/*----------------------------------------------------------------------
X    export list     
X------------------------------------------------------------------------*/
X
X#define REGULAR         1
X#define TURNING         2
X#define BIFURCATION     3
X#define BOUNDARY        4
X#define DEAD            5
X#define BREAK_DOWN      6
X#define BREAK_UP        7
X#define NO_BREAK        8
X
X/*------------------------------------------------------------------------
X    structure point
X    
X    type            = type of point (REGULAR, TURNING, BIFURCATION, BOUNDARY,
X                        DEAD)
X    para            = index of alcon's implicit parameter (= pivot[nu])
X    det[1..nu]      = alcon's determinants for the detection of symmetry
X                        preserving bifurcations
X    sym_det[i]      = determinant of A_i (for the detection of symmetry
X                        breaking bifurcations) (i=2,..,sigma->s)
X    sym_sc[i]       = subcondition of A_i (i=2,..,sigma->s)
X    s               = steplength
X    sc              = subcondition
X    u[1..nu]        = point in Y^sigma
X    tu[1..n]        = tangent in Y^sigma
X    next            = next point in a list of points
X    sym_next        = next point in the list of symmetric points
X    op              = operation from point to point->sym_next 
X-------------------------------------------------------------------------*/
X
Xtypedef struct POINT {
X    int type, para;
X    double *det, *sym_det, *sym_sc, s, sc, *u, *tu;
X    struct POINT *next, *sym_next;
X    Op *op;
X} Point;
X
X/*------------------------------------------------------------------------
X    structure branch
X    
X    type        = type of branch (REGULAR, BREAK_DOWN, BREAK_UP, NO_BREAK)
X    point       = first point of branch 
X    group       = symmetry group of branch
X    next        = next branch in a list of branches
X    sym_next    = next point in the list of symmetric points
X    x[1..?]     = augmented bifurcation vector
X    op          = operation from branch to branch->sym_next 
X-------------------------------------------------------------------------*/
X
Xtypedef struct BRANCH {
X    int type, i_break;
X    Point *point;
X    Group *group, *supergroup;
X    struct BRANCH *next, *sym_next;
X    BOOLEAN active;
X    Op *op;
X} Branch;
X
Xextern int x_index, y_index;
Xextern BOOLEAN use_projection, complete_diagram, plot_norm;
Xextern Branch *branch_list, *cont_list, *b_act;
Xextern Point *p_act;
X
Xextern void init_tree();
Xextern void quit_tree();
X
Xextern Point  *new_point();
Xextern Branch *new_branch();
X
Xextern void free_point();
Xextern void free_branch();
X
Xextern void happend_point();
Xextern void tappend_point();
Xextern void happend_branch();
Xextern void tappend_branch();
Xextern void insert_branch();
X
Xextern void delete_branch();
Xextern void delete_sym_branch();
Xextern void delete_bif_branch();
X
Xextern void fprintf_point();
Xextern void fprintf_point_list();
Xextern void fprintf_branch();
Xextern void fprintf_branch_list();
Xextern void fprint_bifurcations();
X
Xextern void draw_interpolant();
Xextern void draw_point();
Xextern void draw_point_list();
Xextern void draw_branch_list();
Xextern void draw_branch();
Xextern void draw_diagram();
X
X
X
END_OF_FILE
if test 3384 -ne `wc -c <'tree.h'`; then
    echo shar: \"'tree.h'\" unpacked with wrong size!
fi
# end of 'tree.h'
fi
echo shar: End of shell archive.
exit 0

