File : lin-io.adb
with Ada.Strings.Fixed;
package body Lin.IO is
package Txt_Int_IO is new Ada.Text_IO.Integer_IO(Integer);
package Txt_Mod_IO is new Ada.Text_IO.Modular_IO(Int);
use Txt_Int_IO, Txt_Mod_IO;
function MyImg(I: Integer) return String is
use Ada.Strings, Ada.Strings.Fixed;
begin
return Trim(Integer'Image(I),Left);
end MyImg;
procedure Put(F: in File_Type; V: in IVec) is
begin
Put(F,"(");
for I in V'Range loop
Put(F,MyImg(V(I)));
if I<V'Last then Put(F,","); end if;
end loop;
Put(F,")");
end Put;
procedure Show(V: in IVec; NewLine: in Boolean := True) is
begin
Put("(");
for I in V'Range loop
Put(MyImg(V(I)));
if I<V'Last then Put(","); end if;
end loop;
Put(")");
if NewLine then New_Line; end if;
end Show;
procedure Show(V: in RVec; NewLine: in Boolean := True) is
begin
Put("(");
for I in V'Range loop
Txt_Put(Current_Output,V(I));
if I<V'Last then Put(","); end if;
end loop;
Put(")");
if NewLine then New_Line; end if;
end Show;
procedure Show(A: in RMat; Cut: in Rep := Zero) is
begin
for I in A'Range(1) loop
for J in A'Range(2) loop
if Abs(A(I,J))>Cut then
Put("A(" & MyImg(I) & "," & MyImg(J) & ") = ");
Txt_Put(Current_Output,A(I,J));
New_Line;
end if;
end loop;
end loop;
New_Line;
end Show;
procedure ShowBin(V: in IntVec) is
begin
for I in reverse V'Range loop
Put(Item => V(I), Base => 2);
end loop;
New_Line;
end ShowBin;
procedure Show(A: in QMat) is
D: constant Positive := A.P'Last;
begin
for I in 1 .. D loop
for J in 1 .. D loop
Put("A(" & MyImg(I) & "," & MyImg(J) & ") = " & MyImg(A.P(I,J)));
if A.Q /= 1 then
Put("/" & MyImg(A.Q));
end if;
New_Line;
end loop;
end loop;
New_Line;
end Show;
end Lin.IO;