-- sparse.ads Sparse storage of a matrix -- specifically designed for solving PDE -- simultaneous equations. -- zero based subscripting -- column (nrow) is right hand side -- -- with real_arrays; -- use real-arrays; -- package A is new sparse(nrow); -- use A; -- i,j:integer; -- val:real; -- A.put(i,j,val); with Real_Arrays; use Real_Arrays; generic Nrow : Integer; package Sparse is procedure Put(I : Integer; J : Integer; Val : Real); procedure Add(I : Integer; J : Integer; Val :Real); procedure Simeq(X : out Real_Vector); -- X returned solution procedure Multiply(X : in Real_Vector; Y : out Real_Vector); procedure Import(M : in Real_Matrix); procedure Export(M : out Real_Matrix); procedure Clear; function Get(I : Integer; J : Integer) return Real; procedure GetRHS(Y : out Real_Vector); procedure SetRHS(Y : in Real_Vector); procedure Write_All; procedure Divide(Krow : Integer; K : Integer); -- works on a Krow j=k+1..n procedure Reduce(Irow : Integer; K : Integer; Krow : Integer); -- works on complete Irow j=k+1..n -- using Krow j=k+1..n where it exists private type Cell; type Link is access Cell; type Cell is record J : Integer := -1; Val : Real := 0.0; Next : Link := null; end record; A : array(0..Nrow-1) of link; end Sparse;