Category : C Source Code
Archive   : DYNAM_S1.ZIP
Filename : YCOMP.C

 
Output of file : YCOMP.C contained in archive : DYNAM_S1.ZIP
/******************************** YCOMP.C ***********************************/
/*********************** PARAMETER COMMANDS AND MENU *************************/
/********************* (C) 1986,7,8 by JAMES A. YORKE ************************/


#include "yinclud.h"

int parameters(CodeName)
char *CodeName;
{
int num,
ss;
int iterate_map(); /* needed for a pointer */

TEST("all") {

if(xScrPix[1] == -9999.
&& xScrPix[2] == -9999.
&& xScrPix[3] == -9999.
&& xScrPix[4] == -9999.) {
PRINT "No windows are open. \n");
allSSFlag = NO;
return(1);
}
taskFlag = PLOTALL;

allSSFlag = 1 - allSSFlag;
erase_line();
if(allSSFlag == YES)
PRINT "Now all small frames will plot simultaneously\n");
else
PRINT "Now only one frame will be plotted at a time\n");
return(1);
}

TEST("beta") {
beta = Entervalue(beta, CHECKSET);
return(1);
}
TEST2 ("c", "coords") { /* sets the coordinate numbers that are to be
plotted */
caseC();
return(1);
}
TEST2 ("c1", "1") {
C1 = Entervalue(C1, CHECKSET);
return(1);
}
TEST2 ("c2", "2") {
C2 = Entervalue(C2, CHECKSET);
return(1);
}
TEST2 ("c3", "3") {
C3 = Entervalue(C3, CHECKSET);
return(1);
}
TEST2 ("c4", "4") {
C4 = Entervalue(C4, CHECKSET);
if(step != -9999 && C4 != -9999) {
step = (twopi / C4) / steps_per_cycle;
sixth_step = step / 6.;/* for rungekutta */
halfstep = step / 2;
}
return(1);
}
TEST2 ("c5", "5") {
C5 = Entervalue(C5, CHECKSET);
return(1);
}
TEST2 ("c6", "6") {
C6 = Entervalue(C6, CHECKSET);
return(1);
}
TEST2 ("c7", "7") {
C7 = Entervalue(C7, CHECKSET);
return(1);
}
TEST2 ("c8", "8") {
C8 = Entervalue(C8, CHECKSET);
return(1);
}
TEST2 ("c9", "9") {
C9 = Entervalue(C9, CHECKSET);
return(1);
}
TEST("dots") {
PRINT
"For bifucation diagrams, use command BIF2 to set dots \n");
dots = (long) Entervalue((double) dots, CHECKSET);
return(1);
}
TEST("fr") {
rho_final = Entervalue(rho_final, CHECKSET);
return(1);
}
TEST("ipp") {
if(iteratee == map)
iteratee = iterate_map;
/* having iteratee = map speeds Henon by 8%; but if num_lyap or
its_per_plot is nontrivial, we must reset iteratee to be
iterate_map; */
if(steps_per_cycle != -9999) {
if(input == StInput) {
erase_line();
PRINT
"Typical values used are 1 (which plots every dot) and%5.0lf;\n"
,steps_per_cycle);
erase_line();
PRINT
" the latter gives the Poincare return map; \n");
erase_line();
PRINT
"that is, you will plot one point per cycle.\n"
);
PRINT
"Note that steps_per_cycle(in DE menu) = %lg\n\n", steps_per_cycle);
erase_line();
PRINT
"Enter the desired number of iterates per plot then \n\n");
}
its_per_plot = (int) Entervalue((double) its_per_plot, CHECKSET);
step = (twopi / C4) / steps_per_cycle;
sixth_step = step / 6.;/* for rungekutta */
halfstep = step / 2;
if(input == StInput && its_per_plot == 1) {
erase_line();
PRINT
"Since you will plot every dot, you may want command \"CONNECT\".\n\n");
}
}
else { /* this case is for maps and dif eqns that
aren't forced periodically */
if(input == StInput) {
erase_line();
PRINT
"Enter the desired number of iterates per plot then \n\n");
its_per_plot = (int) Entervalue((double) its_per_plot, CHECKSET);
}
}
return(1);
}
TEST("l") { /* Lyapunov */
if(num_lyap == -9999) {
PRINT
"This program is not set up to compute Lyapunov numbers for this process");
ret_erase_line(2);
return(1);
}
if(SCREEN) {
PRINT
"Current number of exponents to be calculated is %d\n\n",
num_lyap);
PRINT "Specify an integer >= 0 and <= %d\n", vec_dim);
}
#ifdef X11
if(input == StInput && sscanf(xwfgets(), "%d", &num) != 1
|| input != StInput && fscanf(input, "%d", &num) != 1)
return(1);
#else
if(abortEnter() == YES
|| fscanf(input, "%d", &num) != 1)
return(1);
#endif
if((num < 0) || (num > vec_dim)
|| (lyapzero + num * vec_dim > eqn0)) {
PRINT
" Illegal value for num_lyap: %d \n", num);
}
else if(num != num_lyap) {
if(iteratee == map)
iteratee = iterate_map;
/* having iteratee = map speeds Henon by 8%; but if
num_lyap or its_per_plot is nontrivial, we must
reset iteratee to be iterate_map; */
num_lyap = num;
storeNumLyap = num_lyap;
/* used for straddle orbits */
start();
/* sets dot = 0 among other functions; see
YINTRPT.C */
lyapinit();
}
if(SCREEN)
PRINT
"Current number of exponents to be calculated is %d\n\n", num_lyap);

