Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,31 +0,0 @@
|
|||
with Ada.Text_IO, Matrix_Scalar;
|
||||
|
||||
procedure Scalar_Ops is
|
||||
|
||||
subtype T is Integer range 1 .. 3;
|
||||
|
||||
package M is new Matrix_Scalar(T, T, Integer);
|
||||
|
||||
-- the functions to solve the task
|
||||
function "+" is new M.Func("+");
|
||||
function "-" is new M.Func("-");
|
||||
function "*" is new M.Func("*");
|
||||
function "/" is new M.Func("/");
|
||||
function "**" is new M.Func("**");
|
||||
function "mod" is new M.Func("mod");
|
||||
|
||||
-- for output purposes, we need a Matrix->String conversion
|
||||
function Image is new M.Image(Integer'Image);
|
||||
|
||||
A: M.Matrix := ((1,2,3),(4,5,6),(7,8,9)); -- something to begin with
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Put_Line(" Initial M=" & Image(A));
|
||||
Ada.Text_IO.Put_Line(" M+2=" & Image(A+2));
|
||||
Ada.Text_IO.Put_Line(" M-2=" & Image(A-2));
|
||||
Ada.Text_IO.Put_Line(" M*2=" & Image(A*2));
|
||||
Ada.Text_IO.Put_Line(" M/2=" & Image(A/2));
|
||||
Ada.Text_IO.Put_Line(" square(M)=" & Image(A ** 2));
|
||||
Ada.Text_IO.Put_Line(" M mod 2=" & Image(A mod 2));
|
||||
Ada.Text_IO.Put_Line("(M*2) mod 3=" & Image((A*2) mod 3));
|
||||
end Scalar_Ops;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
generic
|
||||
type Rows is (<>);
|
||||
type Cols is (<>);
|
||||
type Num is private;
|
||||
package Matrix_Scalar is
|
||||
type Matrix is array(Rows, Cols) of Num;
|
||||
|
||||
generic
|
||||
with function F(L, R: Num) return Num;
|
||||
function Func(Left: Matrix; Right: Num) return Matrix;
|
||||
|
||||
generic
|
||||
with function Image(N: Num) return String;
|
||||
function Image(M: Matrix) return String;
|
||||
|
||||
end Matrix_Scalar;
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package body Matrix_Scalar is
|
||||
|
||||
function Func(Left: Matrix; Right: Num) return Matrix is
|
||||
Result: Matrix;
|
||||
begin
|
||||
for R in Rows loop
|
||||
for C in Cols loop
|
||||
Result(R,C) := F(Left(R,C), Right);
|
||||
end loop;
|
||||
end loop;
|
||||
return Result;
|
||||
end Func;
|
||||
|
||||
function Image(M: Matrix) return String is
|
||||
|
||||
function Img(R: Rows) return String is
|
||||
|
||||
function I(C: Cols) return String is
|
||||
S: String := Image(M(R,C));
|
||||
L: Positive := S'First;
|
||||
begin
|
||||
while S(L) = ' ' loop
|
||||
L := L + 1;
|
||||
end loop;
|
||||
if C=Cols'Last then
|
||||
return S(L .. S'Last);
|
||||
else
|
||||
return S(L .. S'Last) & "," & I(Cols'Succ(C));
|
||||
end if;
|
||||
end I;
|
||||
|
||||
Column: String := I(Cols'First);
|
||||
begin
|
||||
if R=Rows'Last then
|
||||
return "(" & Column & ")";
|
||||
else
|
||||
return "(" & Column & ")," & Img(Rows'Succ(R));
|
||||
end if;
|
||||
end Img;
|
||||
|
||||
begin
|
||||
return("(" & Img(Rows'First) & ")");
|
||||
end Image;
|
||||
|
||||
end Matrix_Scalar;
|
||||
Loading…
Add table
Add a link
Reference in a new issue