You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

full_test_counter.m 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. addpath solver
  2. addpath solver/hss
  3. addpath solver/counter
  4. addpath tools
  5. num_trials = 20;
  6. n = 100;
  7. radius = 3;
  8. num_rand_vectors = 1;
  9. num_points = 10;
  10. origin = complex(4, -7);
  11. region = CSquareRegion(real(origin), imag(origin), (1 / sqrt(2)) * radius);
  12. % hss_block_row_size = 10;
  13. % tol = 1e-2;
  14. threshold = 60;
  15. correct = 0;
  16. for trial = 1:num_trials
  17. A = TestMatrix(n);
  18. E = eig(A);
  19. num_eigs = sum(abs(E - origin) <= radius);
  20. fprintf('(%d) actual number of eigenvalues with radius %d centered at %s: %d\n', trial, radius, num2str(origin), num_eigs);
  21. % [hss_tree, m] = npart(n, hss_block_row_size);
  22. % [D, U, R, B, W, V, nflops] = mat2hss(A, hss_tree, m, 'tol', tol);
  23. % [count_estimate, num_iters] = Eigencounter(D, U, R, B, W, V, hss_tree, hss_block_row_size, n, threshold, region, num_rand_vectors, num_points);
  24. [count_estimate, num_iters] = Eigencounter(A, n, threshold, region, num_rand_vectors, num_points);
  25. fprintf('(%d) estimated number of eigenvalues: %s\tmagnitude: %f\n', trial, num2str(count_estimate), abs(count_estimate));
  26. fprintf('(%d) number of iterations: %d\n', trial, num_iters);
  27. if round(abs(count_estimate)) == num_eigs
  28. correct = correct + 1;
  29. end
  30. end
  31. fprintf('error rate: %f\n', 1 - correct / num_trials);