dim = lyapzero + num_lyap * vec_dim;
return(1);
}
TEST("pi") {
preiter = (long) Entervalue((double) preiter, CHECKSET);
return(1);
}
TEST2 ("r", "rho") {
if(rho == rho_final) {
rho = Entervalue(rho, CHECKSET);
rho_final = rho;
}
else {
rho = Entervalue(rho, CHECKSET);
}
return(1);
}
TEST("rs") {
rho_step = Entervalue(rho_step, CHECKSET);
return(1);
}
TEST("sd") {
if(ScrnSec != 0)
if(SCREEN)
PRINT
"Enter new diameter for current screen section which is # %d\n"
,ScrnSec);
diameters[ScrnSec] = Entervalue(diameters[ScrnSec], CHECKSET);
return(1);
}
TEST("sigma") {
sigma = Entervalue(sigma, CHECKSET);
return(1);
}
TEST("ss") {
ss = ScrnSec;
ss = (int) Entervalue((double) ss, CHECKSET);
if(ss < 0 || ss > 4) {
PRINT "unacceptable; ScreenSec is now %d \n", ScrnSec);
PRINT "Value remains: %d\n\n", ScrnSec);
}
else {
if(xScrPix[ss] != -9999.&& xScrPix[ss] != 0
&& yScrPix[ss] != 0) {
/* they can't be 0 anyway */
ScrnSec = ss;
if(SCREEN)
PRINT
"New Screen Section is # %d \n", ss);

/* ScreenConstants();
*/
X_coord = ssX_coord[ss];
Y_coord = ssY_coord[ss];
allSSFlag = NO;
/* now plot in only one frame */
X_lower = X_Lo[ss];
X_upper = X_Up[ss];
Y_upper = Y_Up[ss];
Y_lower = Y_Lo[ss];
}
else {
PRINT
"You cannot change to this value of ScrnSecs because its scale has \n");
PRINT
"not been set. You must first use command SSS which allows you to set the \n");
PRINT
"scale for any ScrnSec.\n");

}
}
return(1);
}
TEST("xs") {
EnterScale(&X_lower, &X_upper);
ScreenConstants();
return(1);
}
TEST("ys") {
EnterScale(&Y_lower, &Y_upper);
if(X_coord == Y_coord) {
X_lower = Y_lower;
X_upper = X_lower + (8.0 / 5.3) * (Y_upper - Y_lower);
} /* The printed page is 8 in wide and 5.3 high
--- when using 48 print lines per picture.
This setting can be overridden by setting
the X scale after the Y scale has been set.
*/
ScreenConstants();
return(1);
}
TEST("wm")
{
WMenu();
return(1);
}
return(0);
}




caseC()
{
int numRhos;
int X_c,
Y_c;

if(SCREEN) {
PRINT
"Enter two coordinate numbers >= -1 and < %d, \n", dim);
PRINT
" The first is for the X(horizontal) axis, \n");
PRINT
" the second is for the Y(vertical)\n");
PRINT
"Currently: %d %d, \n"
,X_coord, Y_coord);
PRINT
" i.e.: plotting y[%d] on the X axis and y[%d] on the Y axis\n\n"
,X_coord, Y_coord);
PRINT
"If you set them equal, then horizontal is one time step earlier than ");
PRINT "vertical.\n");
PRINT
" You can make the difference 2 or more by setting IPP = 2 or more.\n\n");
PRINT
"rho is considered to be coordinate -1; see BIFM menu \n\n");
PRINT
"Enter them separated by a space, no comma, then \n");
}
#ifdef X11
if(input == StInput && sscanf(xwfgets(), "%d %d", &X_c, &Y_c) == 2
|| input != StInput && fscanf(input, "%d %d", &X_c, &Y_c) == 2) {
#else
if(abortEnter() == YES)
return;
if(fscanf(input, "%d %d", &X_c, &Y_c) == 2) {
#endif
if(X_c >= -1 && X_c < dim && Y_c >= -1
&& Y_c < dim && (X_c + Y_c > -2)) {
X_coord = X_c;
Y_coord = Y_c;
setXYPlot();
}
else
PRINT
" Not accepted; not >= -1 and < %d \n", dim);
}
if(SCREEN)
PRINT
"X_coord = %d and Y_coord = %d \n", X_coord, Y_coord);
if((X_coord == -1 || Y_coord == -1) && SCREEN) {
numRhos = COREROWS * 8;/* for case Y_coord == -1 */
if(X_coord == -1)
numRhos = CORECOLS;
PRINT "\n\nThe number of values of rho to be studied is %d.\n",
numRhos);
PRINT
"Use command BIFM to see menu for bifurcation diagrams\n\n");
if(X_coord == -1) {
PRINT
"Use command XS to set the range of rhos to be plotted.\n");
PRINT
"Rho will be initialized as having the value of the left side of the screen.\n");
}
if(Y_coord == -1) {
PRINT
"Use command YS to set the range of rhos to be plotted.\n");
PRINT
"Rho starts at the value at the bottom of the screen.\n");
}
PRINT "\n\n");
}


