Vektoren und Matrizen 2008-11-26 14:10:03 with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; procedure Vektor_Matrix is type Vektor is array (Positive range <>) of Float; type Matrix is array (Positive range <>, Positive range <>) of Float; Dimensions_Dont_Match : exception; -- a) Ausgabe eines Vektors procedure Put (V : Vektor) is begin null; end; -- b) Ausgabe einer Matrix procedure Put (M : Matrix) is begin null; end; -- c) Anzahl der Komponenten function Groesse (V : Vektor) return Natural is begin null; end; -- d) Summe aller Komponenten function Sum (V : Vektor) return Float is begin null; end; -- e) Prueft ob zwei Vektoren den gleichen Range haben (First und Last) function Same_Range (V1, V2 : Vektor) return Boolean is begin null; end; -- f) Multiplikation eines Skalars mit einem Vektor function "*" (Scalar : Float; V : Vektor) return Vektor is Res : Vektor (V'Range); begin null; end; -- g) Addition zweier Vektoren function "+" (V1, V2 : Vektor) return Vektor is Res : Vektor (V1'Range); begin null; end; -- h) Skalarprodukt zweier Vektoren -- (Summe der komponentenweisen Multiplikation) function "*" (V1, V2 : Vektor) return Float is Res : Float; begin null; end; -- Matrix -- i) Prueft ob die Matrix quadratisch ist (Groesse der Dimensionen gleich) function Is_Quad (M : Matrix) return Boolean is begin null; end; -- j) Spur einer Matrix (Summe der Diagonale), nur fuer Matrizen -- deren range in beiden Dimensionen gleich ist. function Spur (M : Matrix) return Float is Res : Float; begin null; end; -- k) Multiplikation von Skalar mit Matrix function "*" (Scalar : Float; M : Matrix) return Matrix is Res : Matrix (M'Range (1), M'Range (2)); begin null; end; -- l) Multiplikation von Matrix mit Vektor function "*" (M : Matrix; V : Vektor) return Vektor is Res : Vektor (M'Range (1)); begin null; end; -- m) Addition zweier Matrizen function "+" (M1, M2 : Matrix) return Matrix is Res : Matrix (M1'Range (1), M1'Range (2)); begin null; end; -- n) Multiplikation zweier Matrizen; der 2. range von der 1. und der -- 1. range von der 2. matrix muessen gleich sein function "*" (M1, M2 : Matrix) return Matrix is Res : Matrix (M1'Range (1), M2'Range (2)); begin null; end; V1 : Vektor := (1.0, 222.0); M1 : Matrix := ((1.0, 2.0), (3.0, 4.0)); -- Testprogramm begin null; end Vektor_Matrix;