campo-sirio/gfm/dcoss.c
alex ba237a9d91 Patch level : no patch
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll)


git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
2002-02-26 12:19:02 +00:00

57 lines
1.0 KiB
C
Executable File

/* void _CosDecSmall(pDst,pSrc)
*
* ARGUMENT
* DEC *pDst, *pSrc;
*
* DESCRIPTION
* Sets pDst = cos(pSrc), where 0 <= pSrc < pi / 4.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* None.
*
* ALGORITHM
* Using the Taylor series,
* cos(x) = 1 - x^2/2! + x^4/4! - ...
*
* AUTHOR
* Jared Levy April 7, 1987
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
void _CosDecSmall(pDst,pSrc)
DEC *pDst, *pSrc;
{
DEC *srcsq, dsrcsq, *term, dterm, *fact, dfact;
SHORT i;
srcsq = &dsrcsq;
(void) _MulDec80Bit(srcsq, pSrc, pSrc);
(void) ConvLongToDecimal(pDst, 1L);
term = &dterm;
(void) _MulDec80Bit(term, srcsq, &decPoint5);
i = 2;
fact = ConvLongToDecimal(&dfact, 6L);
while (!(_MacIsDecZ(term))) {
if ((i % 4) == 0)
(void) _AddDec80Bit(pDst, pDst, term);
else
(void) _SubDec80Bit(pDst, pDst, term);
i+=2;
_MulDec80Bit(term, term, srcsq);
fact->dc.sl[0] = i * (i - 1);
_DivRndDec80Bit(term, term, fact, 23);
}
}