# Программирование векторных и матричных операций, страница 4

end;

end;

{===============================================================}

{Умножает две матрицы}

procedure Mul_Matrix;

var

i,j,k:integer;

begin

for i:=1 to Size do

begin

for j:=1 to Size do

begin

Matrix_Of_Resalt[i,j]:=0;

for k:=1 to Size do

Matrix_Of_Resalt[i,j] := Matrix_Of_Resalt[i,j] +

First_Matrix[i,k]*Second_Matrix[k,j];

end;

end;

end;

{===============================================================}

{Суммирует две матрицы}

var  i,j:integer;

begin

for i:=1 to Size do

for j:=1 to Size do

Matrix_Of_Resalt[i,j] := First_Matrix[i,j] + Second_Matrix[i,j];

end;

{===============================================================}

{Вычитает две матрицы}

procedure Sub_Matrix;

var  i,j:integer;

begin

for i:=1 to Size do

for j:=1 to Size do

Matrix_Of_Resalt[i,j] := First_Matrix[i,j] - Second_Matrix[i,j];

end;

{===============================================================}

{Умножает матрицу на коэффициент}

procedure Mul_Matrix_On_Coef;

var

i,j:integer;

begin

for i:=1 to Size do

for j:=1 to Size do

Matrix_Of_Resalt[i,j] := Matrix[i,j]*Coefficient;

end;

{===============================================================}

{Умножает матрицу на вектор}

procedure Mul_Matrix_On_Vector;

var

i,j:Integer;

begin

for i:=1 to Size do

for j:=1 to Size do

Matrix_Of_Resalt[i,j]:=0;

for i:=1 to Size do

for j:=1 to Size do

Matrix_Of_Resalt[i,j]:=Matrix_Of_Resalt[i,j]+Matrix[i,j]*Vector[j];

end;

{===============================================================}

{Выводит матрицу в файл}

procedure Print_Matrix_To_File;

var

File_On_Disk:text;

i,j:integer;

begin

assign(File_On_Disk,File_Name);

rewrite(File_On_Disk);

for i:=1 to Size do

begin

for j:=1 to Size do

write(File_On_Disk,Matrix[i,j],'        ');

writeln(File_On_Disk);

end;

close(File_On_Disk);

end;

{===============================================================}

{Выводит матрицу на экран}

procedure Print_Matrix_ON_Screen;

var

i,j:integer;

begin

ClrScr;

for i:=1 to Size do

for j:=1 to Size do

begin

GoToXY(j*20-16,i*3);

Write('Matrix[',i,',',j,']=',Matrix[i,j]:3);  {Вывод строки}

end;

end;

{===============================================================}

{Конец модуля}

END.

Текстмодуля (U_Vector):

UNIT U_Vector;

{****--------*****--------****}

INTERFACE {Объявление раздела модуля: INTERFACE - ИНТЕРФЕЙС}

{****--------*****--------****}

{Объявление записи числа}

const

Vector_Size=3;

type

Size_Type_Vector = 1..Vector_Size;

VectorArray = array[Size_Type_Vector] of integer;

procedure Take_Vector_From_File(var Vector:VectorArray; File_Name:string; Size:integer);

procedure Take_Vector_From_Keyboard(var Vector:VectorArray; Size:integer);

procedure Print_Vector_ON_Screen(Vector:VectorArray; Size:integer);

procedure Print_Vector_To_File(Vector:VectorArray; File_Name:string; Size:integer);

function Scal_Mul_Vector(First_Vector,Second_Vector:VectorArray; Size:integer):Integer;

var Vector_Of_Resalt:VectorArray; Size:integer);

procedure Mul_Vector_On_Scal(Vector:VectorArray; Scalar:integer;

var Vector_Of_Resalt:VectorArray;Size:integer);

{****------****------****}

IMPLEMENTATION {Объявление раздела модуля: IMPLEMENTATION - РЕАЛИЗАЦИЯ}

{****------****------****}

uses crt;

{===============================================================}

{Считывает вектор из файла}

procedure Take_Vector_From_File;