rem Convolution/Deconvolution dim a(100) dim b(100) dim c(100) dim t(3) for x=1 to 3 t(x)=0 next x cls print print "Convolution/Deconvolution" print print "All curves must have the same number of data points." input "Number of points to input? ";n [aleap] print print "0= End" print "1= Enter Curve A Data" print "2= Enter Curve B Data" print "3= Enter Curve C Data" print "4= Convolution: C=A*B" print "5= Deconvolution: A=C/B" print "6= Deconvolution: B=C/A" print input " => ";q if q=0 then end if q>0 and q<4 then gosub [inputdata] if q=4 then gosub [convatb] if q=5 then gosub [deconcob] if q=6 then gosub [deconcoa] goto [aleap] [convatb] if t(1)=0 or t(2)=0 then print "Curves A and B must both be populated with data!" goto [aleap] end if for k=1 to n c(k)=0 for j=1 to k c(k)=c(k)+a(j)*b(k-j+1) next j next k for k=1 to n print "C(";k;")= ";c(k) next k t(3)=1 return [deconcob] if t(2)=0 or t(3)=0 then print "Curves B and C must both be populated with data!" goto [aleap] end if m=b(1) h=1 rem find max b for k=2 to n if b(k) > m then m=b(k) h=k end if next k for k=1 to h-1 a(k)=0 next k a(h)=c(h)/b(h) if h=n then [hleap] for k=h+1 to n a(k)=c(k) for j=h to k-1 a(k)=a(k)-a(j)*b(k-j+h) next j a(k)=a(k)/b(h) next k [hleap] print for k=1 to n print "A(";k;")= ";a(k) next k t(1)=1 return [deconcoa] if t(1)=0 or t(3)=0 then print "Curves A and C must both be populated with data!" goto [aleap] end if m=a(1) h=1 rem find max a for k=2 to n if a(k) > m then m=a(k) h=k end if next k for k=1 to h-1 b(k)=0 next k b(h)=c(h)/a(h) if h=n then [ileap] for k=h+1 to n b(k)=c(k) for j=h to k-1 b(k)=b(k)-b(j)*a(k-j+h) next j b(k)=b(k)/a(h) next k [ileap] print for k=1 to n print "B(";k;")= ";b(k) next k t(1)=1 return [inputdata] [gleap] input "Use keyboard (k) or read from data (d) or quit (q)? ";c$ if c$="q" then end if q=1 then a1$="A" t(1)=1 end if if q=2 then a1$="B" t(2)=1 end if if q=3 then a1$="C" t(3)=1 end if if c$="k" then print for i=1 to n print a1$;"(";i;")= "; input " ";x1 if q=1 then a(i)=x1 if q=2 then b(i)=x1 if q=3 then c(i)=x1 next i end if if c$="d" then for i=1 to n read x1 print x1 if q=1 then a(i)=x1 if q=2 then b(i)=x1 if q=3 then c(i)=x1 next i end if if c$<>"d" and c$<>"k" then [gleap] print rem test case curve b data 1101,1048,715,318,141,9,0,0,33,280,483,763 rem test case curve c data 173,215,196,93,73,41,32,27,29,29,71,125 rem test case new curve b data 984,1100,520,354,75,6,2,3,22,311,425,757 return