Skip to content

Commit

Permalink
Added timings to LUStability scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
drreynolds committed Feb 10, 2021
1 parent a65a4f8 commit 0f4de61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LUFactorization/LUStability.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,23 @@

% test LUPFactors_simple
fprintf(' LUPFactors_simple:\n');
ts = tic;
[L,U,P] = LUPFactors_simple(A);
fprintf(' runtime = %g\n', toc(ts))
fprintf(' norm(A - P^T L U) = %9.2e\n', norm(A - P'*L*U));

% test LUPFactors
fprintf(' LUPFactors:\n');
ts = tic;
[L,U,P] = LUPFactors(A);
fprintf(' runtime = %g\n', toc(ts))
fprintf(' norm(A - P^T L U) = %9.2e\n', norm(A - P'*L*U));

% test LUPPFactors
fprintf(' LUPPFactors:\n');
ts = tic;
[L,U,P1,P2] = LUPPFactors(A);
fprintf(' runtime = %g\n', toc(ts))
fprintf(' norm(A - P1^T L U P2^T) = %9.2e\n', norm(A - P1'*L*U*P2'));

end
7 changes: 7 additions & 0 deletions LUFactorization/LUStability.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# imports
import numpy
import time
from LUPFactors_simple import LUPFactors_simple
from LUPFactors import LUPFactors
from LUPPFactors import LUPPFactors
Expand All @@ -31,17 +32,23 @@

# test LUPFactors_simple
print(" LUPFactors_simple:")
ts = time.time()
L, U, P = LUPFactors_simple(A)
print(" runtime = ", time.time()-ts)
print(" norm(A - P^T L U) = ", numpy.linalg.norm(A - P.T@L@U))

# test LUPFactors
print(" LUPFactors:")
ts = time.time()
L, U, P = LUPFactors(A)
print(" runtime = ", time.time()-ts)
print(" norm(A - P^T L U) = ", numpy.linalg.norm(A - P.T@L@U))

# test LUPPFactors
print(" LUPPFactors:")
ts = time.time()
L, U, P1, P2 = LUPPFactors(A)
print(" runtime = ", time.time()-ts)
print(" norm(A - P1^T L U P2^T) = ", numpy.linalg.norm(A - P1.T@L@U@P2.T))

# end of script

0 comments on commit 0f4de61

Please sign in to comment.