You've already forked lazarus-ccr
LazStats: Add tests.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7925 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
64
applications/lazstats/tests/matrix_test/MatrixTest.lpi
Normal file
64
applications/lazstats/tests/matrix_test/MatrixTest.lpi
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="MatrixTest"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="MatrixTest.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="MatrixTest"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\..\source\units"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
51
applications/lazstats/tests/matrix_test/MatrixTest.lpr
Normal file
51
applications/lazstats/tests/matrix_test/MatrixTest.lpr
Normal file
@@ -0,0 +1,51 @@
|
||||
program MatrixTest;
|
||||
|
||||
uses
|
||||
MatrixUnit;
|
||||
|
||||
var
|
||||
A: TDblMatrix;
|
||||
B: TDblMatrix;
|
||||
|
||||
procedure WriteMatrix(A: TDblMatrix; AName: String);
|
||||
var
|
||||
n, m, i, j: Integer;
|
||||
begin
|
||||
WriteLn(AName, ' = ');
|
||||
MatSize(A, n,m);
|
||||
for i := 0 to n-1 do
|
||||
begin
|
||||
for j := 0 to m-1 do
|
||||
Write(A[i, j]:10:3);
|
||||
WriteLn;
|
||||
end;
|
||||
WriteLn;
|
||||
end;
|
||||
|
||||
begin
|
||||
SetLength(A, 3, 3);
|
||||
A[0, 0] := 1.0; A[0, 1] := 3.0; A[0, 2] := 4.0;
|
||||
A[1, 0] := -1.0; A[1, 1] := 2.0; A[1, 2] := -3.0;
|
||||
A[2, 0] := 0.0; A[2, 1] := -1.0; A[2, 2] := 1.0;
|
||||
WriteMatrix(A, 'A');
|
||||
|
||||
SetLength(B, 3, 3);
|
||||
B[0, 0] := -1.0; B[0, 1] := -3.0; B[0, 2] := 1.0;
|
||||
B[1, 0] := +1.0; B[1, 1] := 2.0; B[1, 2] := -3.0;
|
||||
B[2, 0] := 0.0; B[2, 1] := -2.0; B[2, 2] := 2.0;
|
||||
WriteMatrix(B, 'B');
|
||||
|
||||
WriteMatrix(A*B, 'A*B');
|
||||
|
||||
WriteMatrix(MatInverse(A), 'inv(A)');
|
||||
|
||||
WriteMatrix(A*MatInverse(A), 'A*inv(A)');
|
||||
|
||||
WriteLn('det(A) = ');
|
||||
WriteLn(MatDeterminant(A):10:3);
|
||||
|
||||
WriteLn;
|
||||
WriteLn('Press ENTER to quit...');
|
||||
ReadLn;
|
||||
end.
|
||||
|
Reference in New Issue
Block a user