TESTMAP("l") /* if we have map "l" = Lorenz */
if(SCREEN)
PRINT "coordinates 0 1 2 3 are x y z and t respectively\n\n");
}

setXYPlot() { /* called by caseC() */
ssX_coord[ScrnSec] = X_coord;
ssY_coord[ScrnSec] = Y_coord;
if(X_coord >= 0) {
Xplot[ScrnSec] = &y[X_coord];
}
if(X_coord == -1) {
Xplot[ScrnSec] = ρ
}
if(Y_coord >= 0) {
Yplot[ScrnSec] = &y[Y_coord];
}
if(Y_coord == -1) {
Yplot[ScrnSec] = ρ
}
}

menuP()/* variables */
{
FILE *output;

if (level == SETPARAM)
scr_clr();/* in desmets pcio.a */
scr_rowcol(0,2);
PRINT
" PARAMETER MENU \n\n ");

output = StOutPut;
map_menu(output,MapName);/* in YMapMenu.c*/

PRINT "\n");

if (beta != -9999.)
PRINT
" BETA: beta = %11.8lf \n",beta);

if (C1 != -9999.) PRINT
" C1: C1 = %11.8lf \n",C1);
if (C2 != -9999.) PRINT
" C2: C2 = %11.8lf \n",C2);
if (C3 != -9999.) PRINT
" C3: C3 = %11.8lf \n",C3);
if (C4 != -9999.) PRINT
" C4: C4 = %11.8lf \n",C4);
if (C5 != -9999.) PRINT
" C5: C5 = %11.8lf \n",C5);
if (C6 != -9999.) PRINT
" C6: C6 = %11.8lf \n",C6);
if (C7 != -9999.) PRINT
" C7: C7 = %11.8lf \n",C7);
if (C8 != -9999.) PRINT
" C8: C8 = %11.8lf \n",C8);
if (C9 != -9999.) PRINT
" C9: C9 = %11.8lf \n",C9);

if (sigma != -9999.)
PRINT
" SIGMA: sigma= %lf\n",sigma);

if (rho !=-9999.)
PRINT
" RHO: Rho = %11.8lf \n",rho);/* no return; */

PRINT "\n");

PRINT
"submenu \n WM: What When and Where plot Menu \n");

PRINT "\n");
}



WMenu()/* what when and where submenu of parameter menu */
{
FILE *output;

if (level == SETPARAM)
scr_clr();/* in desmets pcio.a */
scr_rowcol(0,2);

PRINT
" *** What When and Where plot Menu *** \n");


PRINT
"\nwhat\n");

PRINT
" ALL: simultaneously plots dots in ALL small windows that are open;\n");
PRINT
" COORDS: Coordinates to be plotted;\n");

PRINT
"\nwhen\n");
PRINT
" DOTS: Dots to be plotted %ld;",dots);
PRINT " Last dot # was %ld\n",dot);
/*
if (rho != -9999.)
PRINT
" FR: Final Rho value for a series of pictures %lf\n",rho_final);
*/
PRINT
" IPP: Iterates Per Plot = %d\n",its_per_plot);

PRINT
" PI: PREITERATES before plotting = %ld\n",preiter);

PRINT
"\nwhere\n");

if (rho != -9999.)
PRINT
" RS: Rho changes in Steps of %12.10lf; \n",rho_step);

PRINT
" SD: The number of Screen Diameters a point can be from screen without\n");
PRINT
" pausing. Currently = %5.2lf (set to negative to disable check)\n"
,diameters[ScrnSec]);

PRINT
" SS: ScreenSec = 0 means plot on full screen (=F10 while plotting); now =%d"
,ScrnSec);
PRINT
" \n = 1,2,3 or 4 to plot in one of 4 quarters of the screen \n");
PRINT
" = 1 upper left (=F1 while plotting) = 2 upper right (=F2);\n"
);

PRINT
" = 3 lower left (=F3); = 4 lower right (=F4);\n"
);


PRINT
" XS: X Scale: X_left = %lf; X_right= %lf",X_Lo[ScrnSec], X_Up[ScrnSec]);
if (ScrnSec != 0)
PRINT " for current ScreenSec'n");

PRINT
"\n YS: Y Scale: Y_lower = %lf Y_upper = %lf",Y_Lo[ScrnSec], Y_Up[ScrnSec]);
if (ScrnSec != 0)
PRINT " ScreenSec'n %d",ScrnSec);
PRINT "\n");

}




  3 Responses to “Category : C Source Code
Archive   : DYNAM_S1.ZIP
Filename : YCOMP.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/