%!ps % Demo Legrange and friends % ======= % Author and date % Function % Details % ====== % Postscript demo to explore "best" order 3 filter. % ======= % Uncomment and modify to use disk based Gonzo. ( or other disk access ) (C:/Users/Don/Desktop/Ghost/gonzo.psl) run % use internal /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def guru % activate gonzo utilities % ============================== /makelogvalues { /logvalues [ 0.1 {dup 1.01 mul dup 10 ge {exit} if } loop ] store} store makelogvalues /comps [ 1 1 1 1 1 1 ] store /getvalues { comps 0 get /C1 exch store comps 1 get /C2 exch store comps 2 get /C3 exch store comps 3 get /R1 exch store comps 4 get /R2 exch store comps 5 get /R3 exch store } store /funct { /num { 1 C1 C2 mul C3 mul R1 mul R2 mul R3 mul div } store /s0 num store /s3 fq fq mul fq mul store /s1 1 C1 C2 mul R1 mul R2 mul div 1 C1 C2 mul R1 mul R3 mul div add 1 C1 C2 mul R2 mul R3 mul div add 1 C2 C3 mul R2 mul R3 mul div add fq mul store /s2 1 C2 R2 mul div 1 C2 R3 mul div add 1 C1 R2 mul div add 1 C1 R1 mul div add fq dup mul mul store s0 s2 sub dup mul s1 s3 sub dup mul add sqrt num exch div } store /plot { getvalues 0 1 logvalues length 1 sub {logvalues exch get /fq exch store funct drawit % log 20 mul == } for } store /drawit { fq fadj mul log 1 add 22.5 mul exch log 20 mul 48 mul 60 div 48 add mt dot } store % logvalues == % logvalues length == % logvalues { 10 mul log == } forall %%%%%%%%%%%%%%%%%%% 80 200 10 setgrid 0 0 mt 48 2.667 add pu 45 pr 48 2.667 add pd closepath gsave 0.9 1 0.9 setrgbcolor fill grestore 0.4 1 0.4 setrgbcolor line3 stroke line1 [{0 0 mt 45 r} 8 7] yrpt .2 log 1 add 22.5 mul 0 mt 50.667 u .3 log 1 add 22.5 mul 0 mt 50.667 u .4 log 1 add 22.5 mul 0 mt 50.667 u .5 log 1 add 22.5 mul 0 mt 50.667 u .6 log 1 add 22.5 mul 0 mt 50.667 u .7 log 1 add 22.5 mul 0 mt 50.667 u .8 log 1 add 22.5 mul 0 mt 50.667 u .9 log 1 add 22.5 mul 0 mt 50.667 u 1 log 1 add 22.5 mul 0 mt 50.667 u 2 log 1 add 22.5 mul 0 mt 50.667 u 3 log 1 add 22.5 mul 0 mt 50.667 u 4 log 1 add 22.5 mul 0 mt 50.667 u 5 log 1 add 22.5 mul 0 mt 50.667 u 6 log 1 add 22.5 mul 0 mt 50.667 u 7 log 1 add 22.5 mul 0 mt 50.667 u 8 log 1 add 22.5 mul 0 mt 50.667 u 9 log 1 add 22.5 mul 0 mt 50.667 u /group [ [ 1 1 1 1 1 1 ] [ 2 0.5 1 1 1 1 ] [ 2 0.5 1 2 0.5 1 ] [ 2 0.5 1 2 1 0.5 ] [ 2 0.5 1 1 2 0.5 ] [ 2 0.5 1 1 0.5 2 ] [ 2 0.5 1 0.5 2 1 ] [ 2 0.5 1 2 0.5 1 ] [ 2 1 0.5 1 1 1 ] [1 2 0.5 1 1 1 ] [ 1 0.5 2 1 1 1 ] [ 0.5 2 1 1 1 1] [ 2 0.5 1 1 1 1] ] store { group {/comps exch store comps == plot} forall } pop % start with butterworth /s0 1 store /s1 2 store /s2 2 store /s3 1 store /funcpoly { s0 s2 fq dup mul mul sub dup mul s1 fq mul s3 fq dup mul fq mul mul sub dup mul add sqrt 1 exch div } store %%%%%%%%%%%% /findadj { /fadj 1 store 0 1 logvalues length 1 sub {logvalues exch get /fq exch store funcpoly dup fq == 0.707 lt { /fadj 1 fq div store exit } if } for (\nfadj is now -----------> )print fadj == } store %%%%%%%%%%%%%% /plotpoly { getvalues /setadj false store 0 1 logvalues length 1 sub {logvalues exch get /fq exch store funcpoly dup == drawit } for } store 1 0 0 setrgbcolor /fadj 1.0 store /shift true store { save /ssnap exch store shift {0 -50 translate} if % 1.5 0.25 2.5 {/s1 exch store 1.5 0.25 2.5 {/s2 exch store % -1 0.25 3 {/s1 exch store -1 0.25 3 {/s2 exch store % 1.5 0.125 2.75 {/s1 exch store shift { 0 5 translate } if 1 0.25 pop 0.100 2.75{/s2 exch store -3 0.5 3 {/s1 exch store shift { 0 5 translate } if -3 0.5 3{/s2 exch store findadj plotpoly shift {0 0.8 pop 0 translate} if } for } for ssnap restore } pop % spaced save /ssnap1 exch store % 0.5 dup scale % 0 10 translate 0 0 1 setrgbcolor /shift false pop true pop false store shift {0 -30 translate} if % 1.5 0.25 2.5 {/s1 exch store 1.5 0.25 2.5 {/s2 exch store % -1 0.25 3 {/s1 exch store -1 0.25 3 {/s2 exch store % 1.5 0.125 2.75 {/s1 exch store shift { 0 2 translate } if 1.5 0.25 2.75 {/s2 exch store 1.5 0.2 2.5 {/s1 exch store shift { 0 3 translate } if 1.5 0.2 2.5 {/s2 exch store % 1.85 0.2 2.15 {/s1 exch store shift { 0 3 translate } if 1.85 0.2 2.15 {/s2 exch store findadj plotpoly shift {0 1 translate} if } for } for ssnap1 restore % butterworth 0.7 0.7 0 setrgbcolor /s1 2 store /s2 2 store findadj plotpoly showpage %EOF