summaryrefslogtreecommitdiff
path: root/support/fastpictex/src
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/fastpictex/src
Initial commit
Diffstat (limited to 'support/fastpictex/src')
-rw-r--r--support/fastpictex/src/Makefile39
-rw-r--r--support/fastpictex/src/fastpictex.cc947
-rw-r--r--support/fastpictex/src/fastpictex.h73
-rw-r--r--support/fastpictex/src/global.h2
-rw-r--r--support/fastpictex/src/main.cc40
-rw-r--r--support/fastpictex/src/myfunctions.cc211
-rw-r--r--support/fastpictex/src/nrutil.cc284
-rw-r--r--support/fastpictex/src/nrutil.h82
-rw-r--r--support/fastpictex/src/scale.cc66
9 files changed, 1744 insertions, 0 deletions
diff --git a/support/fastpictex/src/Makefile b/support/fastpictex/src/Makefile
new file mode 100644
index 0000000000..55ed45c228
--- /dev/null
+++ b/support/fastpictex/src/Makefile
@@ -0,0 +1,39 @@
+# Makefile for FastPicTeX
+
+PROG = fastpictex.exe
+PRGOBJ = main.o fastpictex.o myfunctions.o scale.o nrutil.o
+CC = g++
+DUMADIR = ..\..\duma
+CFLAGS = -O2
+# CFLAGS = -g -DDUMA
+LFLAGS = -O2
+# LFLAGS = -g
+LIBS =
+# LIBS = $(DUMADIR)\libduma.a
+RM = del
+STRIP = strip
+MAKE = mingw32-make
+
+$(PROG): $(PRGOBJ)
+ $(CC) $(LFLAGS) -o fastpictex.exe $(PRGOBJ) $(LIBS)
+
+main.o: main.cc fastpictex.h
+ $(CC) -c $(CFLAGS) main.cc
+
+fastpictex.o: fastpictex.cc fastpictex.h
+ $(CC) -c $(CFLAGS) fastpictex.cc
+
+myfunctions.o: myfunctions.cc
+ $(CC) -c $(CFLAGS) myfunctions.cc
+
+scale.o: scale.cc
+ $(CC) -c $(CFLAGS) scale.cc
+
+nrutil.o: nrutil.cc nrutil.h
+ $(CC) -c $(CFLAGS) nrutil.cc
+
+clean:
+ $(RM) $(PRGOBJ) *~
+
+strip:
+ $(STRIP) $(PROG)
diff --git a/support/fastpictex/src/fastpictex.cc b/support/fastpictex/src/fastpictex.cc
new file mode 100644
index 0000000000..c106e53766
--- /dev/null
+++ b/support/fastpictex/src/fastpictex.cc
@@ -0,0 +1,947 @@
+/*******************************************************/
+/* Linux GNU C++ Compiler */
+/* Name : fastpictex.cc */
+/* Autor: Harald Stauss */
+/*******************************************************/
+
+#include <iostream>
+#include <fstream>
+#include <float.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#include "fastpictex.h"
+
+#ifdef DUMA
+ #include <new>
+ #include "../../duma/duma.h"
+ #include "../../duma/dumapp.h"
+#endif
+
+/* ----------------------------- */
+/* Implementation der Funktionen */
+/* ----------------------------- */
+FASTPICTEX::FASTPICTEX() { /* Constructor */
+ width=6.0; height=6.0; // default 6x6 cm;
+ nofseries=0;
+ nofbar=0;
+ linenoxmax=-1;
+ xgrid=0; ygrid=0;
+ noftline=0;
+ series=(SERIES *)malloc(sizeof(SERIES));
+ need_errorbarmacros=0;
+ xlabel =(char*)malloc(2*sizeof(char)); strcpy(xlabel, "\0");
+ ylabel =(char*)malloc(2*sizeof(char)); strcpy(ylabel, "\0");
+ heading=(char*)malloc(2*sizeof(char)); strcpy(heading, "\0");
+ nxticlabels=0;
+ xticlabels=new char* [1];
+ nofrawpictex=0;
+ rawpictex=(char **)malloc(sizeof(char *));
+ strcpy(plotsym[0], "$\\bullet$");
+ strcpy(plotsym[1], "$\\circ$");
+ strcpy(plotsym[2], "$\\diamond$");
+ strcpy(plotsym[3], "$\\star$");
+ strcpy(plotsym[4], "$\\ast$");
+ strcpy(plotsym[5], "$\\oplus$");
+ strcpy(plotsym[6], "$\\odot$");
+ strcpy(plotsym[7], "$\\oslash$");
+ strcpy(plotsym[8], "$\\otimes$");
+ strcpy(plotsym[9], "$\\times$");
+ strcpy(linesym[0], "\\setsolid");
+ strcpy(linesym[1], "\\setdots");
+ strcpy(linesym[2], "\\setdashes");
+ strcpy(linesym[3], "\\setdashpattern <3mm,1mm,1mm,1mm>");
+ strcpy(linesym[4], "\\setdashpattern <3mm,1mm,0.5mm,0.5mm,0.5mm,1mm>");
+ strcpy(linesym[5], "\\setsolid");
+ strcpy(linesym[6], "\\setdots");
+ strcpy(linesym[7], "\\setdashes");
+ strcpy(linesym[8], "\\setdashpattern <3mm,1mm,1mm,1mm>");
+ strcpy(linesym[9], "\\setdashpattern <3mm,1mm,0.5mm,0.5mm,0.5mm,1mm>");
+}
+
+FASTPICTEX::~FASTPICTEX() { /* Destructor */
+ int i;
+ unsigned long j;
+ for (i=0; i<nofseries; i++) {
+ free(series[i].x);
+ free(series[i].y);
+ free(series[i].dx);
+ free(series[i].dy);
+ for (j=0; j<series[i].ny; j++)
+ delete[]series[i].sig[j];
+ free(series[i].sig);
+ free(series[i].legend);
+ }
+ for (j=0; j<nxticlabels; j++)
+ delete[]xticlabels[j];
+ delete[]xticlabels;
+ free(series);
+ free(xlabel);
+ free(ylabel);
+ free(heading);
+ for (i=0; i<nofrawpictex; i++) free(rawpictex[i]);
+ free(rawpictex);
+}
+
+/* function to read input file */
+int FASTPICTEX::Read(char *fname) {
+ std::ifstream fptin;
+ int i, j, rc=0;
+ int nx, ny, ndx, ndy, ntype, nsize, nlegend;
+ short is_newcommand;
+ char *s, *fpt_command, *token, *hchar;
+ unsigned long n, ndata, nallocdata=100;
+ float *data, wert;
+ short is_multiword;
+
+ extern int myatof(char *s, float *f);
+ extern char *getsig(char *s);
+
+ /* open input file */
+ fptin.open(fname);
+ if (!fptin) {
+ rc=1;
+ std::cout << "Cannot open input file! \n";
+ return(rc);
+ }
+
+ /* allocate memory */
+ s = (char *)malloc(MAX_FIELD_LENGTH*sizeof(char));
+ fpt_command = (char *)malloc(MAX_FIELD_LENGTH*sizeof(char));
+ hchar = (char *)malloc(MAX_FIELD_LENGTH*sizeof(char));
+ data = (float *)malloc(nallocdata*sizeof(float));
+ nx=0; ny=0; ndx=0; ndy=0; ntype=0; nlegend=0;
+ is_multiword=0;
+
+ /* Hauptschleife */
+ fptin.getline(hchar,MAX_FIELD_LENGTH);
+ strcpy(s,hchar);
+ while (fptin.fail() && !fptin.eof()) {
+ fptin.clear();
+ fptin.getline(hchar,MAX_FIELD_LENGTH);
+ s=(char *)realloc(s, strlen(s)+strlen(hchar)+1);
+ strcat(s, hchar);
+ }
+ while(!fptin.eof()) {
+ /* new command or continue with old command */
+ if (strchr(WHITE_SPACE, s[0])) {
+ fpt_command=(char *)realloc(fpt_command, strlen(fpt_command)+strlen(s)+1);
+ s=(char *)realloc(s, strlen(fpt_command)+strlen(s)+1);
+ strcat(fpt_command, s);
+ strcpy(s, fpt_command);
+ is_newcommand=0;
+ }
+ else {
+ is_newcommand=1;
+ }
+ /* get first token */
+ token=strtok(s, WHITE_SPACE);
+ strcpy(fpt_command, token);
+ /* work on commands */
+ /* comment */
+ if (!strcmp(fpt_command, "%")) {
+ /* do nothing */
+ }
+ /* size */
+ else if (!strcmp(fpt_command, "size")) {
+ token=fpt_command;
+ if (is_newcommand) {
+ nsize=0;
+ }
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ if (nsize==0) {
+ if (myatof(token, &wert)) {
+ width=wert;
+ nsize++;
+ }
+ }
+ else if (nsize==1) {
+ if (myatof(token, &wert)) {
+ height=wert;
+ nsize++;
+ }
+ }
+ } /* endif */
+ } /* endwhile */
+ }
+ /* xlabel */
+ else if (!strcmp(fpt_command, "xlabel")) {
+ token=fpt_command;
+ if (is_newcommand) strcpy(xlabel, "");
+ else strcat(xlabel, " ");
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ xlabel=(char *)realloc(xlabel, strlen(xlabel)+strlen(token)+2);
+ strcat(xlabel, token); strcat(xlabel, " ");
+ } /* endif */
+ } /* endwhile */
+ xlabel[strlen(xlabel)-1]='\0';
+ }
+ /* ylabel */
+ else if (!strcmp(fpt_command, "ylabel")) {
+ token=fpt_command;
+ if (is_newcommand) strcpy(ylabel, "");
+ else strcat(ylabel, " ");
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ ylabel=(char *)realloc(ylabel, strlen(ylabel)+strlen(token)+2);
+ strcat(ylabel, token); strcat(ylabel, " ");
+ } /* endif */
+ } /* endwhile */
+ ylabel[strlen(ylabel)-1]='\0';
+ }
+ /* heading */
+ else if (!strcmp(fpt_command, "heading")) {
+ token=fpt_command;
+ if (is_newcommand) strcpy(heading, "");
+ else strcat(heading, " ");
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ heading=(char *)realloc(heading, strlen(heading)+strlen(token)+2);
+ strcat(heading, token); strcat(heading, " ");
+ } /* endif */
+ } /* endwhile */
+ heading[strlen(heading)-1]='\0';
+ }
+ /* graph type */
+ else if (!strcmp(fpt_command, "type")) {
+ if (is_newcommand) {
+ ntype++;
+ if (ntype>nofseries) {
+ AddSeries();
+ }
+ }
+ token=fpt_command;
+ token=strtok(NULL, WHITE_SPACE);
+ if (!token) {
+ series[ntype-1].type=0;
+ }
+ if (!strcmp(token, "xy")) {
+ series[ntype-1].type=1;
+ }
+ else if (!strcmp(token, "line")) {
+ series[ntype-1].type=2;
+ }
+ else if (!strcmp(token, "bar")) {
+ series[ntype-1].type=3;
+ nofbar++;
+ }
+ else {
+ series[ntype-1].type=0;
+ }
+ }
+ /* trendline */
+ else if (!strcmp(fpt_command, "tline")) {
+ if (is_newcommand) {
+ noftline++;
+ if (noftline>nofseries) {
+ AddSeries();
+ }
+ }
+ //series[noftline-1].tline=1;
+ token=fpt_command;
+ /* read one more token */
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) series[noftline-1].tline=atoi(token);
+ /* read remaining tokens to go to end of line */
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ }
+ }
+ /* legend */
+ else if (!strcmp(fpt_command, "legend")) {
+ if (is_newcommand) {
+ nlegend++;
+ if (nlegend>nofseries) {
+ AddSeries();
+ }
+ }
+ token=fpt_command;
+ if (is_newcommand) {
+ series[nlegend-1].legend=(char *)realloc(series[nlegend-1].legend, sizeof(char));
+ strcpy(series[nlegend-1].legend, "");
+ }
+ else {
+ series[nlegend-1].legend=(char *)realloc(series[nlegend-1].legend,
+ (strlen(series[nlegend-1].legend)+2)*sizeof(char));
+ strcat(series[nlegend-1].legend, " ");
+ }
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ series[nlegend-1].legend=(char *)realloc(series[nlegend-1].legend,
+ (strlen(series[nlegend-1].legend)+strlen(token)+2)*sizeof(char));
+ strcat(series[nlegend-1].legend, token);
+ strcat(series[nlegend-1].legend, " ");
+ } /* endif */
+ } /* endwhile */
+ series[nlegend-1].legend[strlen(series[nlegend-1].legend)-1]='\0';
+ }
+ /* pictex commands */
+ else if (!strcmp(fpt_command, "pictex")) {
+ token=fpt_command;
+ if (is_newcommand) {
+ nofrawpictex++;
+ rawpictex=(char **)realloc(rawpictex, nofrawpictex*sizeof(char *));
+ rawpictex[nofrawpictex-1]=(char *)malloc(sizeof(char));
+ strcpy(rawpictex[nofrawpictex-1], "");
+ }
+ else {
+ rawpictex[nofrawpictex-1]=(char *)realloc(rawpictex[nofrawpictex-1],
+ (strlen(rawpictex[nofrawpictex-1])+2)*sizeof(char));
+ strcat(rawpictex[nofrawpictex-1], " ");
+ }
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ rawpictex[nofrawpictex-1]=(char *)realloc(rawpictex[nofrawpictex-1],
+ (strlen(rawpictex[nofrawpictex-1])+strlen(token)+2)*sizeof(char));
+ strcat(rawpictex[nofrawpictex-1], token);
+ strcat(rawpictex[nofrawpictex-1], " ");
+ } /* endif */
+ } /* endwhile */
+ rawpictex[nofrawpictex-1][strlen(rawpictex[nofrawpictex-1])-1]='\0';
+ }
+ /* x coordinates */
+ else if (!strcmp(fpt_command, "x")) {
+ if (is_newcommand) {
+ ndata=0;
+ nx++;
+ if (nx>nofseries) {
+ AddSeries();
+ }
+ }
+ token=fpt_command;
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ if (ndata>=nallocdata) {
+ nallocdata+=100;
+ data=(float *)realloc(data, nallocdata*sizeof(float));
+ } /* endif */
+ data[ndata]=atof(token);
+ ndata++;
+ } /* endif */
+ } /* endwhile */
+ series[nx-1].nx=ndata;
+ series[nx-1].x=(float *)realloc(series[nx-1].x, ndata*sizeof(float));
+ for (n=0; n<ndata; n++) {
+ series[nx-1].x[n]=data[n];
+ }
+ }
+ /* y coordinates */
+ else if (!strcmp(fpt_command, "y")) {
+ if (is_newcommand) {
+ ndata=0;
+ ny++;
+ if (ny>nofseries) {
+ AddSeries();
+ }
+ }
+ token=fpt_command;
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ if (ndata>=nallocdata) {
+ nallocdata+=100;
+ data=(float *)realloc(data, nallocdata*sizeof(float));
+ } /* endif */
+ series[ny-1].sig=(char **)realloc(series[ny-1].sig, (ndata+1)*sizeof(char *));
+ series[ny-1].sig[ndata]=getsig(token);
+ data[ndata]=atof(token);
+ ndata++;
+ } /* endif */
+ } /* endwhile */
+ series[ny-1].ny=ndata;
+ series[ny-1].y=(float *)realloc(series[ny-1].y, ndata*sizeof(float));
+ for (n=0; n<ndata; n++) {
+ series[ny-1].y[n]=data[n];
+ }
+ }
+ /* dx coordinates */
+ else if (!strcmp(fpt_command, "dx")) {
+ if (is_newcommand) {
+ need_errorbarmacros=1;
+ ndata=0;
+ ndx++;
+ if (ndx>nofseries) {
+ AddSeries();
+ }
+ }
+ token=fpt_command;
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ if (ndata>=nallocdata) {
+ nallocdata+=100;
+ data=(float *)realloc(data, nallocdata*sizeof(float));
+ } /* endif */
+ data[ndata]=atof(token);
+ ndata++;
+ } /* endif */
+ } /* endwhile */
+ series[ndx-1].ndx=ndata;
+ series[ndx-1].dx=(float *)realloc(series[ndx-1].dx, ndata*sizeof(float));
+ for (n=0; n<ndata; n++) {
+ series[ndx-1].dx[n]=data[n];
+ }
+ }
+ /* dy coordinates */
+ else if (!strcmp(fpt_command, "dy")) {
+ if (is_newcommand) {
+ need_errorbarmacros=1;
+ ndata=0;
+ ndy++;
+ if (ndy>nofseries) {
+ AddSeries();
+ }
+ }
+ token=fpt_command;
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ if (ndata>=nallocdata) {
+ nallocdata+=100;
+ data=(float *)realloc(data, nallocdata*sizeof(float));
+ } /* endif */
+ data[ndata]=atof(token);
+ ndata++;
+ } /* endif */
+ } /* endwhile */
+ series[ndy-1].ndy=ndata;
+ series[ndy-1].dy=(float *)realloc(series[ndy-1].dy, ndata*sizeof(float));
+ for (n=0; n<ndata; n++) {
+ series[ndy-1].dy[n]=data[n];
+ }
+ }
+ /* xticlabels */
+ else if (!strcmp(fpt_command, "xticlabels")) {
+ is_multiword=0; nxticlabels=0;
+ token=fpt_command;
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ if (token) {
+ if (is_multiword) {
+ xticlabels[nxticlabels-1]=(char *)realloc(xticlabels[nxticlabels-1],
+ strlen(xticlabels[nxticlabels-1])+1
+ +strlen(token)+1);
+ strcat(xticlabels[nxticlabels-1], " ");
+ strcat(xticlabels[nxticlabels-1], token);
+ if (token[strlen(token)-1]=='"') {
+ xticlabels[nxticlabels-1][strlen(xticlabels[nxticlabels-1])-1]='\0';
+ is_multiword=0;
+ }
+ }
+ else {
+ if (token[0]=='"') {
+ is_multiword=1;
+ token++;
+ }
+ nxticlabels++;
+ xticlabels=(char **)realloc(xticlabels, nxticlabels * sizeof(char *));
+ xticlabels[nxticlabels-1]=new char [strlen(token)+1];
+ strcpy(xticlabels[nxticlabels-1], token);
+ if (token[strlen(token)-1]=='"') {
+ xticlabels[nxticlabels-1][strlen(xticlabels[nxticlabels-1])-1]='\0';
+ is_multiword=0;
+ }
+ }
+ } /* endif */
+ } /* endwhile */
+ }
+ /* xgrid lines */
+ else if (!strcmp(fpt_command, "xgrid")) {
+ xgrid=1;
+ }
+ /* ygrid lines */
+ else if (!strcmp(fpt_command, "ygrid")) {
+ ygrid=1;
+ }
+ /* unknown command */
+ else {
+ token=fpt_command;
+ while (token) {
+ token=strtok(NULL, WHITE_SPACE);
+ }
+ }
+ /* read new line */
+ fptin.getline(hchar,MAX_FIELD_LENGTH);
+ s=(char *)realloc(s, strlen(hchar)+1);
+ strcpy(s,hchar);
+ while (fptin.fail() && !fptin.eof()) {
+ fptin.clear();
+ fptin.getline(hchar,MAX_FIELD_LENGTH);
+ s=(char *)realloc(s, strlen(s)+strlen(hchar)+1);
+ strcat(s, hchar);
+ }
+ } /* endwhile */
+
+ /* set x coordinates for bar charts if number of x coords different from number of y coords */
+ for (i=0; i<nofseries; i++) {
+ if (series[i].type==3) {
+ if (series[i].ny>0 && (series[i].nx!=series[i].ny)) {
+ series[i].nx=series[i].ny;
+ series[i].x=(float *)realloc(series[i].x, series[i].nx*sizeof(float));
+ for (n=0; n<series[i].nx; n++) {
+ series[i].x[n]=n+1;
+ }
+ }
+ }
+ }
+ /* set x coordinates for line and xy series without x-values */
+ linenoxmax=-1; j=0;
+ for (i=0; i<nofseries; i++) {
+ if ((series[i].type==2 || series[i].type==1) && series[i].nx==0) {
+ if (series[i].ny>0) {
+ if (series[i].ny>j) {j=series[i].ny; linenoxmax=i;}
+ series[i].nx=series[i].ny;
+ series[i].x=(float *)realloc(series[i].x, series[i].nx*sizeof(float));
+ for (n=0; n<series[i].nx; n++) {
+ series[i].x[n]=n+1;
+ }
+ }
+ }
+ }
+ /* close input file */
+ free(s); free(hchar); free(fpt_command);
+ free(data);
+ fptin.close();
+ return(rc);
+}
+
+/* function to write PicTeX file */
+int FASTPICTEX::Write(char *fname) {
+ std::ofstream pictex;
+ int rc=0, i, j, is_fault;
+ short is_valid, is_first;
+ short nxy=0, nline=0, nbar=0;
+ unsigned long n;
+ float xmin=0, xmax=10, xstep=1, ymin=0, ymax=10, ystep=1;
+ float xlmin, xlmax;
+ float valmin=0, valmax=10, step=1;
+ float xunit, yunit;
+ float ypos;
+ unsigned long nreg;
+ float sx, sy, sx2, sy2, sxy, qx, qy, qxy;
+ float ax, bx, ay, by, r, s2xy, s2yx, pwert;
+ float rxmin, rxmax;
+
+ extern float prho(int n, float is, int *ifault);
+ extern int scale(float fmn, float fmx, int n, float *valmin, float *step, float *valmax);
+
+ /* open output file */
+ pictex.open(fname);
+ if (!pictex) {
+ rc=1;
+ std::cout << "Cannot open output file! \n";
+ return(rc);
+ }
+
+ /* write header of pictex file */
+ pictex << "% ...... start of pictex file generated by FastPicTeX ...... \n";
+ pictex << "\\beginpicture \n";
+ /* need errorbar macros ? */
+ if (need_errorbarmacros) {
+ pictex << "% ...... macros for errorbars ...... \n";
+ pictex << "\\newcommand{\\putxerrorbar}[3]{% \n";
+ pictex << "\\dimen0=\\Xdistance{#1} \\dimen1=\\Ydistance{#2} \\dimen2=\\Xdistance{#3} \n";
+ pictex << "\\unitlength=1pt \\setdimensionmode \n";
+ pictex << "\\dimen3=\\dimen0 \\advance \\dimen3 by -\\dimen2 \n";
+ pictex << "\\dimen4=\\dimen0 \\advance \\dimen4 by \\dimen2 \n";
+ pictex << "\\dimen5=\\dimen1 \\advance \\dimen5 by -1mm \n";
+ pictex << "\\dimen6=\\dimen1 \\advance \\dimen6 by 1mm \n";
+ pictex << "\\putrule from {\\dimen3} {\\dimen1} to {\\dimen4} {\\dimen1} \n";
+ pictex << "\\putrule from {\\dimen3} {\\dimen5} to {\\dimen3} {\\dimen6} \n";
+ pictex << "\\putrule from {\\dimen4} {\\dimen5} to {\\dimen4} {\\dimen6} \n";
+ pictex << "\\setcoordinatemode } \n";
+ pictex << "\\newcommand{\\putyerrorbar}[3]{% \n";
+ pictex << "\\dimen0=\\Xdistance{#1} \\dimen1=\\Ydistance{#2} \\dimen2=\\Ydistance{#3} \n";
+ pictex << "\\unitlength=1pt \\setdimensionmode \n";
+ pictex << "\\dimen3=\\dimen1 \\advance \\dimen3 by -\\dimen2 \n";
+ pictex << "\\dimen4=\\dimen1 \\advance \\dimen4 by \\dimen2 \n";
+ pictex << "\\dimen5=\\dimen0 \\advance \\dimen5 by -1mm \n";
+ pictex << "\\dimen6=\\dimen0 \\advance \\dimen6 by 1mm \n";
+ pictex << "\\putrule from {\\dimen0} {\\dimen3} to {\\dimen0} {\\dimen4} \n";
+ pictex << "\\putrule from {\\dimen5} {\\dimen3} to {\\dimen6} {\\dimen3} \n";
+ pictex << "\\putrule from {\\dimen5} {\\dimen4} to {\\dimen6} {\\dimen4} \n";
+ pictex << "\\setcoordinatemode } \n";
+ }
+ /* get extrema */
+ GetExtrema(0,0.0,0.0,&xmin, &xmax, &ymin, &ymax);
+ /* write coordinate-system and axis */
+ /* number of x-tics depend on xticlabels first */
+ xlmin=FLT_MIN; xlmax=FLT_MAX;
+ if (nxticlabels>0) {
+ xlmin=1.0; xlmax=(float)nxticlabels;
+ GetExtrema(1, xlmin, xlmax, &xmin, &xmax, &ymin, &ymax);
+ xmin=1.0; xmax=(float)nxticlabels;
+ scale(xmin-1, xmax+1, nxticlabels+2, &valmin, &step, &valmax);
+ }
+ /* number of x-tics depend on bar-graphs second */
+ else if (nofbar>0) {
+ j=0;
+ for (i=0; i<nofseries; i++) {
+ if (series[i].type==3)
+ if (series[i].nx>j) j=series[i].nx;
+ }
+ scale(xmin-1, xmax+1, j+2, &valmin, &step, &valmax);
+ }
+ /* number of x-tics depend on line- and xy-series without x-values third */
+ else if (linenoxmax>=0)
+ scale(xmin-1, xmax+1, series[linenoxmax].nx+2, &valmin, &step, &valmax);
+ /* finally default */
+ else
+ scale(xmin, xmax, N_XTICKS, &valmin, &step, &valmax);
+ xstep=floor(step*10000.0+0.5)/10000.0;
+ if (xmin>valmin) xmin=floor(valmin*10000.0+0.5)/10000.0;
+ else xmin=floor((valmin-xstep)*10000.0+0.5)/10000.0;
+ if (xmax<valmax) xmax=floor(valmax*10000.0+0.5)/10000.0;
+ else xmax=floor((valmax+xstep)*10000.0+0.5)/10000.0;
+ scale(ymin, ymax, N_YTICKS, &valmin, &step, &valmax);
+ ystep=floor(step*10000.0+0.5)/10000.0;
+ if (ymin>valmin) ymin=floor(valmin*10000.0+0.5)/10000.0;
+ else ymin=floor((valmin-ystep)*10000.0+0.5)/10000.0;
+ if (ymax<valmax) ymax=floor(valmax*10000.0+0.5)/10000.0;
+ else ymax=floor((valmax+ystep)*10000.0+0.5)/10000.0;
+ xunit=width/(xmax-xmin);
+ yunit=height/(ymax-ymin);
+ pictex << "\\setcoordinatesystem units <" << xunit << "cm,"
+ << yunit << "cm> point at 0 0 \n";
+ pictex << "\\setplotarea x from " << xmin << " to " << xmax
+ << ", y from " << ymin << " to " << ymax << " \n";
+ /* plot axis */
+ pictex << "% .......... axis ............ \n";
+ pictex << "\\axis bottom ";
+ if (xlabel) pictex << "label {" << xlabel << "} ";
+ pictex << "ticks ";
+ if (xgrid) pictex << "andacross ";
+ if (nxticlabels==0) {
+ pictex << "numbered from "
+ << xmin << " to " << xmax << " by " << xstep << " / \n";
+ }
+ else {
+ pictex << "withvalues {} ";
+ for (n=0; n<nxticlabels; n++) pictex << "{" << xticlabels[n] << "}" << " ";
+ pictex << "{} / \n";
+ pictex << "quantity " << nxticlabels+2 << " / \n";
+ }
+ pictex << "\\axis left ";
+ if (ylabel) pictex << "label {" << ylabel << "} ";
+ pictex << "ticks ";
+ if (ygrid) pictex << "andacross ";
+ pictex << "numbered from "
+ << ymin << " to " << ymax << " by " << ystep << " / \n";
+ /* plot heading */
+ pictex << "% .......... heading ............ \n";
+ if (heading) pictex << "\\plotheading {" << heading << "} \n";
+ /* plot series */
+ pictex.setf(std::ios::fixed);
+ pictex << "% .......... series ............. \n";
+ for (i=0; i<nofseries; i++) {
+ switch (series[i].type) {
+ case 1: // xy plot;
+ /* write dots and calculate regression line */
+ sx2=0; sy2=0; sx=0; sy=0; sxy=0; nreg=0;
+ for (n=0; n<series[i].nx; n++) {
+ if (series[i].x[n]>=xlmin && series[i].x[n]<=xlmax) {
+ pictex << "\\put {" << plotsym[(int)fmod(nxy,10)] << "} at "
+ << series[i].x[n] << " " << series[i].y[n] << " \n";
+ sx2+=(series[i].x[n]*series[i].x[n]); sy2+=(series[i].y[n]*series[i].y[n]);
+ sxy+=(series[i].x[n]*series[i].y[n]);
+ sx+=series[i].x[n]; sy+=series[i].y[n];
+ nreg++;
+ if (series[i].ndx>n) {
+ pictex << "\\putxerrorbar{" << series[i].x[n] << "}{"
+ << series[i].y[n] << "}{" << series[i].dx[n] << "} \n";
+ }
+ if (series[i].ndy>n) {
+ pictex << "\\putyerrorbar{" << series[i].x[n] << "}{"
+ << series[i].y[n] << "}{" << series[i].dy[n] << "} \n";
+ }
+ /* plot significance signs */
+ if (series[i].sig[n]) {
+ ypos=series[i].y[n];
+ if (series[i].ndy>n) ypos+=series[i].dy[n];
+ pictex << "\\put {" << series[i].sig[n] << "} [b] <0mm,0.5\\baselineskip> at "
+ << series[i].x[n] << " " << ypos << "\n";
+ }
+ }
+ }
+ /* calculate regression line */
+ if (nreg>2) {
+ qx=sx2-(sx*sx/nreg); qy=sy2-(sy*sy/nreg); qxy=sxy-(sx*sy/nreg);
+ r=qxy/sqrt(qx*qy);
+ by=qxy/qx; bx=qxy/qy;
+ ay=(sy-by*sx)/nreg; ax=(sx-bx*sy)/nreg;
+ s2yx=(qy-(qxy*qxy/qx))/(nreg-2);
+ s2xy=(qx-(qxy*qxy/qy))/(nreg-2);
+ pwert=2.0*(1.0-prho(nreg, (nreg*nreg*nreg-nreg)*(1.0-fabs(r))/6.0, &is_fault));
+ series[i].m1=by; series[i].m2=bx; series[i].b=ay; series[i].nreg=nreg;
+ if (pwert>1.0) pwert=1.0;
+ if (pwert<0.0) pwert=0.0;
+ /* plot regression line */
+ rxmin=xmin; rxmax=xmax;
+ if (series[i].tline>0) {
+ if (ymin>xmin*by+ay) rxmin=(ymin-ay)/by;
+ if (ymax<xmin*by+ay) rxmin=(ymax-ay)/by;
+ if (ymin>xmax*by+ay) rxmax=(ymin-ay)/by;
+ if (ymax<xmax*by+ay) rxmax=(ymax-ay)/by;
+ pictex << "\\setlinear \n";
+ pictex << linesym[(int)fmod(nxy,10)] << " \n";
+ /* set formatting */
+ pictex << "\\plot " << rxmin << " " << rxmin*by+ay << " "
+ << rxmax << " " << rxmax*by+ay << " /\n";
+ }
+ } /* endif nreg>2 */
+ else series[i].tline=0;
+ /* clean up */
+ nxy++;
+ break;
+ case 2: // line graph;
+ /* write lines */
+ pictex << "\\setlinear \n";
+ pictex << linesym[(int)fmod(nline,10)] << " \n";
+ is_first=1;
+ for (n=0; n<series[i].nx; n++) {
+ if (series[i].x[n]>=xlmin && series[i].x[n]<=xlmax) {
+ if (is_first) {pictex << "\\plot "; is_first=0;}
+ pictex << series[i].x[n] << " " << series[i].y[n] << " ";
+ }
+ }
+ pictex << "/ \n";
+ pictex << "\\setsolid \n";
+ for (n=0; n<series[i].nx; n++) {
+ if (series[i].x[n]>=xlmin && series[i].x[n]<=xlmax) {
+ if (series[i].ndx>n) {
+ pictex << "\\putxerrorbar{" << series[i].x[n] << "}{"
+ << series[i].y[n] << "}{" << series[i].dx[n] << "} \n";
+ }
+ if (series[i].ndy>n) {
+ pictex << "\\putyerrorbar{" << series[i].x[n] << "}{"
+ << series[i].y[n] << "}{" << series[i].dy[n] << "} \n";
+ }
+ /* plot significance signs */
+ if (series[i].sig[n]) {
+ ypos=series[i].y[n];
+ if (series[i].ndy>n) ypos+=series[i].dy[n];
+ pictex << "\\put {" << series[i].sig[n] << "} [b] <0mm,0.5\\baselineskip> at "
+ << series[i].x[n] << " " << ypos << "\n";
+ }
+ }
+ }
+ nline++;
+ break;
+ case 3: // bar graph;
+ /* write bars */
+ if (nbar==0) {
+ pictex << "\\shaderectanglesoff \n";
+ }
+ if (nbar>0 && nbar<nofbar-1) {
+ pictex << "\\shaderectangleson \n";
+ pictex << "\\setshadegrid span <" << 1.0-(float)(nbar-1)/(float)(nofbar-2) << "mm> \n";
+ }
+ if (nbar!=0 && nbar==nofbar-1) {
+ pictex << "\\shaderectanglesoff%\n";
+ pictex << "\\dimen0=\\linethickness%\n";
+ pictex << "%look here\n";
+ pictex << "\\setlength{\\linethickness}{" << (BARWIDTH*xunit)/(float)nofbar << "cm}%\n";
+ //pictex << "\\setlength{\\linethickness}{\\Xdistance{" << BARWIDTH/(float)nofbar << "}}%\n";
+ }
+ if (nbar==0 || nbar<nofbar-1) {
+ for (n=0; n<series[i].nx; n++) {
+ if (series[i].x[n]>=xlmin && series[i].x[n]<=xlmax) {
+ pictex << "\\putrectangle corners at ";
+ pictex << (series[i].x[n]-BARWIDTH/2.0)+(BARWIDTH*(float)nbar/(float)nofbar) << " " << ymin << " and ";
+ pictex << (series[i].x[n]-BARWIDTH/2.0)+(BARWIDTH*(float)(nbar+1)/(float)nofbar) << " "
+ << series[i].y[n] << " \n";
+ }
+ }
+ }
+ if (nbar!=0 && nbar==nofbar-1) {
+ for (n=0; n<series[i].nx; n++) {
+ if (series[i].x[n]>=xlmin && series[i].x[n]<=xlmax) {
+ pictex << "\\putrule from "
+ << (series[i].x[n]-BARWIDTH/2)+BARWIDTH/(float)(2*nofbar)+(BARWIDTH*(float)(nbar)/(float)nofbar) << " "
+ << ymin << " to "
+ << (series[i].x[n]-BARWIDTH/2)+BARWIDTH/(float)(2*nofbar)+(BARWIDTH*(float)(nbar)/(float)nofbar) << " "
+ << series[i].y[n] << " \n";
+ }
+ }
+ pictex << "\\setlength{\\linethickness}{\\dimen0}%\n";
+ }
+ for (n=0; n<series[i].nx; n++) {
+ if (series[i].x[n]>=xlmin && series[i].x[n]<=xlmax) {
+ /* plot errorbars */
+ if (series[i].ndy>n) {
+ pictex << "\\putyerrorbar{"
+ << (series[i].x[n]-BARWIDTH/2)+BARWIDTH/(float)(2*nofbar)+(BARWIDTH*(float)(nbar)/(float)nofbar)
+ << "}{"
+ << series[i].y[n] << "}{" << series[i].dy[n] << "} \n";
+ }
+ /* plot significance signs */
+ if (series[i].sig[n]) {
+ ypos=series[i].y[n];
+ if (series[i].ndy>n) ypos+=series[i].dy[n];
+ pictex << "\\put {" << series[i].sig[n] << "} [b] <0mm,0.5\\baselineskip> at "
+ << (series[i].x[n]-BARWIDTH/2)+BARWIDTH/(float)(2*nofbar)+(BARWIDTH*(float)(nbar)/(float)nofbar)
+ << " " << ypos << "\n";
+ }
+ }
+ }
+ nbar++;
+ break;
+ } /* endswitch */
+ } /* endfor */
+ /* legend */
+ is_valid=0;
+ for (i=0; i<nofseries; i++) {
+ if ((strlen(series[i].legend)>0) ||
+ (series[i].type==1 && series[i].tline>0 && series[i].nreg>2))
+ is_valid=1;
+ }
+ if (is_valid) {
+ pictex << "% .......... legends ............. \n";
+ j=0; nxy=0; nbar=0, nline=0;
+ for (i=0; i<nofseries; i++) {
+ if ((strlen(series[i].legend)>0) ||
+ (series[i].type==1 && series[i].tline>0 && series[i].nreg>2)) {
+ /* first symbols */
+ if (series[i].type==1) { /* xy */
+ if (series[i].tline>0 && series[i].nreg>2) {
+ pictex << "\\put {" << plotsym[(int)fmod(nxy,10)] << "} [cc] <0.2cm,-" << 2.5*j+1 << "ex> at " << xmax << " " << ymax << "\n";
+ pictex << "\\setlinear \n";
+ pictex << linesym[(int)fmod(nxy,10)] << " \n";
+ pictex << "\\put {\\frame{\\hspace*{8mm}}} [lc] <0.4cm,-" << 2.5*j+1 << "ex> at " << xmax << " " << ymax << "\n";
+ }
+ else
+ pictex << "\\put {" << plotsym[(int)fmod(nxy,10)] << "} [cc] <0.8cm,-" << 2.5*j+1 << "ex> at " << xmax << " " << ymax << "\n";
+ }
+ if (series[i].type==2) { /* line */
+ pictex << linesym[(int)fmod(nline,10)] << " \n";
+ pictex << "\\putrule <0.4cm,-" << 2.5*j+1 << "ex> from " <<
+ xmax << " " << ymax << " to " << xmax+0.8/xunit << " " << ymax << "\n";
+ }
+ if (series[i].type==3) { /* bar */
+ if (nbar==0) {
+ pictex << "\\shaderectanglesoff \n";
+ pictex << "\\putrectangle <5mm,-" << 2.5*j << "ex> corners at " <<
+ xmax << " " << ymax << " and " << xmax+0.6/xunit << " " << ymax-0.3/yunit << "\n";
+ }
+ if (nbar>0 && nbar<nofbar-1) {
+ pictex << "\\shaderectangleson \n";
+ pictex << "\\setshadegrid span <" << 1.0-(float)(nbar-1)/(float)(nofbar-2) << "mm> \n";
+ pictex << "\\putrectangle <5mm,-" << 2.5*j << "ex> corners at " <<
+ xmax << " " << ymax << " and " << xmax+0.6/xunit << " " << ymax-0.3/yunit << "\n";
+ }
+ if (nbar!=0 && nbar==nofbar-1) {
+ pictex << "\\shaderectanglesoff%\n";
+ pictex << "\\dimen0=\\linethickness%\n";
+ pictex << "\\setlength{\\linethickness}{6mm}%\n";
+ pictex << "\\putrule <8mm,-" << 2.5*j << "ex> from " <<
+ xmax << " " << ymax << " to " << xmax << " " << ymax-0.3/yunit << "\n";
+ pictex << "\\setlength{\\linethickness}{\\dimen0}%\n";
+ }
+ }
+ /* then labels */
+ pictex << "\\put {" << series[i].legend;
+ if (series[i].type==1 && series[i].tline>0 && series[i].nreg>2) {
+ if (strlen(series[i].legend)>0) pictex << ", n=" << series[i].nreg;
+ else pictex << "n=" << series[i].nreg;
+ }
+ pictex << "} [lc] <1.4cm,-" << 2.5*j+1 << "ex> at " << xmax << " " << ymax << "\n";
+ j++;
+ if (series[i].type==1 && series[i].tline==2 && series[i].nreg>2) {
+ pictex << "\\put ";
+ by=series[i].m1; ay=series[i].b; bx=series[i].m2;
+ pictex.precision(3);
+ if (ay>0)
+ pictex << "{\\footnotesize $(y=" << by << "x+" << ay << ", r^2=" << by*bx << ")$}";
+ else pictex << "{\\footnotesize $(y=" << by << "x-" << (-1)*ay << ", r^2=" << by*bx << ")$}";
+ pictex.precision(6);
+ pictex << " [lc] <1.4cm,-" << 2.5*j+1 << "ex> at " << xmax << " " << ymax << "\n";
+ j++;
+ }
+ }
+ if (series[i].type==1) nxy++;
+ if (series[i].type==2) nline++;
+ if (series[i].type==3) nbar++;
+ } /* endfor i */
+ } /* endif is_valid */
+ /* pictex commands */
+ if (nofrawpictex>0) pictex << "% .......... rawpictex ............. \n";
+ for (i=0; i<nofrawpictex; i++) pictex << rawpictex[i] << " \n";
+
+ /* close pictex file */
+ pictex << "\\endpicture \n";
+ pictex << "% ...... end of pictex file generated by FastPicTeX ...... \n";
+ pictex.close();
+ return(rc);
+}
+
+/* function to add a new series */
+int FASTPICTEX::AddSeries() {
+ nofseries++;
+ series=(SERIES *)realloc(series, nofseries*sizeof(SERIES));
+ series[nofseries-1].type=0; /* graph type not defined (0) */
+ series[nofseries-1].ndata=0;
+ series[nofseries-1].nx=0; series[nofseries-1].ny=0;
+ series[nofseries-1].ndx=0; series[nofseries-1].ndy=0;
+ series[nofseries-1].tline=0; /* no trendline */
+ series[nofseries-1].x=(float *)malloc(sizeof(float));
+ series[nofseries-1].y=(float *)malloc(sizeof(float));
+ series[nofseries-1].dx=(float *)malloc(sizeof(float));
+ series[nofseries-1].dy=(float *)malloc(sizeof(float));
+ series[nofseries-1].sig=(char **)malloc(sizeof(char *));
+ series[nofseries-1].legend=(char *)malloc(sizeof(char));
+ strcpy(series[nofseries-1].legend, "\0");
+}
+
+
+/* Get Extrema */
+int FASTPICTEX::GetExtrema(short is_limit, float x1, float x2, float *xmin, float *xmax, float *ymin, float *ymax) {
+ int rc=0, i;
+ unsigned long n;
+ float wert1, wert2;
+ float mxmin, mxmax, mymin, mymax;
+
+ if (nofseries>0) {
+ /* start values */
+ mxmin=FLT_MAX; mymin=FLT_MAX;
+ mxmax=FLT_MIN; mymax=FLT_MIN;
+ for (i=0; i<nofseries; i++) {
+ for (n=0; n<series[i].nx; n++) {
+ if (!is_limit || (is_limit && series[i].x[n]<=x2 && series[i].x[n]>=x1)) {
+ if (series[i].ndx>n) {
+ wert1=series[i].x[n]-series[i].dx[n];
+ wert2=series[i].x[n]+series[i].dx[n];
+ }
+ else {
+ wert1=series[i].x[n];
+ wert2=series[i].x[n];
+ }
+ if (mxmin>wert1) mxmin=wert1;
+ if (mxmax<wert2) mxmax=wert2;
+ if (series[i].ndy>n) {
+ wert1=series[i].y[n]-series[i].dy[n];
+ wert2=series[i].y[n]+series[i].dy[n];
+ }
+ else {
+ wert1=series[i].y[n];
+ wert2=series[i].y[n];
+ }
+ if (mymin>wert1) mymin=wert1;
+ if (mymax<wert2) mymax=wert2;
+ } /* endif limit */
+ } /* endfor */
+ } /* endfor */
+ *xmin=mxmin; *xmax=mxmax;
+ *ymin=mymin; *ymax=mymax;
+ }
+ else rc=-1;
+ return(rc);
+}
diff --git a/support/fastpictex/src/fastpictex.h b/support/fastpictex/src/fastpictex.h
new file mode 100644
index 0000000000..f73e8d4d95
--- /dev/null
+++ b/support/fastpictex/src/fastpictex.h
@@ -0,0 +1,73 @@
+/*******************************************************/
+/* Linux GNU C++ Compiler */
+/* Name : fastpictex.h */
+/* Autor: Harald Stauss */
+/*******************************************************/
+
+#ifndef FPICTEX
+#define FPICTEX
+#define MAX_FIELD_LENGTH 256
+#define WHITE_SPACE " \t\n\0"
+#define NSYMBOL 10 /* number of different plot symbols */
+#define N_XTICKS 5 /* number of ticks on x-scale */
+#define N_YTICKS 5 /* number of ticks on y-scale */
+#define BARWIDTH 0.8 /* How much space is used for bar graphs 0-1 */
+
+#include <string.h>
+
+class FASTPICTEX {
+
+ typedef struct {
+ short type; /* type of graph: 0:ndef, 1:xy, 2:line, 3:bar */
+ short tline; /* trendline for xy: 0:no, 1:yes no formula, 2: yes with formula */
+ float m1, m2, b; /* linear regression line parameters */
+ unsigned long nreg; /* number of data points for regression line */
+ unsigned long ndata, nx, ny, ndx, ndy; /* number of data points */
+ float *x; /* pointer to x values */
+ float *y; /* pointer to y values */
+ float *dx; /* pointer to x-errors */
+ float *dy; /* pointer to y-errors */
+ char **sig; /* pointer to sig. signs */
+ char *legend; /* pointer to legend string */
+ }
+ SERIES;
+
+ /* holds plot symbols */
+ char plotsym[NSYMBOL][80];
+ char linesym[NSYMBOL][80];
+ short need_errorbarmacros;
+
+ /* To add a new series */
+ int AddSeries();
+
+ /* Get Extrema */
+ int GetExtrema(short is_limit, float x1, float x2, float *xmin, float *xmax, float *ymin, float *ymax);
+
+public:
+
+ float width, height; /* width and height of graph */
+ short nofseries; /* number of series */
+ short nofbar; /* number of bar graph series */
+ short linenoxmax; /* fist line graph without x-values */
+ short noftline; /* number of trendlines */
+ short xgrid, ygrid; /* if 1 draw x/y-gridlines */
+ char *xlabel, *ylabel, *heading; /* various labels */
+ unsigned long nxticlabels; /* number of ticlabels */
+ char **xticlabels; /* pointers to x tic labels */
+ int nofrawpictex; /* number of pictex commands */
+ char **rawpictex; /* raw pictex commands */
+ SERIES *series; /* pointer to an array of SERIES */
+
+ /* Initialisierung der Registrierung */
+ FASTPICTEX(); // Constructor;
+ ~FASTPICTEX(); // Destructor;
+
+ /* function to read input file */
+ int Read(char *fname);
+
+ /* function to write PicTeX file */
+ int Write(char *fname);
+
+}; /* Ende der Klassendefinition */
+
+#endif
diff --git a/support/fastpictex/src/global.h b/support/fastpictex/src/global.h
new file mode 100644
index 0000000000..32bd0e05ee
--- /dev/null
+++ b/support/fastpictex/src/global.h
@@ -0,0 +1,2 @@
+#define VERSION "0.9"
+extern FASTPICTEX fpt;
diff --git a/support/fastpictex/src/main.cc b/support/fastpictex/src/main.cc
new file mode 100644
index 0000000000..e1f593954e
--- /dev/null
+++ b/support/fastpictex/src/main.cc
@@ -0,0 +1,40 @@
+/* Program main.cc (FastPicTeX) */
+/* By Harald Stauss */
+/* Last change January 12, 2008 */
+
+#include <iostream>
+#include "fastpictex.h"
+
+#ifdef DUMA
+ #include <new>
+ #include "../../duma/duma.h"
+ #include "../../duma/dumapp.h"
+#endif
+
+/* global variables */
+#define VERSION "0.9"
+FASTPICTEX fpt;
+
+main(int argc, char *argv[]) {
+ int rc=0;
+
+ /* hello world */
+ std::cout << "FastPicTeX by Harald M. Stauss, Ver. " << VERSION << "\n";
+
+ /* allocate memory */
+
+ /* get command line parameters */
+ if (argc!=3) {
+ rc=1;
+ std::cout << "number of parameters wrong! \n";
+ std::cout << "usage: fastpictex fin fout \n";
+ goto ende;
+ }
+
+ fpt.Read(argv[1]);
+
+ fpt.Write(argv[2]);
+
+ende:
+ return(rc);
+} /* Ende von main */
diff --git a/support/fastpictex/src/myfunctions.cc b/support/fastpictex/src/myfunctions.cc
new file mode 100644
index 0000000000..1bfb73b6b1
--- /dev/null
+++ b/support/fastpictex/src/myfunctions.cc
@@ -0,0 +1,211 @@
+#include <iostream>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+int myatoi(char *s, int *i) {
+ float wert;
+ int rc=0;
+ char *endp;
+
+ wert=strtod(s, &endp);
+ if (s==endp) {
+ rc=0;
+ }
+ else {
+ *i=(int)floor(wert);
+ rc=1;
+ }
+ return(rc);
+}
+
+int myatof(char *s, float *f) {
+ double wert;
+ int rc=0;
+ char *endp;
+
+ wert=strtod(s, &endp);
+ if (s==endp) {
+ rc=0;
+ }
+ else {
+ *f=(float)wert;
+ rc=1;
+ }
+ return(rc);
+}
+
+char *getsig(char *s) {
+ char *a, *b, *rc;
+ /* allocates memory for a string in */
+ /* doublequotes and returns a pointer to it */
+ if (strchr(s, '"')) {
+ a=strchr(s, '"');
+ b=strrchr(s, '"');
+ if (a<b) {
+ rc=new char[b-a];
+ strncpy(rc, (a+1), b-a-1);
+ rc[b-a-1]='\0';
+ }
+ else {
+ rc=new char[1];
+ strcpy(rc,"\0");
+ }
+ }
+ else {
+ rc=new char[1];
+ strcpy(rc,"\0");
+ }
+ return rc;
+}
+
+float prho(int n, float is, int *ifault) {
+/*
+ Algorithm AS 89 Appl. Statist. (1975) Vol.24, No. 3, P377.
+
+ To evaluate the probability of obtaining a value greater than or
+ equal to is, where is=(n**3-n)*(1-r)/6, r=Spearman's rho and n
+ must be greater than 1
+
+ n is the number of data pairs in the correlation
+ The calculated probability is for one-sided tests.
+ For two-sided tests multiply the probability value with 2.
+
+ Auxiliary function required: ALNORM = algorithm AS66
+*/
+
+ float c1=0.2274, c2=0.2531, c3=0.1745, c4=0.0758, c5=0.1033, c6=0.3932;
+ float c7=0.0879, c8=0.0151, c9=0.0072, c10=0.0831, c11=0.0131, c12=0.00046;
+ float rc;
+ double b, x, y, u;
+ long i, js, ifr, nfac, m, n1, mt, nn, ise;
+ long l[7];
+
+ extern float alnorm(float x, int upper);
+
+ /* Test admissibility of arguments and initialize */
+ rc=1.0;
+ *ifault=1;
+ if (n<=1) return(rc);
+ *ifault=0;
+ if (is<=0) return(rc);
+ rc=0.0;
+ if (is > n*(n*n-1)/3) return(rc);
+ js=(long)is;
+ if (js!= 2*(js/2)) js=js+1;
+ /* if (n>6) goto mark6; */
+ goto mark6;
+
+ /* Exact evaluation of probability */
+ nfac=1;
+ for (i=1; i<=n; i++) {
+ nfac*=i;
+ l[i]=i;
+ }
+mark1:
+ rc=1.0/(float)(nfac);
+ if (js != n*(n*n-1)/3) return(rc);
+ ifr=0;
+ for (m=1; m<=nfac; m++) {
+ ise=0;
+ for (i=1; i<=n; i++) {
+ ise+=(i-l[i])*(i-l[i]);
+ }
+ mark2:
+ if (js <= ise) ifr++;
+ n1=n;
+ mark3:
+ mt=l[1];
+ nn=n1-1;
+ for (i=1; i<=nn; i++) {
+ l[i]=l[i+1];
+ }
+ mark4:
+ l[n1]=mt;
+ if ((l[n1]!=n1) || (n1==2)) goto mark5;
+ n1--;
+ if (m!=nfac) goto mark3;
+ }
+mark5:
+ rc=(float)(ifr)/(float)(nfac);
+ return(rc);
+ /* Evaluation by Edgeworth series expansion */
+mark6:
+ b=1.0/(double)(n);
+ x=(6.0*((double)(js)-1.0)*b/(1.0/(b*b)-1.0)-1.0)*sqrt(1.0/b-1.0);
+ y=x*x;
+ u=x*b*(c1+b*(c2+c3*b)+y*(-c4+b*(c5+c6*b)-y*b*(c7+c8*b-y*(c9-c10*b+y*b*(c11-c12*y)))));
+ /* Call to algorithm AS 66 */
+ rc=u/exp(y/2.0)+alnorm(x,1);
+ if (rc < 0.0) rc=0.0;
+ if (rc > 1.0) rc=1.0;
+ return(rc);
+}
+
+
+/*
+ Algorithm AS66 Applied Statistics (1973) vol22 no.3
+ Evaluates the tail area of the standardised normal curve
+ from x to infinity if upper is .true. or
+ from minus infinity to x if upper is .false.
+*/
+float stdnorm(float x) {
+ return (1.0/sqrt(2*3.141592653))*exp(-0.5*x*x);
+}
+float alnorm(float x, int upper) {
+ float q;
+
+ float stdnorm(float x);
+ extern float qtrap(float (*func)(float x), float a, float b);
+
+ if (x==0.0) q=0;
+ else q=qtrap(&stdnorm, 0, x);
+
+ if (upper) q=1.0-q-0.5;
+ else q+=0.5;
+
+ return(q);
+}
+
+
+#define EPS 1.0e-5
+#define JMAX 20
+float qtrap(float (*func)(float), float a, float b)
+{
+ float trapzd(float (*func)(float), float a, float b, int n);
+ void nrerror(char error_text[]);
+ int j;
+ float s,olds;
+
+ olds = -1.0e30;
+ for (j=1;j<=JMAX;j++) {
+ s=trapzd(func,a,b,j);
+ if (fabs(s-olds) < EPS*fabs(olds)) return s;
+ olds=s;
+ }
+ nrerror("Too many steps in routine qtrap");
+ return 0.0;
+}
+#undef EPS
+#undef JMAX
+
+#define FUNC(x) ((*func)(x))
+float trapzd(float (*func)(float), float a, float b, int n)
+{
+ float x,tnm,sum,del;
+ static float s;
+ int it,j;
+
+ if (n == 1) {
+ return (s=0.5*(b-a)*(FUNC(a)+FUNC(b)));
+ } else {
+ for (it=1,j=1;j<n-1;j++) it <<= 1;
+ tnm=it;
+ del=(b-a)/tnm;
+ x=a+0.5*del;
+ for (sum=0.0,j=1;j<=it;j++,x+=del) sum += FUNC(x);
+ s=0.5*(s+(b-a)*sum/tnm);
+ return s;
+ }
+}
+#undef FUNC
diff --git a/support/fastpictex/src/nrutil.cc b/support/fastpictex/src/nrutil.cc
new file mode 100644
index 0000000000..f6ecb08faf
--- /dev/null
+++ b/support/fastpictex/src/nrutil.cc
@@ -0,0 +1,284 @@
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#define NR_END 1
+#define FREE_ARG char*
+
+void nrerror(char error_text[])
+/* Numerical Recipes standard error handler */
+{ fprintf(stderr,"Numerical Recipes run-time error...\n");
+ fprintf(stderr,"%s\n",error_text);
+ fprintf(stderr,"...now exiting to system...\n");
+ exit(1);
+}
+
+float *vector(long nl, long nh)
+/* allocate a float vector with subscript range v[nl..nh] */
+{
+ float *v;
+
+ v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
+ if (!v) nrerror("allocation failure in vector()");
+ return v-nl+NR_END;
+}
+
+int *ivector(long nl, long nh)
+/* allocate an int vector with subscript range v[nl..nh] */
+{
+ int *v;
+
+ v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
+ if (!v) nrerror("allocation failure in ivector()");
+ return v-nl+NR_END;
+}
+
+unsigned char *cvector(long nl, long nh)
+/* allocate an unsigned char vector vith subscript range v[nl..nh] */
+{
+ unsigned char *v;
+
+ v=(unsigned char *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
+ if (!v) nrerror("allocation failure in cvector()");
+ return v-nl+NR_END;
+}
+
+unsigned long *lvector(long nl, long nh)
+/* allocate an unsigned long vector with subscript range v[nl..nh] */
+{
+ unsigned long *v;
+
+ v=(unsigned long *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(long)));
+ if (!v) nrerror("allocation failure in lvector()");
+ return v-nl+NR_END;
+}
+
+double *dvector(long nl, long nh)
+/* allocate a double vector with subscript range v[nl..nh] */
+{
+ double *v;
+
+ v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
+ if (!v) nrerror("allocation failure in dvector()");
+ return v-nl+NR_END;
+}
+
+float **matrix(long nrl, long nrh, long ncl, long nch)
+/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+ long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+ float **m;
+
+ /* allocate pointers to rows */
+ m=(float **) malloc((size_t)((nrow+NR_END)*sizeof(float*)));
+ if (!m) nrerror("allocation failure 1 in matrix()");
+ m += NR_END;
+ m -= nrl;
+
+ /* allocate rows and set pointers to them */
+ m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
+ if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+ m[nrl] += NR_END;
+ m[nrl] -= ncl;
+
+ for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+ /* return pointer to array of pointers to rows */
+ return m;
+}
+
+double **dmatrix(long nrl, long nrh, long ncl, long nch)
+/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+ long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+ double **m;
+
+ /* allocate pointers to rows */
+ m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
+ if (!m) nrerror("allocation failure 1 in matrix()");
+ m += NR_END;
+ m -= nrl;
+
+ /* allocate rows and set pointers to them */
+ m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
+ if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+ m[nrl] += NR_END ;
+ m[nrl] -= ncl;
+
+ for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+ /* return pointer to array of pointers to rows */
+ return m;
+}
+
+int **imatrix(long nrl, long nrh, long ncl, long nch)
+/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+ long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+ int **m;
+
+ /* allocate pointers to rows */
+ m=(int **) malloc((size_t)((nrow+NR_END)*sizeof(int*)));
+ if (!m) nrerror("allocation failure 1 in matrix()");
+ m += NR_END;
+ m -= nrl;
+
+
+ /* allocate rows and set pointers to them */
+ m[nrl]=(int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int)));
+ if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+ m[nrl] += NR_END;
+ m[nrl] -= ncl;
+
+ for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+ /* return pointer to array of pointers to rows */
+ return m;
+}
+
+float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
+ long newrl, long newcl)
+/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
+{
+ long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
+ float **m;
+
+ /* allocate array of pointers to rows */
+ m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
+ if (!m) nrerror("allocation failure in submatrix()");
+ m += NR_END;
+ m -= newrl;
+
+ /* set pointers to rows */
+ for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
+
+ /* return pointer to array of pointers to rows */
+ return m;
+}
+
+float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch)
+/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
+declared in the standard C mamer as a[nrow][ncol], where nrow=nrh-nrl+1
+and ncol=nch-ncl+1. The routine should be called vith the address
+&a[0][0] as the first argument. */
+{
+ long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
+ float **m;
+
+ /* allocate pointers to rows */
+ m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
+ if (!m) nrerror("allocation failure in convert_matrix()");
+ m += NR_END;
+ m -= nrl;
+
+ /* set pointers to rovs */
+ m [nrl] =a-ncl;
+ for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
+ /* return pointer to array of pointers to rows */
+ return m;
+}
+
+float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
+/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
+{
+ long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
+ float ***t;
+
+ /* allocate pointers to pointers to rows */
+ t=(float ***) malloc((size_t)((nrow+NR_END)*sizeof(float**)));
+ if (!t) nrerror("allocation failure 1 in f3tensor()");
+ t += NR_END;
+ t -= nrl;
+
+ /* allocate pointers to rows and set pointers to them */
+ t[nrl]=(float **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*)));
+ if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
+ t [nrl] += NR_END;
+ t [nrl] -= ncl;
+
+ /* allocate rows and set pointers to them */
+ t[nrl][ncl]=(float *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float)));
+ if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
+ t[nrl][ncl] += NR_END;
+ t[nrl][ncl] -= ndl;
+
+ for (j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
+ for(i=nrl+1;i<=nrh;i++) {
+ t[i]=t[i-1]+ncol;
+ t[i][ncl]=t[i-1][ncl]+ncol*ndep;
+ for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
+}
+
+ /* return pointer to array of pointers to rows */
+ return t;
+}
+
+void free_vector(float *v, long nl, long nh)
+/* free a float vector allocated with vector() */
+{
+ free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_ivector(int *v, long nl, long nh)
+/* free an int vector allocated with ivector() */
+{
+ free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_cvector(unsigned char *v, long nl, long nh)
+/* free an unsigned char vector allocated with cvector() */
+{
+ free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_lvector(unsigned long *v, long nl, long nh)
+/* free an unsigned long vector allocated vith lvector() */
+{
+ free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_dvector(double *v, long nl, long nh)
+/* free a double vector allocated with dvector() */
+{
+ free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
+/* free a float matrix allocated by matrix() */
+{
+ free((FREE_ARG) (m[nrl]+ncl-NR_END));
+ free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch)
+/* free a double matrix allocated by dmatrix() */
+{
+ free((FREE_ARG) (m[nrl]+ncl-NR_END));
+ free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch)
+/* free an int matrix allocated by imatrix() */
+{
+ free((FREE_ARG) (m[nrl]+ncl-NR_END));
+ free((FREE_ARG) (m+nrl-NR_END));
+}
+void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch)
+/* free a submatrix allocated by submatrix() */
+{
+ free((FREE_ARG) (b+nrl-NR_END));
+}
+
+void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch)
+/* free a matrix allocated by convert_matrix() */
+{
+ free((FREE_ARG) (b+nrl-NR_END));
+}
+
+void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
+ long ndl, long ndh)
+/* free a float f3tensor allocated by f3tensor() */
+{
+ free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
+ free((FREE_ARG) (t[nrl]+ncl-NR_END));
+ free((FREE_ARG) (t+nrl-NR_END));
+}
diff --git a/support/fastpictex/src/nrutil.h b/support/fastpictex/src/nrutil.h
new file mode 100644
index 0000000000..5e1d0deb2d
--- /dev/null
+++ b/support/fastpictex/src/nrutil.h
@@ -0,0 +1,82 @@
+#ifndef _NR_UTILS_H_
+#define _NR_UTILS_H_
+
+static float sqrarg;
+#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
+
+static double dsqrarg;
+#define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
+
+static double dmaxarg1,dmaxarg2;
+#define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
+(dmaxarg1) : (dmaxarg2))
+
+static double dminarg1,dminarg2;
+#define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
+(dminarg1) : (dminarg2))
+
+static float maxarg1,maxarg2;
+#define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
+(maxarg1) : (maxarg2))
+
+static float minarg1,minarg2;
+#define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
+(minarg1) : (minarg2))
+
+static long lmaxarg1,lmaxarg2;
+#define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
+(lmaxarg1) : (lmaxarg2))
+
+static long lminarg1,lminarg2;
+#define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
+(lminarg1) : (lminarg2))
+
+static int imaxarg1,imaxarg2;
+#define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
+(imaxarg1) : (imaxarg2))
+
+static int iminarg1,iminarg2;
+#define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
+(iminarg1) : (iminarg2))
+
+#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
+
+#if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
+
+void nrerror(char error_text[]);
+float *vector(long nl, long nh);
+int *ivector(long nl, long nh);
+unsigned char *cvector(long nl, long nh);
+unsigned long *lvector(long nl, long nh);
+double *dvector(long nl, long nh);
+float **matrix(long nrl, long nrh, long ncl, long nch);
+double **dmatrix(long nrl, long nrh, long ncl, long nch);
+int **imatrix(long nrl, long nrh, long ncl, long nch);
+float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
+ long newrl, long newcl);
+float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch);
+float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
+void free_vector(float *v, long nl, long nh);
+void free_ivector(int *v, long nl, long nh);
+void free_cvector(unsigned char *v, long nl, long nh);
+void free_lvector(unsigned long *v, long nl, long nh);
+void free_dvector(double *v, long nl, long nh);
+void free_matrix(float **m, long nrl, long nrh, long ncl, long nch);
+void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
+void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
+void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch);
+void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch);
+void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
+ long ndl, long ndh);
+
+#else /* ANSI */
+/* traditional - K&R */
+
+void nrerror();
+float *vector();
+/* Rest of traditional declarations are here on the diskette. */
+
+#endif /* ANSI */
+
+#endif /* _NR_UTILS_H_ */
+
diff --git a/support/fastpictex/src/scale.cc b/support/fastpictex/src/scale.cc
new file mode 100644
index 0000000000..11f8eedc94
--- /dev/null
+++ b/support/fastpictex/src/scale.cc
@@ -0,0 +1,66 @@
+/*
+ SUBROUTINE SCALE(FMN, FMX, N, VALMIN, STEP, VALMAX, IFAULT)
+
+ ALGORITHM AS 96 APPL. STATIST. (1976) VOL.25, NO.1
+
+ Given extreme values FMN, FMX, and the need for a scale with N
+ marks, calculates value for the lowest scale mark (VALMIN) and
+ step length (STEP) and highest scale mark (VALMAX).
+*/
+
+#include <math.h>
+
+int scale(float fmn, float fmx, int n, float *valmin, float *step, float *valmax) {
+
+ float unit[12]={0.0, 1.0, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0};
+ int i, j, ifault, nunit=11;;
+ float tol=5.0e-6;
+ float bias=1.0e-4;
+ float fmax, fmin, rn, x, s, range;
+
+ fmax=fmx;
+ fmin=fmn;
+ ifault=1;
+
+ /* Test for valid parameter values */
+ if ((fmax < fmin) || (n <= 1)) return(ifault);
+ ifault=0;
+ rn=(float)(n - 1.0);
+ x=fabs(fmax);
+ if (x == 0.0) x=1.0;
+ if ((fmax-fmin)/x <= tol) {
+ /* All values effectively equal */
+ if (fmax < 0.0) fmax=0.0;
+ else if (fmax == 0.0) fmax=1.0;
+ else fmin=0.0;
+ }
+ *step=(fmax-fmin)/rn;
+ s=*step;
+
+ /* Find power of 10 */
+ while (s<1.0) s*=10.0;
+ while (s>=10.0) s/=10.0;
+
+ /* Calculate STEP */
+ x=s-bias;
+ i=1;
+ while ((i<=nunit) && (x>unit[i])) i++;
+ *step=(*step)*unit[i]/s;
+ range=(*step)*rn;
+
+ /* Make first estimate of VALMIN */
+ x=0.5 * (1.0 +(fmax+fmin-range)/(*step));
+ j=(int)(x-bias);
+ if (x<0.0) j--;
+ *valmin=(*step)*(float)j;
+ /* Test if VALMIN could be zero */
+ if ((fmin >= 0.0) && (range >= fmax)) *valmin=0.0;
+ *valmax=(*valmin)+range;
+
+ /* Test if VALMAX could be zero */
+ if ((fmax > 0.0) || (range < (-1)*fmin)) return(ifault);
+ *valmax=0.0;
+ *valmin=(-1)*range;
+ return(ifault);
+}
+