[BACK]Return to ts_intmat.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Matrices

Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Matrices/ts_intmat.adb, Revision 1.1

1.1     ! maekawa     1: with text_io,integer_io;                 use text_io,integer_io;
        !             2: with Standard_Integer_Vectors;
        !             3: with Standard_Integer_Vectors_io;
        !             4: with Standard_Integer_Matrices;
        !             5: with Standard_Integer_Matrices_io;
        !             6: with Standard_Integer_VecMats;
        !             7: with Standard_Integer_VecMats_io;
        !             8: with Standard_Integer_Linear_Solvers;
        !             9: with Standard_Random_Matrices;           use Standard_Random_Matrices;
        !            10: with Multprec_Random_Matrices;           use Multprec_Random_Matrices;
        !            11: with Multprec_Integer_Vectors;
        !            12: with Multprec_Integer_Vectors_io;
        !            13: with Multprec_Integer_Matrices;
        !            14: with Multprec_Integer_Matrices_io;
        !            15: with Multprec_Integer_Linear_Solvers;
        !            16:
        !            17: procedure ts_intmat is
        !            18:
        !            19: -- DESCRIPTION :
        !            20: --   Tests the matrix packages of standard and multi-precision integers.
        !            21:
        !            22:   procedure Test_Standard_io is
        !            23:
        !            24:     use Standard_Integer_Matrices,Standard_Integer_Matrices_io;
        !            25:
        !            26:     n,m : natural;
        !            27:
        !            28:   begin
        !            29:     put("Give the number of rows : "); get(n);
        !            30:     put("Give the number of columns : "); get(m);
        !            31:     declare
        !            32:       mat : Matrix(1..n,1..m);
        !            33:     begin
        !            34:       put("Give "); put(n,1); put("x"); put(m,1);
        !            35:       put_line(" integer matrix : "); get(mat);
        !            36:       put_line("Your matrix : "); put(mat);
        !            37:     end;
        !            38:   end Test_Standard_io;
        !            39:
        !            40:   procedure Test_Standard_VecMat_io is
        !            41:
        !            42:     use Standard_Integer_Matrices,Standard_Integer_Matrices_io;
        !            43:     use Standard_Integer_VecMats,Standard_Integer_VecMats_io;
        !            44:
        !            45:     n,n1,n2 : natural;
        !            46:     lv : Link_to_VecMat;
        !            47:
        !            48:   begin
        !            49:     put("Give the number of matrices : "); get(n);
        !            50:     put("Give #rows : "); get(n1);
        !            51:     put("Give #columns : "); get(n2);
        !            52:     put("Give "); put(n,1); put(" "); put(n1,1); put("-by-"); put(n2,1);
        !            53:     put_line(" integer matrices : ");
        !            54:     get(n,n1,n2,lv);
        !            55:     put_line("The vector of matrices :"); put(lv);
        !            56:   end Test_Standard_VecMat_io;
        !            57:
        !            58:   procedure Random_Test_Standard_Solver
        !            59:                  ( n,m : in natural; low,upp : in integer ) is
        !            60:
        !            61:     use Standard_Integer_Vectors,Standard_Integer_Vectors_io;
        !            62:     use Standard_Integer_Matrices;
        !            63:     use Standard_Integer_Linear_Solvers;
        !            64:
        !            65:     mat : Matrix(1..n,1..m) := Random_Matrix(n,m,low,upp);
        !            66:     wrk : Matrix(1..n,1..m) := mat;
        !            67:     sol : Vector(1..m);
        !            68:     res : Vector(1..n);
        !            69:
        !            70:   begin
        !            71:     Upper_Triangulate(wrk);
        !            72:     Solve0(wrk,sol);
        !            73:     res := mat*sol;
        !            74:     put("The residual : "); put(res);
        !            75:     put(" of solution : "); put(sol); new_line;
        !            76:   end Random_Test_Standard_Solver;
        !            77:
        !            78:   procedure Random_Test_Multprec_Solver ( n,m,sz : in natural ) is
        !            79:
        !            80:     use Multprec_Integer_Vectors,Multprec_Integer_Vectors_io;
        !            81:     use Multprec_Integer_Matrices,Multprec_Integer_Matrices_io;
        !            82:     use Multprec_Integer_Linear_Solvers;
        !            83:
        !            84:     mat : Matrix(1..n,1..m) := Random_Matrix(n,m,sz);
        !            85:     wrk : Matrix(1..n,1..m);
        !            86:     sol : Vector(1..m);
        !            87:     res : Vector(1..n);
        !            88:
        !            89:   begin
        !            90:     Copy(mat,wrk);
        !            91:     Upper_Triangulate(wrk);
        !            92:     Solve0(wrk,sol);
        !            93:     res := mat*sol;
        !            94:     put("The residual : "); put(res);
        !            95:     put(" of solution : "); put(sol); new_line;
        !            96:   end Random_Test_Multprec_Solver;
        !            97:
        !            98:   procedure Random_Test_Standard_Solvers is
        !            99:
        !           100:     n,m,nb : natural;
        !           101:     low,upp : integer;
        !           102:
        !           103:   begin
        !           104:     put("Give number of tests : "); get(nb);
        !           105:     put("Give number of rows : "); get(n);
        !           106:     put("Give number of columns : "); get(m);
        !           107:     put("Give lower bound for numbers : "); get(low);
        !           108:     put("Give upper bound for numbers : "); get(upp);
        !           109:     for i in 1..nb loop
        !           110:       Random_Test_Standard_Solver(n,m,low,upp);
        !           111:     end loop;
        !           112:   end Random_Test_Standard_Solvers;
        !           113:
        !           114:   procedure Random_Test_Multprec_Solvers is
        !           115:
        !           116:     n,m,nb,sz : natural;
        !           117:
        !           118:   begin
        !           119:     put("Give number of tests : "); get(nb);
        !           120:     put("Give number of rows : "); get(n);
        !           121:     put("Give number of columns : "); get(m);
        !           122:     put("Give the size of the numbers : "); get(sz);
        !           123:     for i in 1..nb loop
        !           124:       Random_Test_Multprec_Solver(n,m,sz);
        !           125:     end loop;
        !           126:   end Random_Test_Multprec_Solvers;
        !           127:
        !           128:   procedure Interactive_Test_Standard_Solvers is
        !           129:
        !           130:     use Standard_Integer_Vectors,Standard_Integer_Vectors_io;
        !           131:     use Standard_Integer_Matrices,Standard_Integer_Matrices_io;
        !           132:     use Standard_Integer_Linear_Solvers;
        !           133:
        !           134:     n,m : natural;
        !           135:
        !           136:   begin
        !           137:     put("Give the number of rows : "); get(n);
        !           138:     put("Give the number of columns : "); get(m);
        !           139:     declare
        !           140:       sol : Vector(1..m) := (1..m => 0);
        !           141:       res : Vector(1..n);
        !           142:       mat,wrk : Matrix(1..n,1..m);
        !           143:       l : Matrix(1..n,1..n);
        !           144:     begin
        !           145:       put("Give "); put(n,1); put("x"); put(m,1);
        !           146:       put_line(" integer matrix : "); get(mat);
        !           147:       put_line("Your matrix : "); put(mat);
        !           148:       wrk := mat;
        !           149:       Upper_Triangulate(l,wrk);
        !           150:       put_line("The matrix in upper triangular form : "); put(wrk);
        !           151:       put_line("The transformation matrix T : "); put(l);
        !           152:       put_line("product of T and original matrix : "); put(l*mat);
        !           153:       Solve0(wrk,sol);
        !           154:       put_line("The solution of the homogeneous system : ");
        !           155:       put(sol); new_line;
        !           156:       res := mat*sol;
        !           157:       put("The residual : "); put(res); new_line;
        !           158:     end;
        !           159:   end Interactive_Test_Standard_Solvers;
        !           160:
        !           161:   procedure Test_Multprec_io is
        !           162:
        !           163:     use Multprec_Integer_Matrices,Multprec_Integer_Matrices_io;
        !           164:
        !           165:     n,m : natural;
        !           166:
        !           167:   begin
        !           168:     put("Give the number of rows : "); get(n);
        !           169:     put("Give the number of columns : "); get(m);
        !           170:     declare
        !           171:       mat : Matrix(1..n,1..m);
        !           172:     begin
        !           173:       put("Give "); put(n,1); put("x"); put(m,1);
        !           174:       put_line(" integer matrix : "); get(mat);
        !           175:       put_line("Your matrix : "); put(mat); new_line;
        !           176:     end;
        !           177:   end Test_Multprec_io;
        !           178:
        !           179:   procedure Interactive_Test_Multprec_Solvers is
        !           180:
        !           181:     use Multprec_Integer_Vectors,Multprec_Integer_Vectors_io;
        !           182:     use Multprec_Integer_Matrices,Multprec_Integer_Matrices_io;
        !           183:     use Multprec_Integer_Linear_Solvers;
        !           184:
        !           185:     n,m : natural;
        !           186:
        !           187:   begin
        !           188:     put("Give the number of rows : "); get(n);
        !           189:     put("Give the number of columns : "); get(m);
        !           190:     declare
        !           191:       sol : Vector(1..m);
        !           192:       res : Vector(1..n);
        !           193:       mat,wrk : Matrix(1..n,1..m);
        !           194:       l : Matrix(1..n,1..n);
        !           195:     begin
        !           196:       put("Give "); put(n,1); put("x"); put(m,1);
        !           197:       put_line(" integer matrix : "); get(mat);
        !           198:       put_line("Your matrix : "); put(mat);
        !           199:       Copy(mat,wrk);
        !           200:       Upper_Triangulate(l,wrk);
        !           201:       put_line("The matrix in upper triangular form : "); put(wrk);
        !           202:       put_line("The transformation matrix T : "); put(l);
        !           203:       put_line("product of T and original matrix : "); put(l*mat);
        !           204:       Solve0(wrk,sol);
        !           205:       put_line("The solution of the homogeneous system : ");
        !           206:       put(sol); new_line;
        !           207:       res := mat*sol;
        !           208:       put("The residual : "); put(res); new_line;
        !           209:     end;
        !           210:   end Interactive_Test_Multprec_Solvers;
        !           211:
        !           212:   procedure Test_Multprec_Matrix_Vector_Product is
        !           213:
        !           214:     use Multprec_Integer_Vectors,Multprec_Integer_Vectors_io;
        !           215:     use Multprec_Integer_Matrices,Multprec_Integer_Matrices_io;
        !           216:
        !           217:     n,m : natural;
        !           218:
        !           219:   begin
        !           220:     put("Give the number of rows : "); get(n);
        !           221:     put("Give the number of columns : "); get(m);
        !           222:     declare
        !           223:       mat : Matrix(1..n,1..m);
        !           224:       vec : Vector(1..m);
        !           225:       prod : Vector(1..n);
        !           226:     begin
        !           227:       put("Give "); put(n,1); put("x"); put(m,1);
        !           228:       put_line(" integer matrix : "); get(mat);
        !           229:       put_line("Your matrix : "); put(mat);
        !           230:       put("Give an " ); put(m,1); put("-vector : "); get(vec);
        !           231:       put("Your vector : "); put(vec); new_line;
        !           232:       prod := mat*vec;
        !           233:       put_line("The matrix-vector product : "); put(prod); new_line;
        !           234:     end;
        !           235:   end Test_Multprec_Matrix_Vector_Product;
        !           236:
        !           237:   procedure Main is
        !           238:
        !           239:     ans : character;
        !           240:
        !           241:   begin
        !           242:     new_line;
        !           243:     put_line("Interactive testing of matrices of integer numbers");
        !           244:     new_line;
        !           245:     loop
        !           246:       put_line("Choose one of the following : ");
        !           247:       put_line("  0. exit this program.");
        !           248:       put_line("  1. io of matrices of standard numbers.");
        !           249:       put_line("  2. io of vectors of matrices of standard numbers.");
        !           250:       put_line("  3. solve given linear systems of standard numbers.");
        !           251:       put_line("  4. solve random linear systems of standard numbers.");
        !           252:       put_line("  5. io of matrices of multi-precision numbers.");
        !           253:       put_line("  6. solve given linear systems of multi-precision numbers.");
        !           254:       put_line("  7. solve random linear systems of multi-precision numbers.");
        !           255:       put_line("  8. test multi-precision matrix-vector product.");
        !           256:       put("Make your choice (0,1,2,3,4,5,6,7 or 8) : "); get(ans);
        !           257:       exit when (ans = '0');
        !           258:       case ans is
        !           259:         when '1' => Test_Standard_io;
        !           260:         when '2' => Test_Standard_VecMat_io;
        !           261:         when '3' => Interactive_Test_Standard_Solvers;
        !           262:         when '4' => Random_Test_Standard_Solvers;
        !           263:         when '5' => Test_Multprec_io;
        !           264:         when '6' => Interactive_Test_Multprec_Solvers;
        !           265:         when '7' => Random_Test_Multprec_Solvers;
        !           266:         when '8' => Test_Multprec_Matrix_Vector_Product;
        !           267:         when others => null;
        !           268:       end case;
        !           269:     end loop;
        !           270:   end Main;
        !           271:
        !           272: begin
        !           273:   Main;
        !           274: end ts_intmat;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>