From 0bc5b2f119fb48cf3914ca5bb8816e626cc1993c Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 24 Jan 2019 15:46:44 +0100 Subject: matheunit.pas: sortiereNachWert und sortiereNachDominanz neu --- matheunit.pas | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/matheunit.pas b/matheunit.pas index 5974e4b..9ee4f4b 100644 --- a/matheunit.pas +++ b/matheunit.pas @@ -66,6 +66,8 @@ function berechneEinheitsZelle(invarianz,modulus: tInt64Point): tInt64Point; function ggT(a,b: int64): int64; function ermittleAnstieg(dat: string; xSpalte,ySpalte: longestOrdinal): extended; function ermittleMittelwert(dat: string; werteSpalte,gewichteSpalte: longestOrdinal): extended; +procedure sortiereNachWert(var maxima: tLongintArray; werte: tExtendedArray; logarithmischesPivot: boolean); +procedure sortiereNachDominanz(var maxima: tLongintArray; werte: tExtendedArray; nullteSpektrometerordnung: extended); implementation @@ -1102,5 +1104,139 @@ begin result:=wSum/gSum; end; +procedure sortiereNachWert(var maxima: tLongintArray; werte: tExtendedArray; logarithmischesPivot: boolean); +var + mins,maxs: tExtendedArray; + pivot,wert,wertLi,wertRe: extended; + vons,biss: tLongintArray; + i,li,re,cnt,tmp: int64; +begin + setLength(vons,1); + vons[0]:=0; + setLength(biss,1); + biss[0]:=length(maxima)-1; + setLength(mins,1); + setLength(maxs,1); + mins[0]:=0; + maxs[0]:=0; + for i:=vons[0] to biss[0] do begin + wert:=werte[maxima[i]]; + if (i=vons[0]) or (wert>maxs[0]) then + maxs[0]:=wert; + if (i=vons[0]) or (wert0 do begin + li:=vons[cnt-1]; + re:=biss[cnt-1]; + + if (li>=re) or (mins[cnt-1]=maxs[cnt-1]) then begin + dec(cnt); + continue; + end; + + if cnt>=length(vons) then begin + setLength(vons,cnt+100); + setLength(biss,cnt+100); + setLength(mins,cnt+100); + setLength(maxs,cnt+100); + end; + + if logarithmischesPivot and (maxs[cnt-1]*mins[cnt-1]>0) then begin + pivot:=sqrt(maxs[cnt-1]*mins[cnt-1]); + if (pivot<=mins[cnt-1]) or (pivot>=maxs[cnt-1]) then + pivot:=(maxs[cnt-1]+mins[cnt-1])/2; + end + else + pivot:=(maxs[cnt-1]+mins[cnt-1])/2; + if pivot>=maxs[cnt-1] then + pivot:=mins[cnt-1]; + + mins[cnt]:=mins[cnt-1]; + biss[cnt]:=biss[cnt-1]; + maxs[cnt]:=mins[cnt]; + mins[cnt-1]:=maxs[cnt-1]; + + while li<=re do begin + wertLi:=werte[maxima[li]]; + if wertLi>pivot then begin + if wertLimaxs[cnt] then + maxs[cnt]:=wertRe; + dec(re); + continue; + end; + if wertLi>maxs[cnt] then + maxs[cnt]:=wertLi; + if wertRe=length(werte)) or (werte[maxima[i]+dom]<=werte[maxima[i]])) and + ((maxima[i]-dom<0) or (werte[maxima[i]-dom]<=werte[maxima[i]])) do + inc(dom); + dominanzen[i]:=dom; + if (maxima[i]+dom < length(werte)) and (werte[maxima[i]]= 0) and (werte[maxima[i]]