Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,45 @@
*process source attributes xref;
mat: Proc Options(main);
Dcl a(10) Dec Fixed(8,6);
Dcl s Dec Fixed(10,8);
Dcl n Bin Fixed(31) init(hbound(a)); /* number of items in the list. */
Dcl p Bin Fixed(31) init(3); /* the 1st period */
Dcl q Bin Fixed(31) init(5); /* the 2nd period */
Dcl m Bin Fixed(31);
Call i(a);
Put Edit(' SMA with SMA with',
' number period 3 period 5',
' -------- ---------- ----------')
(Skip,a);
Do m=1 To n;
Put Edit(m,sma(p,m),sma(q,m))(Skip,f(5),2(f(13,6)));
End;
i: Proc(a);
Dcl a(*) Dec Fixed(8,6);
Dcl (j,m) Bin Fixed(31);
Do j=1 To hbound(a)/2;
a(j)=j; /* ··· increasing values. */
End;
Do k=hbound(a)/2 To 1 By -1;
a(j)=k; /* ··· decreasing values. */
j+=1;
End;
End;
sma: Proc(p,j) Returns(Dec Fixed(8,6));
Dcl s Dec fixed(8,6) Init(0);
Dcl i Bin Fixed(31) Init(0);
Dcl j Bin Fixed(31) Init((hbound(a)+1));
Dcl (p,i,k,ka,kb) Bin Fixed(31);
ka=max(1,j-p+1);
kb=j+p;
Do k=ka To kb While(k<=j);
i+=1;
s+=a(k)
End;
s=s/i+0.5e-6;
Return(s);
End;
End;