File : lin.ads


with Ints, Reps;
use Ints, Reps;
with Ada.Unchecked_Deallocation;

package Lin is

  type IVec is array(Integer range <>) of Integer;
  type IntVec is array(Integer range <>) of Int;
  type RVec is array(Integer range <>) of Rep;
  type IvecPtr is access all Ivec;
  type IntVecPtr is access all IntVec;
  type RVecPtr is access all RVec;
  type IMat is array(Integer range <>,Integer range <>) of Integer;
  type IMatPtr is access all IMat;
  type RMat is array(Integer range <>,Integer range <>) of Rep;
  type RMatPtr is access all RMat;

  type QMat(Dim: Positive) is
    record
      P: IMat(1 .. Dim,1 .. Dim);
      Q: Positive;
    end record;

  procedure Free is new Ada.Unchecked_Deallocation(IVec,IVecPtr);
  procedure Free is new Ada.Unchecked_Deallocation(IntVec,IntVecPtr);
  procedure Free is new Ada.Unchecked_Deallocation(RMat,RMatPtr);

  procedure SetZero(V: in out IVec);
  procedure SetZero(V: in out IntVec);
  procedure SetZero(A: in out IMat);
  procedure SetOne(A: in out IMat);
  procedure SetZero(V: in out RVec);
  procedure SetZero(A: in out RMat);
  procedure SetOne(A: in out RMat);
  procedure SetZero(A: in out QMat);
  function QZero(Dim: in Positive) return QMat;
  procedure SetOne(A: in out QMat);
  function QOne(Dim: in Positive) return QMat;
  procedure SetRow(I: in Positive; V: in IVec; A: in out QMat);

  pragma Inline (SetZero);

end Lin;