campo-sirio/gfm/predy.c

52 lines
1.0 KiB
C
Raw Normal View History

/* DEC *PredictY(pDst, pSrc)
*
* ARGUMENT
* DEC *pDst, *pSrc;
*
* DESCRIPTION
* Using the previous values of A & B of the least squares line
* Y = A + B * X, calculates the predicted value of Y corresponding to
* a given value of X. pSrc contains X, and the predicted Y is returned
* to pDst. The globals pGMStatA and pGMStatB should already contain
* the values of A and B as computed and stored by LinearEstimate.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* pDst if successful, otherwise GM_NULL.
*
* POSSIBLE ERRORS
* GM_NULLPOINTER
* GM_OVERFLOW
* GM_UNDERFLOW
*
* AUTHOR
* Jared Levy
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
DEC *PredictY(pDst, pSrc)
DEC *pDst, *pSrc;
{
DEC dTemp, *pTemp=&dTemp;
_MacStart(GM_PREDY);
_MacInVarD(pSrc);
_MacOutVarD(pDst);
if (!MultiplyDecimal(pTemp, pSrc, pGMStatB))
_MacRet(GM_NULL);
pDst = AddDecimal(pDst, pTemp, pGMStatA);
_MacRet(pDst);
}