% Angewandte Numerik 1, SoSe 2014 % Uebungsblatt 02, Aufgabe 15: Cholesky-Zerlegung % % Testprogramm fuer die Funktion L = cholesky(A) clear all; close all; clc; tol = 1e-12; %% Testfall 1 A = [2 6 -2; 6 21 0; -2 0 16]; L = cholesky(A); err = max(max(abs(L*L'-A))); if (err < tol) fprintf('Testfall 1: Bestanden.\n'); else fprintf(2,'Testfall 1: Fehlgeschlagen.\n'); end %% Testfall 2 A = hilb(10); L = cholesky(A); err = max(max(abs(L*L'-A))); if (err < tol) fprintf('Testfall 2: Bestanden.\n'); else fprintf(2,'Testfall 2: Fehlgeschlagen.\n'); end %% Testfall 3 A = rand(35); A = A+A'; A = A+(norm(A,1)+norm(A,Inf))*eye(35); L = cholesky(A); err = max(max(abs(L*L'-A))); if (err < tol) fprintf('Testfall 3: Bestanden.\n'); else fprintf(2,'Testfall 3: Fehlgeschlagen.\n'); end