VAR M%=63 DIM X#[M%+1],B#[M%+1] VAR Y#=0 VAR K%=0,J% VAR W%=400,H%=240 '画面サイズ
FILL B#,1.0/64
WHILE 1 WAIT 1 'ボタンの入力 IF 16==(BUTTON() AND 16) THEN X#[K%]=255 ELSE X#[K%]=0 ENDIF 'フィルタの計算 Y#=0 FOR J%=0 TO M% Y#=Y#+X#[(K%-J%+M%)MOD M%]*B#[J%] NEXT J% '描画 GFILL 0,0,W%,H%,RGB(ROUND(Y#),ROUND(Y#),ROUND(Y#)) K%=K%+1 IF K%>M% THEN K%=0 WEND
def bairstow(double a[],double ro[],double jo[],int n) var cnt%=0,i,j var d# fill bair1,0:fill bair2,0 var a0#=a[0] aryop 3,a,a,a0% while n>3 var p#,q# var dp#=1,dq#=1 p#=q#=0 while abs(dp#)>1e-10||abs(dq#)>1e-10 bair1[0]=a[0] bair1[1]=a[1]-p#*a[0] bair2[0]=bair1[0] bair2[1]=bair1[1]-p#*bair1[0] for j=2 to n-1 bair1[j]=a[j]-p#*bair1[j-1]-q#*bair1[j-2] bair2[j]=bair1[j]-p#*bair2[j-1]-q#*bair2[j-2] next j var r#=bair2[n-3]*bair2[n-3]-(bair2[n-2]-bair1[n-2])*bair2[n-4] dp#=(bair1[n-2]*bair2[n-3]-bair1[n-1]*bair2[n-4])/r# dq#=(-bair1[n-2]*(bair2[n-2]-bair1[n-2])+bair1[n-1]*bair2[n-3])/r# p#+=dp# q#+=dq# wend d#=p#*p#-4*q# if d#>0 then ro[cnt%]=(-p#+sqr(d#))/2 ro[cnt%+1]=(-p#-sqr(d#))/2 jo[cnt%]=jo[cnt%+1]=0 cnt%=cnt%+2 else ro[cnt%]=-p#/2 jo[cnt%]=sqr(-d#)/2 cnt%=cnt%+1 endif for i=0 to n-1 a[i]=b[i] next i n=n-2 wend if 3==n then d#=a[1]*a[1]-4*a[2] if d>0 then ro[cnt%]=(-a[1]+sqr(d#))/2 ro[cnt%+1]=(-a[1]-sqr(d#))/2 jo[cnt%]=jo[cnt%+1]=0 cnt%=cnt%+2 else ro[cnt%]=-a[1]/2 jo[cnt%]=sqr(-d#)/2 cnt%=cnt%+1 endif else ro[cnt%]=-a[1] jo[cnt%]=0 cnt%=cnt%+1 endif return cnt% end