**********************************************************************/
/* SPALIB.C */
/* SUBPROGRAMS IN ALPHABETICAL ORDER */
/* IN THE C PROGRAMMING LANGUAGE */
/* */
/**********************************************************************/
/* NOTE: The user may wish to include the following in other programs */
/* .................Begin include file.................*/
/* Latest date: 06/23/92 */
#include
/* In the VMS compiler, M_PI is not defined in math.h */
#ifdef vms
#define M_PI 3.14159265358979323846
#endif
#ifndef KR
#define M_PI 3.14159265358979323846
#endif
#define FALSE 0
#define TRUE 1
#define BIG 1e10
#define SMALL 1e-10
#define ORDER5 1e-5
#define ORDER4 1e-4
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define MAX(a,b) ((a) >= (b) ? (a) : (b))
/* Table of constant values */
static long neg_i1 = -1;
static long pos_i1 = 1;
static long pos_i2 = 2;
static long pos_i4 = 4;
static long pos_i5 = 5;
static float neg_f1 = -1.0;
static float pos_f2 = 2.0;
static double pos_d10 = 10.0;
typedef struct {
float r, i;
} complex;
typedef struct {
double r, i;
} doublecomplex;
/* .................End of include file.................*/
/* SPBFCT 11/14/85 */
/* GENERATES (I1)!/(I1-I2)!=I1*(I1-1)*...*(I1-I2+1). */
/* NOTE: 0!=1 AND SPBFCT(I,I)=SPBFCT(I,I-1)=I!. */
#ifndef KR
double spbfct(long *i1, long *i2)
#else
double spbfct(i1, i2)
long *i1, *i2;
#endif
{
/* Local variables */
long i;
double ret_val;
ret_val = 0.0;
if (*i1 < 0 || *i2 < 0 || *i2 > *i1)
{
return(ret_val);
}
ret_val = 1.0;
for (i = *i1 ; i >= (*i1 - *i2 + 1) ; --i)
{
ret_val *= (double) i;
}
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部1条评论
快来发表一下你的评论吧 !