Registriert seit: 14. Apr 2009
673 Beiträge
|
AW: Lineares Gleichungssystem lösen
30. Okt 2020, 11:22
Hier ist wenigstens ein Beispiel aus dem Testsystem:
Delphi-Quellcode:
procedure TestTThreadedMatrix.TestMatrixSolve;
const cBlkWidth = 512;
cBlkSize = cBlkWidth*cBlkWidth;
var a, x1, x2, b : TDoubleDynArray;
i : integer;
start, stop : int64;
index : integer;
m1, m2 : IMatrix;
mb : IMatrix;
begin
{$IFDEF FMX} Setup; {$ENDIF};
SetLength(a, cBlkSize);
SetLength(b, 3*cBlkWidth);
SetLength(x1, 3*cBlkWidth);
SetLength(x2, 3*cBlkWidth);
RandSeed := 15;
for i := 0 to cBlkSize - 1 do
a[i] := Random - 0.5;
for i := 0 to 3*cBlkWidth - 1 do
b[i] := Random - 0.5;
mb := TDoubleMatrix.Create(b, 3, cBlkWidth);
m1 := TDoubleMatrix.Create(a, cBlkWidth, cBlkWidth);
m2 := TThreadedMatrix.Create(a, cBlkWidth, cBlkWidth);
start := MtxGetTime;
m1.SolveLinEQInPlace(mb);
stop := MtxGetTime;
Status(Format('Blocked LU decomp: %.2fms', [(stop - start)/mtxfreq*1000]));
start := MtxGetTime;
m2.SolveLinEQInPlace(mb);
stop := MtxGetTime;
Status(Format('Threaded LU decomp: %.2fms', [(stop - start)/mtxfreq*1000]));
index := 0;
Check(CheckMtxIdx(m1.SubMatrix, m2.SubMatrix, index), Format('error Lin equation solve. Error at x[%d] = %.5f, y[%d] = %.5f', [index, x1[index], index, x2[index]]));
{$IFDEF FMX} TearDown; {$ENDIF};
end;
Achtung: Bin kein Informatiker sondern komme vom Bau.
|
|
Zitat
|