1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-25 19:46:21 +00:00
Files
Interlisp.maiko/src/lpdual.c
Nick Briggs 5481a14812 Replace all K&R style function definitions with new-style function definitions.
Add some missing default function result types (int).
Add some missing void result types where appropriate.

	modified:   src/Cldeetr.c
	modified:   src/atom.c
	modified:   src/bbtsub.c
	modified:   src/bitblt.c
	modified:   src/byteswap.c
	modified:   src/chardev.c
	modified:   src/chatter.c
	modified:   src/colorbltfns.c
	modified:   src/common.c
	modified:   src/dir.c
	modified:   src/dlpi.c
	modified:   src/doskbd.c
	modified:   src/dosmouse.c
	modified:   src/draw.c
	modified:   src/dsk.c
	modified:   src/dspsubrs.c
	modified:   src/ejlisp.c
	modified:   src/ether.c
	modified:   src/imagefile.c
	modified:   src/imagefile2.c
	modified:   src/inet.c
	modified:   src/initdsp.c
	modified:   src/initkbd.c
	modified:   src/kbdsubrs.c
	modified:   src/ldeboot.c
	modified:   src/llcolor.c
	modified:   src/llstk.c
	modified:   src/loader.c
	modified:   src/loopsops.c
	modified:   src/lpdual.c
	modified:   src/lpmain.c
	modified:   src/lpread.c
	modified:   src/lptran.c
	modified:   src/lpwrite.c
	modified:   src/main.c
	modified:   src/misc7.c
	modified:   src/mkatom.c
	modified:   src/mnwevent.c
	modified:   src/mnxmeth.c
	modified:   src/mouseif.c
	modified:   src/ocr.c
	modified:   src/ocrproc.c
	modified:   src/oether.c
	modified:   src/oldeether.c
	modified:   src/osmsg.c
	modified:   src/picture.c
	modified:   src/rawcolor.c
	modified:   src/rawrs232c.c
	modified:   src/rpc.c
	modified:   src/rs232c.c
	modified:   src/socdvr.c
	modified:   src/socket.c
	modified:   src/testdsp.c
	modified:   src/testtool.c
	modified:   src/timeoday.c
	modified:   src/timeofday.c
	modified:   src/timer.c
	modified:   src/truecolor.c
	modified:   src/tty.c
	modified:   src/ufn.c
	modified:   src/ufs.c
	modified:   src/unixcomm.c
	modified:   src/unixfork.c
	modified:   src/unwind.c
	modified:   src/uraid.c
	modified:   src/vesainit.c
	modified:   src/vgainit.c
	modified:   src/vmemsave.c
	modified:   src/xcursor.c
	modified:   src/xinit.c
	modified:   src/xlspwin.c
	modified:   src/xmkicon.c
	modified:   src/xrdopt.c
	modified:   src/xwinman.c
2017-06-22 17:31:40 -07:00

151 lines
3.6 KiB
C

/* $Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
static char *id = "$Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ Copyright (C) Venue";
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/* The contents of this file are proprietary information */
/* belonging to Venue, and are provided to you under license. */
/* They may not be further distributed or disclosed to third */
/* parties without the specific permission of Venue. */
/* */
/************************************************************************/
#include "version.h"
#include "lpdefs.h"
#include "lpglobl.h"
#ifdef alliant
#pragma global safe(Eta_rownr, Eta_value)
#pragma global assoc
#endif
void rowdual(int *rownr)
{
int i;
double f, g, minrhs;
short artifs;
#ifdef alliant
#pragma safe(Rhs, Upbo, Bas)
#endif
if (Verbose) printf("rowdual\n");
(*rownr) = 0;
minrhs = -EPSB;
i = 0;
artifs = FALSE;
while (i < Rows && !artifs) {
i++;
f = Upbo[Bas[i]];
if (f == 0 && Rhs[i] != 0) {
artifs = TRUE;
(*rownr) = i;
} else {
if (Rhs[i] < f - Rhs[i])
g = Rhs[i];
else
g = f - Rhs[i];
if (g < minrhs) {
minrhs = g;
(*rownr) = i;
}
}
}
} /* rowdual */
short coldual(int *numeta, int *rownr, int *colnr, short *minit, double *prow, double *drow)
{
int i, j, r, varnr;
double theta, quot, pivot, d, f, g;
#ifdef alliant
#pragma safe(Rhs, Upbo, Bas, Cend, Endetacol, prow, drow, Basis, Lower)
#endif
if (Verbose) printf("coldual\n");
if (!(*minit)) {
for (i = 0; i <= Rows; i++) {
prow[i] = 0;
drow[i] = 0;
}
drow[0] = 1;
prow[(*rownr)] = 1;
for (i = (*numeta); i >= 1; i--) {
d = 0;
f = 0;
r = Eta_rownr[Endetacol[i] - 1];
for (j = Endetacol[i - 1]; j < Endetacol[i]; j++) {
/* this is where the program consumes most cpu time */
f = f + prow[Eta_rownr[j]] * Eta_value[j];
d = d + drow[Eta_rownr[j]] * Eta_value[j];
}
if (abs(f) < EPSEL)
prow[r] = 0;
else
prow[r] = f;
if (abs(d) < EPSEL)
drow[r] = 0;
else
drow[r] = d;
}
for (i = 1; i <= Columns; i++) {
varnr = Rows + i;
if (!Basis[varnr]) {
d = -Extrad * drow[0];
f = 0;
for (j = Cend[i - 1]; j < Cend[i]; j++) {
d += drow[Mat[j].rownr] * Mat[j].value;
f += prow[Mat[j].rownr] * Mat[j].value;
}
drow[varnr] = d;
prow[varnr] = f;
}
}
#ifdef alliant
#pragma loop novector
#endif
for (i = 0; i <= Sum; i++) {
if (abs(prow[i]) < EPSEL) prow[i] = 0;
if (abs(drow[i]) < EPSD) drow[i] = 0;
}
}
if (Rhs[(*rownr)] > Upbo[Bas[(*rownr)]])
g = -1;
else
g = 1;
pivot = 0;
(*colnr) = 0;
theta = INFINITE;
for (i = 1; i <= Sum; i++) {
if (Lower[i])
d = prow[i] * g;
else
d = -prow[i] * g;
if (d < 0)
if (!Basis[i])
if (Upbo[i] > 0) {
if (Lower[i])
quot = -drow[i] / (double)d;
else
quot = drow[i] / (double)d;
if (quot < theta) {
theta = quot;
pivot = d;
(*colnr) = i;
} else if (quot == theta)
if (abs(d) > abs(pivot)) {
pivot = d;
(*colnr) = i;
}
}
}
return ((*colnr) > 0);
} /* coldual */