1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
20 |
|
|
21 |
|
#include <errno.h> |
22 |
|
|
23 |
+ |
#include <math.h> |
24 |
+ |
|
25 |
|
#include "calcomp.h" |
26 |
|
|
27 |
|
/* bits in argument flag (better be right!) */ |
155 |
|
int assign; |
156 |
|
double (*fptr)(); |
157 |
|
{ |
158 |
+ |
int oldlibsize = libsize; |
159 |
|
register LIBR *lp; |
160 |
|
|
161 |
|
if ((lp = liblookup(fname)) == NULL) { /* insert */ |
188 |
|
lp[0].atyp = assign; |
189 |
|
lp[0].f = fptr; |
190 |
|
} |
191 |
< |
libupdate(fname); /* relink library */ |
191 |
> |
if (libsize != oldlibsize) |
192 |
> |
libupdate(fname); /* relink library */ |
193 |
|
} |
194 |
|
|
195 |
|
|
473 |
|
static double |
474 |
|
l_rand() /* random function between 0 and 1 */ |
475 |
|
{ |
472 |
– |
extern double floor(); |
476 |
|
double x; |
477 |
|
|
478 |
|
x = argument(1); |
486 |
|
static double |
487 |
|
l_floor() /* return largest integer not greater than arg1 */ |
488 |
|
{ |
486 |
– |
extern double floor(); |
487 |
– |
|
489 |
|
return(floor(argument(1))); |
490 |
|
} |
491 |
|
|
493 |
|
static double |
494 |
|
l_ceil() /* return smallest integer not less than arg1 */ |
495 |
|
{ |
495 |
– |
extern double ceil(); |
496 |
– |
|
496 |
|
return(ceil(argument(1))); |
497 |
|
} |
498 |
|
|
501 |
|
static double |
502 |
|
l_sqrt() |
503 |
|
{ |
505 |
– |
extern double sqrt(); |
506 |
– |
|
504 |
|
return(sqrt(argument(1))); |
505 |
|
} |
506 |
|
|
508 |
|
static double |
509 |
|
l_sin() |
510 |
|
{ |
514 |
– |
extern double sin(); |
515 |
– |
|
511 |
|
return(sin(argument(1))); |
512 |
|
} |
513 |
|
|
515 |
|
static double |
516 |
|
l_cos() |
517 |
|
{ |
523 |
– |
extern double cos(); |
524 |
– |
|
518 |
|
return(cos(argument(1))); |
519 |
|
} |
520 |
|
|
522 |
|
static double |
523 |
|
l_tan() |
524 |
|
{ |
532 |
– |
extern double tan(); |
533 |
– |
|
525 |
|
return(tan(argument(1))); |
526 |
|
} |
527 |
|
|
529 |
|
static double |
530 |
|
l_asin() |
531 |
|
{ |
541 |
– |
extern double asin(); |
542 |
– |
|
532 |
|
return(asin(argument(1))); |
533 |
|
} |
534 |
|
|
536 |
|
static double |
537 |
|
l_acos() |
538 |
|
{ |
550 |
– |
extern double acos(); |
551 |
– |
|
539 |
|
return(acos(argument(1))); |
540 |
|
} |
541 |
|
|
543 |
|
static double |
544 |
|
l_atan() |
545 |
|
{ |
559 |
– |
extern double atan(); |
560 |
– |
|
546 |
|
return(atan(argument(1))); |
547 |
|
} |
548 |
|
|
550 |
|
static double |
551 |
|
l_atan2() |
552 |
|
{ |
568 |
– |
extern double atan2(); |
569 |
– |
|
553 |
|
return(atan2(argument(1), argument(2))); |
554 |
|
} |
555 |
|
|
557 |
|
static double |
558 |
|
l_exp() |
559 |
|
{ |
577 |
– |
extern double exp(); |
578 |
– |
|
560 |
|
return(exp(argument(1))); |
561 |
|
} |
562 |
|
|
564 |
|
static double |
565 |
|
l_log() |
566 |
|
{ |
586 |
– |
extern double log(); |
587 |
– |
|
567 |
|
return(log(argument(1))); |
568 |
|
} |
569 |
|
|
571 |
|
static double |
572 |
|
l_log10() |
573 |
|
{ |
595 |
– |
extern double log10(); |
596 |
– |
|
574 |
|
return(log10(argument(1))); |
575 |
|
} |
576 |
|
#endif |