-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrix_Lib_Test.adb
87 lines (70 loc) · 3.52 KB
/
Matrix_Lib_Test.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
-------------------------------------------------------------------------------
-- --
-- Matrix Lib --
-- --
-- Matrix_Lib_Test.adb --
-- --
-- MAIN --
-- --
-- Copyright (C) 1996 Ulrik Hørlyk Hjort --
-- --
-- Matrix Lib is free software; you can redistribute it --
-- and/or modify it under terms of the GNU General Public License --
-- as published by the Free Software Foundation; either version 2, --
-- or (at your option) any later version. --
-- Matrix Lib is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- See the GNU General Public License for more details. --
-- You should have received a copy of the GNU General --
-- Public License distributed with Yolk. If not, write to the Free --
-- Software Foundation, 51 Franklin Street, Fifth Floor, Boston, --
-- MA 02110 - 1301, USA. --
-- --
-------------------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Matrix_Lib; use Matrix_Lib;
procedure Matrix_Lib_Test is
M4 : constant Matrix_Lib.Matrix := (
(2.0,1.0,-1.0, 8.0),
(-3.0,-1.0,2.0,-11.0),
(-2.0,1.0,2.0,-3.0));
M6 : constant Matrix_Lib.Matrix :=(
(1.0,3.0,3.0,1.0,0.0,0.0),
(1.0,4.0,3.0,0.0,1.0,0.0),
(1.0,3.0,4.0,0.0,0.0,1.0));
M7 : constant Matrix_Lib.Matrix :=(
(1.0,3.0,3.0),
(1.0,4.0,3.0),
(1.0,3.0,4.0));
Solution : Column(M6'Range(1));
MI : constant Matrix := Get_Inverse(M7);
MM : Matrix(M7'Range(1), M7'Range(2));
begin
Put_Line("---------Test Inverse matrix:");
Put_Line("M : ");
Print (M7);
Put_Line("M Inverse : ");
Print(MI);
Put_Line("M * Minverse : ");
Print(M7*MI);
Put_Line("---------End: Test Inverse matrix:");
Put_Line("---------Test: Solve equation system:");
Print(M4);
Solve_Equation_System(M4, Solution);
Put_Line("Solution: ");
for I in Solution'Range loop
Put_Line("X" & Integer'Image(I) & "= " & Float'Image(Solution(I)) & " ");
end loop;
New_Line;
Put_Line("---------End: Test: Solve equation system:");
Put_Line("---------Test Inverse matrix by gaussian elimination :");
Put_Line("M : ");
Print (M7);
Put_Line("M Inverse : ");
MM := Get_Inverse_By_Gaussian_Elimination(M7);
Print(MM);
Put_Line("M * Minverse : ");
Print(M7*MM);
Put_Line("---------End: Test Inverse matrix by gaussian elimination:");
end Matrix_Lib_Test;