condest.Rd“Estimate”, i.e. compute approximately the CONDition number of
a (potentially large, often sparse) matrix A.
It works by apply a fast randomized approximation of the 1-norm,
norm(A,"1"), through onenormest(.).
a square matrix, optional for onenormest(), where
instead of A, A.x and At.x can be specified,
see there.
number of columns to use in the iterations.
number; (an estimate of) the 1-norm of A, by
default norm(A, "1"); may be replaced by an estimate.
logical indicating if warning and (by default) convergence messages should be displayed.
logical indicating if convergence messages should be displayed.
when A is missing, these two must be given as
functions which compute A %% x, or t(A) %% x,
respectively.
== nrow(A), only needed when A is not specified.
maximal number of iterations for the 1-norm estimator.
the relative change that is deemed irrelevant.
condest() calls lu(A), and subsequently
onenormest(A.x = , At.x = ) to compute an approximate norm of
the inverse of A, \(A^{-1}\), in a way which
keeps using sparse matrices efficiently when A is sparse.
Note that onenormest() uses random vectors and hence
both functions' results are random, i.e., depend on the random
seed, see, e.g., set.seed().
Both functions return a list;
condest() with components,
a number \(> 0\), the estimated (1-norm) condition number
\(\hat\kappa\); when \(r :=\)rcond(A),
\(1/\hat\kappa \approx r\).
the maximal \(A x\) column, scaled to norm(v) = 1.
Consequently, \(norm(A v) = norm(A) / est\);
when est is large, v is an approximate null vector.
The function onenormest() returns a list with components,
a number \(> 0\), the estimated norm(A, "1").
0-1 integer vector length n, with an 1 at the index
j with maximal column A[,j] in \(A\).
numeric vector, the largest \(A x\) found.
the number of iterations used.
Nicholas J. Higham and Françoise Tisseur (2000). A Block Algorithm for Matrix 1-Norm Estimation, with an Application to 1-Norm Pseudospectra. SIAM J. Matrix Anal. Appl. 21, 4, 1185–1201.
William W. Hager (1984). Condition Estimates. SIAM J. Sci. Stat. Comput. 5, 311–316.
data(KNex, package = "Matrix")
mtm <- with(KNex, crossprod(mm))
system.time(ce <- condest(mtm))
#> user system elapsed
#> 0.025 0.000 0.026
sum(abs(ce$v)) ## || v ||_1 == 1
#> [1] 1
## Prove that || A v || = || A || / est (as ||v|| = 1):
stopifnot(all.equal(norm(mtm %*% ce$v),
norm(mtm) / ce$est))
## reciprocal
1 / ce$est
#> [1] 8.123888e-06
system.time(rc <- rcond(mtm)) # takes ca 3 x longer
#> Warning: 'rcond' via sparse -> dense coercion
#> user system elapsed
#> 0.031 0.036 0.026
rc
#> [1] 2.104775e-05
all.equal(rc, 1/ce$est) # TRUE -- the approximation was good
#> [1] "Mean relative difference: 0.6140259"
one <- onenormest(mtm)
str(one) ## est = 12.3
#> List of 4
#> $ est : num 12.3
#> $ v : int [1:712] 0 0 0 1 0 0 0 0 0 0 ...
#> $ w : num [1:712] 0.036 0 0.0433 0.0375 0 ...
#> $ iter: int 3
## the maximal column:
which(one$v == 1) # mostly 4, rarely 1, depending on random seed
#> [1] 4