-- Matrix_Demo.adb with TEXT_IO ; use TEXT_IO ; with REAL_MATRIX_ARITHMETIC ; use REAL_MATRIX_ARITHMETIC ; procedure MATRIX_DEMO is -- Establish the object MAT_1 with initial data MAT_1 : REAL_MATRIX ( - 1 .. 1 , - 1 .. 2 ) := -- initialization (( 1.1 , 1.2 , 1.3 , 1.4 ) , -- Note that the structure ( 2.1 , 2.2 , 2.3 , 2.4 ) , -- of the object must be ( 3.1 , 3.2 , 3.3 , 3.4 )) ; -- used to initialize data. -- ( (), (), () ) -- Declare additional objects MAT_1A : REAL_MATRIX ( 0 .. 2 , 0 .. 3 ) ; -- same structure as MAT_1 MAT_2 : REAL_MATRIX ( 1 .. 4 , 0 .. 1 ) := ( ( 1.0 , 1.1 ) , ( 2.0 , 2.1 ) , ( 3.0 , 3.1 ) , ( 4.0 , 4.1 ) ) ; MAT_3 : REAL_MATRIX ( - 2 .. 0 , 5 .. 6 ) ; -- Declare an uncompatible matrix for multiply MAT_BAD : REAL_MATRIX ( 1 .. 3 , 0 .. 5 ) ; begin -- Store MAT_1 into MAT_1A MAT_1A := MAT_1 ; -- Change the value 1.1 to -1.1 MAT_1A ( 0 , 0 ) := - 1.1 ; -- Print MAT_1A PUT_LINE ( " DUMP OF MAT_1A " ) ; PUT ( MAT_1A ) ; -- Compute MAT_3 as the product of MAT_1 times MAT_2 MAT_3 := MAT_1 * MAT_2 ; PUT_LINE ( " DUMP OF MAT_3 := MAT_1 * MAT_2 " ) ; PUT ( MAT_3 ) ; -- Remove following comments for homework 5 ( add declarations and data above ) -- MAT_5 := MAT_1 * MAT_2 + MAT_4 ; -- PUT_LINE ( " DUMP OF MAT_5 " ) ; -- PUT ( MAT_5 ) ; -- -- Cause an exception MAT_3 := MAT_3 * MAT_BAD ; exception when MATRIX_ERROR => PUT_LINE ( "matricies not compatable for requested operation" ) ; end MATRIX_DEMO ;