Use va_args in cosadd/sinadd (Michael Teichgräber)

This commit is contained in:
rsc 2006-05-27 18:35:26 +00:00
parent dfbaaaa650
commit 2ad582ee88
2 changed files with 19 additions and 9 deletions

View file

@ -152,7 +152,7 @@ extern void args(int, char**);
extern void bdtsetup(double, Tim*);
extern double betcross(double);
extern double convdate(Tim*);
extern double cosadd(int, double, ...);
extern double cosadd(int, ...);
extern double cosx(double, int, int, int, int, double);
extern double dist(Obj1*, Obj1*);
extern double dsrc(double, Tim*, int);
@ -201,7 +201,7 @@ extern void setime(double);
extern void setobj(Obj1*);
extern void setpt(Occ*, double);
extern void shad(void);
extern double sinadd(int, double, ...);
extern double sinadd(int, ...);
extern double sinx(double, int, int, int, int, double);
extern char* skip(int);
extern double solstice(int);

View file

@ -10,15 +10,20 @@ icosadd(double *fp, char *cp)
}
double
cosadd(int n, double coef, ...)
cosadd(int n, ...)
{
double *coefp;
double *coefp, coef[10];
char *cp;
int i;
double sum, a1, a2;
va_list arg;
sum = 0;
cp = cacp;
va_start(arg, n);
for(i=0; i<n; i++)
coef[i] = va_arg(arg, double);
va_end(arg);
loop:
a1 = *cafp++;
@ -28,7 +33,7 @@ loop:
}
a2 = *cafp++;
i = n;
coefp = &coef;
coefp = coef;
do
a2 += *cp++ * *coefp++;
while(--i);
@ -37,15 +42,20 @@ loop:
}
double
sinadd(int n, double coef, ...)
sinadd(int n, ...)
{
double *coefp;
double *coefp, coef[10];
char *cp;
int i;
double sum, a1, a2;
va_list arg;
sum = 0;
cp = cacp;
va_start(arg, n);
for(i=0; i<n; i++)
coef[i] = va_arg(arg, double);
va_end(arg);
loop:
a1 = *cafp++;
@ -55,7 +65,7 @@ loop:
}
a2 = *cafp++;
i = n;
coefp = &coef;
coefp = coef;
do
a2 += *cp++ * *coefp++;
while(--i);