Created
July 30, 2012 20:03
-
-
Save b-adams/3209694 to your computer and use it in GitHub Desktop.
CS225 Day 17 Notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
digraph all_downhill | |
{ | |
start [shape="oval" label="Start"]; | |
start->broke; | |
noprob [label="No Problem." shape="oval"]; | |
broke [shape="diamond" label="Is it broke?"]; | |
broke->nomess [label="no" color="red"]; | |
broke->didmess [label="yes" color="green"]; | |
didmess [shape="diamond" label="Did you mess with it?"]; | |
didmess->trouble [label="no" color="red"]; | |
didmess->id10t [label="yes" color="green"]; | |
trouble [label="Will it get you in trouble?" shape="diamond"]; | |
trouble->slob [label="yes" color="green"]; | |
trouble->ignore [label="no" color="red"]; | |
known [shape="diamond" label="Does anyone know?"]; | |
known->slob [label="yes" color="green"]; | |
known->hide [label="no" color="red"]; | |
blame [label="Can you blame someone else?" shape="diamond"]; | |
blame->slob [label="no" color="red"]; | |
blame->noprob [label="yes" color="green"]; | |
nomess [shape="rectangle" label="Don't mess with it."]; | |
nomess->noprob; | |
ignore [label="Ignore it." shape="rectangle"]; | |
ignore->noprob; | |
id10t [shape="rectangle" label="You idiot"]; | |
id10t->known; | |
hide [label="Hide it." shape="rectangle"]; | |
hide->noprob; | |
slob [label="You poor slob." shape="rectangle"]; | |
slob->blame; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A ALG HORNARTERGENER | |
COMPILED BY CASE 1107 ALGOL 60 (FAST VERSION) DATEO O.CTOBER 1, 1967 | |
THIS COMPILATION WAS DONE ON 27 OCT 67 AT 16:01:07 | |
1 COMMENT: THIS_PROGRAM CALCULATES THE HORNFUNCTION U(Z),LOG DERIVATIVE | |
2 O(Z) ANn DERIVATIVE DUDZ OF A HORN WITH THE FUNCTION OF ITS GEOMETRY | |
3 RG(X), FIRST, SECOND AND THIRD DERIVATIVE KNOWN. SPHERICAL WAVES $ | |
4 STRING W(40) $ INTEGER N,I $ | |
5 REAL B,ALPHA,X,RG,H,Z,Z0,Z1,RR,DHDX,D2HDX,DRDX,D2RDX,D,DZDX, | |
6 D2ZDX,T1,T2,U,U1,U0,DUDZ,DRDZ,D2RDZ,BO,B1,B2,T3,T4,T5, | |
7 DGDX,D2GDX,D3GDX,F $ | |
8 FORMAT F1('CALCULATED VALUES OF THE HORNPARAMETERS',A9.1) $ | |
9 FORMAT F2(X1O,'I=',I1 ,X2,'B=',D7.4,X2,'ALPHA=',D6.4,X2,'Bl=',D7.4,X2, | |
10 'B2=',07.4,X2,S40,A1.1) $ | |
11 FORMAT F3(X13,'X',X12,'RG',Xll,'Z',X12,'RR',Xll,'D',X12,'U',X12, | |
12 'DUDZ',X4,'FREQ HZ',A1.1) $ | |
13 FORMAT F4(X10,D7.4,X6,D10.6,X3,D9.6,X4,D11.7,X2,D11.7,X2,D10.7, | |
14 X3,D11.7,X4,D7.2,A1.0) $ | |
15 FORMAT F5(El) $ | |
16 FORMAT F6(X10,D7.4,X6,D10.6,X3,D9.6,X4,D11.7,X2,D11,7,X2,D10.7, | |
17 X14 ,X4,D7.2,A1.o) $ | |
18 START: READ (I,B,ALPHA,B1,B2,W) $ | |
19 BEGIN IF I EQL 9 THEN GO TO HURRA $ | |
20 WRITE (F5) $ | |
21 WRITE (Fl) $ WRITE (F2,I,B,ALPHA,R1,B2,W) $ | |
22 WRITE (F3) $ | |
23 X = 26 $ | |
24 BORJA: N=0$ | |
25 FORTS: TF X LSS 10 THEN GO TO HAR $ X=X-1 $ GO TO JA $ | |
26 HAR: X= X- 0.2 $ | |
27 IF X LSS 0.1 THEN GO TO SLUT$ | |
28 JA: | |
29 IF I GTR 1 THEN GO TO HEJ2 $ | |
3O RG= B/(X**ALPHA) $ | |
31 DGDX = - 8*ALPHA/(X**(ALPHA + 1)) $ | |
32 D2GDX = R*ALPHA*(ALPHA + 1)/(X**(ALPHA+2)) $ | |
33 D3GDX=-R*ALPHA*(ALPHA+1)*(ALPHA+2)/(X**(ALPHA+3)) $ | |
34 GO TO GODDA $ | |
35 HEJ2: IF I GTR 2 THEN GO TO HEJ3 $ | |
36 RG= R*EXP( -ALPHA*X) $ | |
37 DGDX =-RG*ALPHA $ D2GDX = RG*(ALPHA**2) $ D3GDX =-RG*(ALPHA**3) $ | |
38 GO TO GODDA $ | |
39 HEJ3: IF I GTR 3 THEN GO TO HEJ4 $ | |
40 RG = B/(1 - EXP( -ALPHA*(X-B1))) $ | |
41 DGDX = -(RG**2)*ALPHA*EXP(-ALPHA*(X-B1))/B $ | |
42 D2GDX = DGDX*(2*DGDX/RG - ALPHA ) $ | |
43 D3GDX =D2GDX*(2*DGDX/RG-ALPHA )+DGDX*(2*D2GDX/RG-2*(DGDX/RG)**2 ) % | |
44 GO TO GODDA $ | |
45 HEJ4: | |
46 GODDA: | |
47 IF DGDX EQL 0 THEN GO TO BORJA $ | |
48 T3= RG/DGDX $ | |
49 T4= 1 - T3*(D2GDX/DGDX) $ | |
50 T5= -T4*(D2GDX/DGDX) - T3*((D3GDX/DGDX) - (D2GDX/DGDX)**2) $ | |
51 H= SQRT(RG**2 + T3**2) $ | |
52 Z = X - T3 - H $ | |
53 RR= SQRT(2*H*(X - Z)) $ | |
54 DHDX= (RG*DGDX + T3*T4)/H $ | |
55 D2HDX=(DGDX**2 + RG*D2GDX + T4**2 + T3*T5 - DHDX**2)/H $ | |
56 DZDX =1 - T4 - DHDX $ | |
57 IF DZDX EQL 0 THEN GO TO BORJA $ | |
58 D2ZDX = -T5 - D2HDX $ | |
59 DRDX= (DHDX*(X - Z) + H*(1 - DZDX))/RR $ . | |
60 D2RDX = (D2HDX*(X-Z) + 2*DHDX*(1-DZDX) - H*D2ZDX - (DRDX)**2)/RR $ | |
61 DRDZ=(DRDX)/(DZDX)$ D=(DRDZ)/(RR)$ | |
62 D2RDZ= (D2RDX - DRDZ*D2ZDX)/(DZDX**2) $ | |
63 U= (D2RDZ)/( RR ) $ | |
64 F = SQRT(U)/ 0.00018075 $ | |
65 IF N EQL 0 THEN GO TO HORN0 ELSE GO TO HORN1$ | |
66 HORN0: U0=U$ Z0=Z$ DUDZ=999$ | |
67 WRITE (F6,X,RG,Z,RR,D,U, F ) $ | |
68 N=N+1$ GO TO FORTS$ | |
69 HORN1 : U1=U$ Z1=Z$ ,DUDZ=(U0-U1)/(Z0-Z1) $ | |
70 WRITE ( F4,X,RG,Z,RR,D,U,DUDZ,F ) $ | |
71 GO TO BORJA $ | |
72 SLUT: | |
73 GO TO START $ | |
74 HURRA : END $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;Program A to see if number is even or odd | |
; | |
num: .EQUATE 0 ;variable #2d | |
frame: .EQUATE 2 ;2-byte frame | |
main: SUBSP frame,i ;allocate #num | |
DECI num,s ;input number | |
LDA num,s ;toss in accumulator | |
DECO num,s ;preliminary output | |
STRO spacer,d | |
;Calculate Condition If C = 1, number is odd, If C = 0, number is even. | |
ASRA ;shifts right, whichstores "1-bit" in C: AFFECTS C FLAG | |
;time to think about branching | |
BRC ODD ;IF C= 1, branch; otherwise proceed to next instruction | |
; if not odd | |
CHARO 'E',i ;output even marker | |
BR IFEND ;unconditional jump over else | |
; if odd (branched on flag) | |
ODD: CHARO 'O',i ;output odd marker | |
;all done with branching business | |
IFEND: CHARO linef,i ; | |
ADDSP frame,i ;deallocate #num | |
STOP ; | |
linef: .EQUATE 0x000A ; | |
spacer: .ASCII ": \x00" | |
.END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;ProgramB to do error check on signed computation | |
num1: .EQUATE 0 ;local variable #2d | |
num2: .EQUATE 2 ;local variable #2d | |
sum: .EQUATE 4 ;local variable #2d | |
frame: .EQUATE 6 | |
linef: .EQUATE 0x000A ; | |
; | |
SUBSP frame,i ;allocate #sum #num2 #num1 | |
main: DECI num1,s ;Get inputs | |
DECI num2,s ; | |
DECO num1,s ;Echo inputs | |
CHARO '+',i | |
DECO num2,s ; | |
CHARO '=',i | |
LDA num1,s ; | |
ADDA num2,s ; adds num2 to num1, stores in A AFFECTS V FLAG | |
BRV error ; IF overflow, do error message | |
; if not error process sum | |
STRO ismsg,d | |
BR IFEND ; jump over else | |
; if error | |
error: STRO notmsg,d | |
IFEND: STA sum,s ;stuff that happens regardless | |
DECO sum,s ; | |
CHARO linef,i ; | |
ADDSP frame,i ;deallocate #num1 #num2 #sum | |
STOP ; | |
notmsg: .ASCII "NOT\x00" | |
ismsg: .ASCII "(for real!)\x00" | |
.END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment