function exercise_1_6_3() % % % Written by: % -- % John L. Weatherwax 2006-03-28 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; load west0479; A = west0479; fprintf( 'The size of west0479 = (%d,%d)\n', size(A,1), size(A,2) ); fprintf( 'Number of non zeros of the matrix west0479 = %d\n', nnz(A) ); %issparse(A) figure; spy(A); title( 'west0479' ); A = A' * A; figure; spy(A); title( 'west0479'' * west0479' ); %issparse(A) fprintf( 'Number of non zeros of the matrix west0479'' * west0479 = %d\n', nnz(A) ); % Part (a): % tic, R = chol(A); t=toc; fprintf('Time to directly Cholesky factor west0479'' * west0479 = %f\n', t ); fprintf( 'Number of non zeros of the Cholesky factor of west0470'' * west0470 = %d\n', nnz(R) ); figure; spy(R); title( 'Cholesky factor of west0479'' * west0479' ); % Part (b): % p = randperm(479); arnd = A(p,p); figure; spy(arnd); title( 'Randomized version of west0479'' * west0479' ); tic, R = chol(arnd); t=toc; fprintf('Time to factor randomly Cholesky factor west0479'' * west0479 = %f\n', t ); fprintf( 'Number of non zeros of the Cholesky factor of west0470'' * west0470 = %d\n', nnz(R) ); figure; spy(R); title( 'Cholesky factor of randomized west0479'' * west0479' ); % Part (c): % p = symrcm(A); arcm = A(p,p); figure; spy(arcm); title( 'Reverse Cuthill-McKee ordered version of west0479'' * west0479' ); tic, R = chol(arcm); t=toc; fprintf('Time to factor the reverse Cuthill-McKee ordered Cholesky factor west0479'' * west0479 = %f\n', t ); fprintf( 'Number of non zeros of the Cholesky factor of west0470'' * west0470 = %d\n', nnz(R) ); figure; spy(R); title( 'Cholesky factor of reverse cuthill-mckey ordered west0479'' * west0479' ); % Part (d): % p = symmmd(A); ammd = A(p,p); figure; spy(ammd); title( 'Minimum degree ordering of west0479'' * west0479' ); tic, R = chol(ammd); t=toc; fprintf('Time to factor the minimum degree ordering Cholesky factor west0479'' * west0479 = %f\n', t ); fprintf( 'Number of non zeros of the Cholesky factor of west0470'' * west0470 = %d\n', nnz(R) ); figure; spy(R); title( 'Cholesky factor of the minimum degree ordering of west0479'' * west0479' );