diff options
author | Erich Eckner <git@eckner.net> | 2015-07-22 10:49:35 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2015-07-22 10:49:35 +0200 |
commit | d05d10b935d6287ee7f2afd7f95f26e5ac8e8a4e (patch) | |
tree | b4de33708d10b7ef7a5c75598257a9782b5df6a4 | |
parent | 4ded40f31ea597906b44719b20cc781ca1a678d0 (diff) | |
download | ROM-d05d10b935d6287ee7f2afd7f95f26e5ac8e8a4e.tar.xz |
Filterung der Maxima optimiert, sodass _manchmal_ (?) nun auch mehrere Maxima pro Zyklus richtig behandelt werden koennen
-rw-r--r-- | ROM.lps | 96 | ||||
-rw-r--r-- | romunit.pas | 113 |
2 files changed, 54 insertions, 155 deletions
@@ -9,17 +9,18 @@ <IsPartOfProject Value="True"/> <TopLine Value="221"/> <CursorPos X="11" Y="242"/> - <UsageCount Value="95"/> + <UsageCount Value="96"/> <Loaded Value="True"/> </Unit0> <Unit1> <Filename Value="romunit.pas"/> <IsPartOfProject Value="True"/> + <IsVisibleTab Value="True"/> <EditorIndex Value="1"/> - <TopLine Value="713"/> - <CursorPos Y="988"/> - <FoldState Value=" T3iD041 pkRkZ0Y2]9clZ093 piXj70G]Rj3jN0w6]9UlG0S[I4Ck10P7]aejg]+l"/> - <UsageCount Value="95"/> + <TopLine Value="541"/> + <CursorPos Y="579"/> + <FoldState Value=" T3iD041 pkRkZ0Y113 piYnW08112]Bbm1054 pj3jI0S1]9Ck10P7]Rejg]wz"/> + <UsageCount Value="96"/> <Loaded Value="True"/> </Unit1> <Unit2> @@ -27,14 +28,13 @@ <IsPartOfProject Value="True"/> <EditorIndex Value="-1"/> <CursorPos Y="10"/> - <UsageCount Value="94"/> + <UsageCount Value="95"/> </Unit2> <Unit3> <Filename Value="../units/matheunit.pas"/> - <IsVisibleTab Value="True"/> <EditorIndex Value="2"/> - <TopLine Value="214"/> - <CursorPos X="15" Y="250"/> + <TopLine Value="26"/> + <CursorPos X="10" Y="22"/> <UsageCount Value="10"/> <Loaded Value="True"/> </Unit3> @@ -47,123 +47,123 @@ <JumpHistory Count="30" HistoryIndex="29"> <Position1> <Filename Value="ROM.lpr"/> - <Caret Line="20" Column="56"/> + <Caret Line="196" Column="45" TopLine="175"/> </Position1> <Position2> <Filename Value="ROM.lpr"/> - <Caret Line="196" Column="45" TopLine="175"/> + <Caret Line="199" Column="15" TopLine="178"/> </Position2> <Position3> <Filename Value="ROM.lpr"/> - <Caret Line="199" Column="15" TopLine="178"/> + <Caret Line="201" Column="15" TopLine="180"/> </Position3> <Position4> <Filename Value="ROM.lpr"/> - <Caret Line="201" Column="15" TopLine="180"/> + <Caret Line="203" Column="34" TopLine="182"/> </Position4> <Position5> <Filename Value="ROM.lpr"/> - <Caret Line="203" Column="34" TopLine="182"/> + <Caret Line="208" Column="18" TopLine="187"/> </Position5> <Position6> <Filename Value="ROM.lpr"/> - <Caret Line="208" Column="18" TopLine="187"/> + <Caret Line="157" Column="45" TopLine="127"/> </Position6> <Position7> - <Filename Value="ROM.lpr"/> - <Caret Line="157" Column="45" TopLine="127"/> + <Filename Value="romunit.pas"/> + <Caret Line="1005" Column="6" TopLine="816"/> </Position7> <Position8> <Filename Value="romunit.pas"/> - <Caret Line="1005" Column="6" TopLine="816"/> + <Caret Line="990" TopLine="974"/> </Position8> <Position9> <Filename Value="romunit.pas"/> - <Caret Line="990" TopLine="974"/> + <Caret Line="994" Column="45" TopLine="973"/> </Position9> <Position10> <Filename Value="romunit.pas"/> - <Caret Line="994" Column="45" TopLine="973"/> + <Caret Line="1003" Column="86" TopLine="974"/> </Position10> <Position11> - <Filename Value="romunit.pas"/> - <Caret Line="1003" Column="86" TopLine="974"/> + <Filename Value="ROM.lpr"/> + <Caret Line="208" TopLine="204"/> </Position11> <Position12> <Filename Value="ROM.lpr"/> - <Caret Line="208" TopLine="204"/> + <Caret Line="207" Column="47" TopLine="186"/> </Position12> <Position13> <Filename Value="ROM.lpr"/> - <Caret Line="207" Column="47" TopLine="186"/> + <Caret Line="70" Column="7" TopLine="28"/> </Position13> <Position14> - <Filename Value="ROM.lpr"/> - <Caret Line="70" Column="7" TopLine="28"/> + <Filename Value="romunit.pas"/> + <Caret Line="987" Column="101" TopLine="520"/> </Position14> <Position15> <Filename Value="romunit.pas"/> - <Caret Line="987" Column="101" TopLine="520"/> + <Caret Line="1028" Column="50" TopLine="521"/> </Position15> <Position16> <Filename Value="romunit.pas"/> - <Caret Line="1028" Column="50" TopLine="521"/> + <Caret Line="1024" Column="23" TopLine="759"/> </Position16> <Position17> - <Filename Value="romunit.pas"/> - <Caret Line="1024" Column="23" TopLine="759"/> - </Position17> - <Position18> <Filename Value="ROM.lpr"/> <Caret Line="63" Column="18" TopLine="25"/> + </Position17> + <Position18> + <Filename Value="romunit.pas"/> + <Caret Line="202" Column="50" TopLine="183"/> </Position18> <Position19> <Filename Value="romunit.pas"/> - <Caret Line="202" Column="50" TopLine="183"/> + <Caret Line="48" Column="32" TopLine="37"/> </Position19> <Position20> - <Filename Value="romunit.pas"/> - <Caret Line="48" Column="32" TopLine="37"/> + <Filename Value="ROM.lpr"/> + <Caret Line="204" Column="10" TopLine="174"/> </Position20> <Position21> <Filename Value="ROM.lpr"/> - <Caret Line="204" Column="10" TopLine="174"/> + <Caret Line="225" TopLine="201"/> </Position21> <Position22> <Filename Value="ROM.lpr"/> - <Caret Line="225" TopLine="201"/> + <Caret Line="220" Column="5" TopLine="200"/> </Position22> <Position23> <Filename Value="ROM.lpr"/> - <Caret Line="220" Column="5" TopLine="200"/> + <Caret Line="13" Column="24"/> </Position23> <Position24> - <Filename Value="ROM.lpr"/> - <Caret Line="13" Column="24"/> - </Position24> - <Position25> <Filename Value="../units/matheunit.pas"/> <Caret Line="34"/> + </Position24> + <Position25> + <Filename Value="ROM.lpr"/> + <Caret Line="17" Column="33" TopLine="4"/> </Position25> <Position26> <Filename Value="ROM.lpr"/> - <Caret Line="17" Column="33" TopLine="4"/> + <Caret Line="35" Column="12" TopLine="4"/> </Position26> <Position27> <Filename Value="ROM.lpr"/> - <Caret Line="35" Column="12" TopLine="4"/> + <Caret Line="99" Column="16" TopLine="87"/> </Position27> <Position28> - <Filename Value="ROM.lpr"/> - <Caret Line="99" Column="16" TopLine="87"/> + <Filename Value="romunit.pas"/> + <Caret Line="8" Column="33"/> </Position28> <Position29> <Filename Value="romunit.pas"/> - <Caret Line="8" Column="33"/> + <Caret Line="32" Column="26"/> </Position29> <Position30> <Filename Value="romunit.pas"/> - <Caret Line="32" Column="26"/> + <Caret Line="563" Column="17" TopLine="521"/> </Position30> </JumpHistory> </ProjectSession> diff --git a/romunit.pas b/romunit.pas index 8bce286..a796540 100644 --- a/romunit.pas +++ b/romunit.pas @@ -314,36 +314,9 @@ begin monotonieHerstellen(inPuls,exList[0],exList[1]); monotonieHerstellen(outPuls,exList[2],exList[3]); - writeln; - for i:=0 to 3 do begin - for j:=0 to length(exList[i])-1 do - write(exList[i,j],'(',j,') '); - writeln; - end; - vereineExtrema(inPuls,outPuls,exList[0],exList[2],0.5); vereineExtrema(inPuls,outPuls,exList[1],exList[3],0.5); -writeln(length(exList[0]),' ',length(exList[1]),' ',length(exList[2]),' ',length(exList[3])); - -{ for k:=0 to 1 do begin - i:=0; - while (i<length(exList[k])-1) and (exList[k,i+1]<exList[1-k,0]) do - inc(i); - for j:=i to length(exList[k])-1 do - exList[k,j-i]:=exList[k,j]; - setlength(exList[k],length(exList[k])-i); - for j:=i to length(exList[2+k])-1 do - exList[2+k,j-i]:=exList[2+k,j]; - setlength(exList[2+k],length(exList[2+k])-i); - - i:=length(exList[k])-1; - while (i>0) and (exList[k,i-1]>exList[1-k,length(exList[1-k])-1]) do - dec(i); - setlength(exList[k],i+1); - setlength(exList[2+k],i+1); - end; } - writeln; for i:=0 to 3 do begin for j:=0 to length(exList[i])-1 do @@ -359,14 +332,6 @@ writeln(length(exList[0]),' ',length(exList[1]),' ',length(exList[2]),' ',length stuecke[i,b1,b2]:= exList[(i and 1) xor byte(exList[0,0]>exList[1,0]) xor (2*byte(b2)) xor byte(b1),(i+byte(b1)) div 2]; - writeln; - for i:=0 to length(stuecke)-1 do - writeln(i,': ',stuecke[i,false,false],' ',stuecke[i,false,true],' ',stuecke[i,true,false],' ',stuecke[i,true,true]); - writeln; -{ for i:=0 to length(stuecke)-1 do - writeln(inPuls[stuecke[i,false,false]].x,' ',outPuls[stuecke[i,false,true]].x,' ',inPuls[stuecke[i,true,false]].x,' ',outPuls[stuecke[i,true,true]].x); - writeln; } - setlength(erledigt,length(stuecke)); for i:=0 to length(erledigt)-1 do erledigt[i]:=false; @@ -408,21 +373,6 @@ writeln(length(exList[0]),' ',length(exList[1]),' ',length(exList[2]),' ',length for i:=0 to length(erledigt)-1 do b1:=b1 and erledigt[i]; until b1; - - -(* setlength(surTraj,min(length(inPuls),length(outPuls))); - for i:=0 to length(surTraj)-1 do begin - surTraj[i].x:=(inPuls[i].x+outPuls[i].x)/2; - surTraj[i].y:=inPuls[i].y+outPuls[i].y; - end; - for i:=0 to length(exList[0])-1 do - surTraj[exList[0,i]].y:=-1; - for i:=0 to length(exList[1])-1 do - surTraj[exList[1,i]].y:=1; - for i:=0 to length(exList[2])-1 do - surTraj[exList[2,i]].y:=0; - for i:=0 to length(exList[3])-1 do - surTraj[exList[3,i]].y:=0; *) end; procedure smoothen(var dat: tExtPointArray; width: longint); @@ -540,29 +490,19 @@ procedure filtereExtrema(const dat: tExtPointArray; var extrema: tLongintArray; var mitte,i,j,k: longint; mx,dist: extended; behalten: array of boolean; - Toepfe: array of longint; begin setlength(behalten,length(extrema)); for i:=0 to length(behalten)-1 do behalten[i]:=false; - setlength(toepfe,round(sqrt(length(extrema)))); - for i:=0 to length(toepfe)-1 do - toepfe[i]:=0; - - for i:=0 to length(extrema)-1 do - inc(toepfe[round(dat[extrema[i]].x/sollAbst*length(toepfe)) mod length(toepfe)]); - mitte:=0; - for i:=1 to length(toepfe)-1 do - if toepfe[i]>toepfe[mitte] then + mx:=abs(dat[extrema[0]].y); + for i:=1 to length(extrema)-1 do + if abs(dat[extrema[i]].y)>mx then begin + mx:=abs(dat[extrema[i]].y);; mitte:=i; - - mx:=0; - for i:=0 to length(extrema)-1 do - mx:=mx + myfrac(dat[extrema[i]].x - mitte/length(toepfe) + 0.5); - - mx:=(mx/length(extrema) + mitte/length(toepfe) - 0.5)*sollAbst; + end; + mx:=dat[extrema[mitte]].x; for i:=round((dat[extrema[0]].x - mx)/sollAbst) to round((dat[extrema[length(extrema)-1]].x - mx)/sollAbst) do begin dist:=abs(dat[extrema[0]].x - i*sollAbst - mx); @@ -576,51 +516,10 @@ begin behalten[k]:=true; end; -(*// Variante 1 - mx:=(dat[0].x+dat[length(dat)-1].x)/2; - mitte:=0; - for i:=1 to length(extrema)-1 do - if abs(dat[extrema[mitte]].x-mx)>abs(dat[extrema[i]].x-mx) then - mitte:=i; - repeat - j:=mitte; - repeat - k:=-1; - for i:=j-1 downto 0 do - if (abs(dat[extrema[j]].x-dat[extrema[i]].x-sollAbst)<=toleranz) and - ((k=-1) or (abs(dat[extrema[j]].x-dat[extrema[i]].x-sollAbst)<abs(dat[extrema[j]].x-dat[extrema[k]].x-sollAbst))) then - k:=i; - if k<>-1 then begin - behalten[k]:=true; - behalten[j]:=true; - j:=k; - end; - until k=-1; - if j=mitte then - inc(mitte); - until (j<>mitte) or (mitte>length(extrema)); - if j=mitte then Fehler('So, wie sich der Programmierer das gedacht hat, findet man die richtigen Maxima nicht ...'); - j:=mitte; - repeat - k:=-1; - for i:=j+1 to length(extrema)-1 do - if (abs(dat[extrema[i]].x-dat[extrema[j]].x-sollAbst)<=toleranz) and - ((k=-1) or (abs(dat[extrema[i]].x-dat[extrema[j]].x-sollAbst)<abs(dat[extrema[k]].x-dat[extrema[j]].x-sollAbst))) then - k:=i; - if k<>-1 then begin - behalten[k]:=true; - behalten[j]:=true; - j:=k; - end; - until k=-1; - if j=mitte then Fehler('So, wie sich der Programmierer das gedacht hat, findet man die richtigen Maxima nicht ...'); -*) - j:=0; for i:=0 to length(behalten)-1 do if behalten[i] then begin extrema[j]:=extrema[i]; -// write(extrema[j],' '); inc(j); end; setlength(extrema,j); |