Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fe_tester()
- N = [10, 30, 50, 70, 100, 300, 500, 700, 1000];
- D = [0.05, 0.1, 0.15, 0.2, 0.25, 0.3];
- for n = N
- for d = D
- data_count = d * n * n;
- if data_count < n
- display("impossible to create invertible matrix");
- display(n);
- display(d);
- display("");
- continue;
- endif
- A = sprand(n, n, d);
- A = full(A);
- A = tril(A);
- A = A + eye(n); % Make sure matrix is invertible
- [cidx, ridx, data] = full_to_csr(A);
- x = rand(n, 1);
- b = A * x;
- tic();
- x_sparse = sparse_fe(cidx, ridx, data, b);
- elapsed_time = toc();
- tic();
- x_full = forward_elim(A, b);
- full_elapsed_time = toc();
- display(norm(x - x_sparse));
- display(n);
- display(d);
- display(elapsed_time);
- display(full_elapsed_time);
- display(full_elapsed_time - elapsed_time);
- display("");
- endfor
- endfor
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement