LazStats: Fix usage of invalid rows in WLSUnit. Cleanup.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7781 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-18 13:52:00 +00:00
parent 791746e7ef
commit dfffbcf6f8
4 changed files with 175 additions and 257 deletions

View File

@ -75,27 +75,29 @@ end;
{ Extracts the grid values from the columns with indices given by AColIndices
and puts them into the columns of the result matrix.
This means: The result matrix contains the variables as columns and the
cases as rows. }
cases as rows.
"Bad" records (filtered, empty) are skipped. }
function CollectMatValues(AGrid: TStringGrid; AColIndices: IntDyneVec): DblDyneMat;
var
nr, r, c, i, j: Integer;
r, c, i, j: Integer;
val: Double;
begin
SetLength(Result, AGrid.RowCount, Length(AColIndices));
nr := 0;
i := 0;
for r:= 1 to AGrid.RowCount-1 do
begin
if not GoodRecord(AGrid, r, AColIndices) then Continue;
i := r - 1;
for j := 0 to High(AColIndices) do
begin
c := AColIndices[j];
if TryStrToFloat(trim(AGrid.Cells[c, r]), val) then
Result[i, j] := val;
Result[i, j] := val
else
Result[i, j] := NaN;
end;
inc(nr); // count the number of rows in the matrix.
inc(i);
end;
SetLength(Result, nr);
SetLength(Result, i);
end;