function [score, time] = harness1(n) % HARNESS1 : Test and validation harness for homework 1 % % [score, time] = harness1(n); % % This generates an n-by-n matrix (default n=100), % runs an external "powermethod" routine to estimate its % dominant eigenvalue, and reports timing and accuracy. % % John R. Gilbert 13 Jan 2006 if nargin < 1 n = 100; end; niters = 1000; % We always do 1000 iterations for evaluation. fprintf('Matlab test harness for CS240A Homework 1.\n'); fprintf('Number of processors = 1 (sequential Matlab code)\n'); fprintf('Matrix dimension = %d\n', n); fprintf('Number of power iterations = %d\n', niters); [A,xinitial] = genmatrix1(n); tic; lambda = powermethod(A, xinitial, niters); time = toc; fprintf('Elapsed time = %d\n', time); fprintf('Computed eigenvalue = %d\n', lambda); score = validate1(n, lambda); if score == 1 fprintf('Answer is close enough.\n'); else fprintf('Answer is not close enough.\n'); end;