source: WorldVistAEHR/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSESLOG.m@ 972

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

initial load of WorldVistAEHR

File size: 1.5 KB
Line 
1YSESLOG ;SLC/DCM-UTILITY ROUTINE TO CALCULATE LOGARITHMS TO BASE e OR BASE 10 ; 10/18/88 16:54 ;
2 ;;5.01;MENTAL HEALTH;;Dec 30, 1994
3 ;DECISION EXPERT SYSTEM (VERSION 1.0) FOR MENTAL HEALTH PACKAGE - DWIGHT MCDANIEL / REGION 5 ISC, SLC
4 ;PASS NUMBER TO A5AESLOG IN VARIABLE ESLN; LOGARIGHM OF NUMBER RETURNED AS ESY
5 ;DECIMAL ACCURACY IS 8 DECIMAL DIGITS
6CALC S ESLU=ESL1-.707106781187/(ESL1+.70710681187),ESLV=ESLU*ESLU
7 S ESLU=.434259751292*ESLV+.576584342056*ESLV+.961800762286*ESLV+2.885390072738*ESLU
8 Q
9EXIT S ESLS=0 S:ESY<0 ESLS=1,ESY=-ESY S ESY=$E(ESY+.000000005,1,ESY["."+8),ESY=$E("-",ESLS)_ESY D CONV:ESE S:$E(ESY,$L(ESY))["0" ESY=$E(ESY,1,$L(ESY)-1)
10EXIT1 K ESLI,ESL1,ESLS,ESLU,ESLV,ESLZ Q
11CONV I ESY>10 F ESLI=0:1 Q:ESY<10 S ESY=ESY/10
12 I ESY<1 F ESLI=0:-1 Q:ESY>1 S ESY=ESY*10
13 S ESY=$E("-",ESLS)_ESY_"E"_ESLI Q
14 ;
15LOG ; Called by routine YSEUT
16 D TEST G EXIT1:ESAB I ESLN=1 S (ESY,ESAB)=0 G EXIT1
17 D SCALE,CALC S ESY=ESY+ESLU/3.321928096+ESLZ G EXIT
18 ;
19LN ; Called by routine YSEUT
20 D TEST G EXIT1:ESAB I ESLN=1 S (ESY,ESAB)=0 G EXIT1
21 D SCALE,CALC S ESY=ESLZ*3.321928094887+ESY+ESLU/1.442695040889 G EXIT ;1.442695040889=1/Ln(2) 3.32192809489=Ln(10)/Ln(2)
22TEST S ESAB=1 Q:'$D(ESLN) S:'$D(ESE) ESE=0 Q:'(ESLN?1N.N!(ESLN?1N.N1"."1N.N)!(ESLN?1"."1N.N))
23 Q:ESLN>1E24!(ESLN=0) S ESAB=0 Q
24SCALE S ESLI=ESLN\1,ESL1=$E(ESLN#1,2,40) ;LI=INT,L1=FRACT PARTS OF LN
25 S:ESLI=0 ESLI="" S ESLZ=$L(ESLI) S:ESL1=0 ESL1="" S ESL1=ESLI_ESL1
26 F ESY=1:1 Q:$E(ESL1)>0 S ESLZ=ESLZ-1,ESL1=$E(ESL1,2,40)
27 F ESY=0:1:3 Q:$E(ESL1)>4 S ESL1=ESL1*2
28 S ESL1="."_ESL1,ESY=-.5-ESY
29 Q
Note: See TracBrowser for help on using the repository browser.