source: WorldVistAEHR/trunk/r/ONCOLOGY-ONC/ONCOSCOM.m@ 1787

Last change on this file since 1787 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 1.8 KB
RevLine 
[613]1ONCOSCOM ;WASH ISC/SRR-COMPUTATIONAL SUBROUTINES ;4/16/92 18:25
2 ;;2.11;ONCOLOGY;;Mar 07, 1995
3 ;This module contains entry points for the following computations:
4 ; EXP - compute the exponential
5 ; LOG10 - compute log to base 10
6 ; LOG2 - compute log to base 2
7 ; SQ - compute the square root
8 ;
9 ;
10EXP ;compute the exponential EXP(X)
11 ;in: X = argument must be less than 55.26
12 ;out: Y = EXP(X)
13 ; Z = 1 for any problem in evaluations, 0 otherwise
14 N F,I,LE,LZ,S
15 S LE=.434294482,LZ=X,X=LE*X
16 S Z=0,S=0 I X=0 S Y=1 G QEXP
17 I +X'=X S Z=1 G QEXP
18 I X<0 S S=1,X=-X
19 S F=X#1,I=X\1,I="1E"_$E("-",S&I)_I
20 S Y=.00093264267*F+0.00255491796*F+0.01742111988*F+0.07295173666*F+0.25439357484*F+0.66273088429*F+1.15129277603*F+1
21 S Y=Y*Y
22QEXP S:S Y=1/Y S Y=+$J(Y+0.000000005,0,8),Y=Y*I,X=LZ
23 Q
24 ;
25LOGE ;compute log to base E
26 ;arguments same as LOG10
27 D LOG2 I 'Z S Y=+$J(Y/1.44269504,0,8)
28 Q
29 ;
30LOG10 ;compute log to base 10
31 ;in: X = argument
32 ;out: Y = LOG10(X)
33 ; Z = 1 if Y not evaluated, 0 otherwise
34 D LOG2 I 'Z S Y=+$J(Y/3.321928096,0,8)
35 Q
36 ;
37LOG2 ;compute log to base 2
38 ;arguments are as above
39 N LU,LV,LZ
40 I X'>0!(+X'=X) S Z=1 Q
41 S LZ=$L($P(X,".",1))
42 I LZ S X="."_$E(X,1,LZ)_$E(X,LZ+2,255),X=+X
43 E F LZ=LZ:-1 Q:X'<.1 S X=X*10
44 F Y=0:1:3 Q:X'<.5 S X=X*2
45 S LU=X-.707106781/(X+.707106781),LV=LU*LU
46 S LU=.434259751292*LV+.576584342056*LV+.961800762286*LV+2.885390072738*LU
47 S Y=+$J(LZ*3.321928096+LU-Y-.5,0,8),Z=0
48 Q
49 ;
50SQ ;compute square root
51 ;in: X = argument for square root
52 ;out: Y = sq root of X if X'<0, of -X if X<0
53 ; Z = 1 if X<0, 0 otherwise
54 S Z=(X<0) I X=0 S Y=0 Q
55 I Z S X=-X
56 I X>1 S Y=X\1
57 E S Y=1/X
58 S Y=$E(Y,1,$L(Y)+1\2)
59 E S Y=1/Y
60 F %=1:1:6 S Y=X/Y+Y*.5
61 Q
62 ;
63TEST ;test LOGE & EXP
64 N I
65 F I=1:1:20 W !,I,?10 S X=I*1.33333 W X D LOGE W ?25,Y S X=Y D EXP W ?40,Y,?60,Z
66 Q
Note: See TracBrowser for help on using the repository browser.