home *** CD-ROM | disk | FTP | other *** search
- (*-------------------------------------------------------------------------*)
- (* GRAFMAT.PAS *)
- (* Grafikserie: Routinen zur Matrizen-/Vektor-Handhabung *)
- (* Setzen die Konstanten xMatDim (Matrizen-x- bzw. Vektor-Ausdehnung), *)
- (* yMatDim (Matrizen-y-Ausdehnung) und die TYPEn tVektor und tMatrix *)
- (* voraus. *)
- (*-------------------------------------------------------------------------*)
-
- PROCEDURE Einheitsmatrix (VAR Matrix: tMatrix);
-
- VAR Zeile, Spalte: INTEGER;
-
- BEGIN
- FOR Zeile := 1 TO yMatDim DO
- FOR Spalte := 1 TO xMatDim DO
- Matrix[Zeile,Spalte] := Ord(Zeile = Spalte)
- END;
-
- (*-------------------------------------------------------------------------*)
- (* Multiplikation zweier gleich dimensionierter (quadratischer) Matrizen: *)
-
- PROCEDURE MatMult(a, b: tMatrix; VAR Res: tMatrix);
-
- VAR Zeile, Spalte, i: INTEGER;
- Sum: REAL;
-
- BEGIN
- FOR Zeile := 1 TO yMatDim DO
- FOR Spalte := 1 TO xMatDim DO
- BEGIN
- Sum := 0;
- FOR i := 1 TO yMatDim DO
- Sum := Sum + a[Zeile,i] * b[i,Spalte];
- Res[Zeile,Spalte] := Sum
- END
- END;
-
- (*-------------------------------------------------------------------------*)
- (* Wendet die Transformationsmatrix "TransMat" auf den Vektor "Vektor" an: *)
-
- PROCEDURE VektorTrans(VAR Vektor: tVektor; TransMat: tMatrix);
-
- VAR Spalte, Zeile: INTEGER;
- Temp: tVektor;
-
- BEGIN
- Temp := Vektor;
- FOR Spalte := 1 TO xMatDim DO BEGIN
- Vektor[Spalte] := 0;
- FOR Zeile := 1 TO yMatDim DO
- Vektor[Spalte] := Vektor[Spalte] + Temp[Zeile] * TransMat[Zeile,Spalte]
- END
- END;
-
- (*-------------------------------------------------------------------------*)
- (* Ende GRAFMAT.PAS *)
-