-- rematari.adb with Text_IO ; use Text_IO ; with Int_IO ; use Int_IO ; with Real_IO ; use Real_IO ; package body Real_Matrix_Arithmetic is function "*" ( A , B : Real_Matrix ) return Real_Matrix is -- Create an object C for temporary use -- The size is based on the formal parameters A and B when called C : Real_Matrix ( A'Range(1) , B'Range(2)) ; begin -- check for legal matrices to multiply if A'Length ( 2 ) /= B'Length ( 1 ) then raise Matrix_Error ; end if ; -- now, compute the product for I in A'Range ( 1 ) loop for J in B'Range ( 2 ) loop C ( I , J ) := 0.0 ; for K in A'Range ( 2 ) loop C ( I , J ) := C ( I , J ) + A ( I , K ) * B ( K - A'First(2) + B'First(1) , J) ; -- <-- offset subscript ---> -- all other subscripts are in correct Range end loop ; end loop ; end loop ; return C ; end ; procedure Put ( A : Real_Matrix ; Width : Integer := 3 ; Fore : Integer := 2 ; Aft : Integer := Real'Digits - 1 ; Exp : Integer := 3 ) is begin for I in A'Range ( 1 ) loop for J in A'Range ( 2 ) loop Put ( "MAT(" ) ; Put ( I , Width ) ; Put ( "," ) ; Put ( J , Width ) ; Put ( " ) = " ) ; Put ( A( I , J ) , Fore , Aft , Exp ) ; New_Line ; end loop ; end loop ; end Put ; end Real_Matrix_Arithmetic ;