Estimate 2-Norm of Sparse Matrix
Create a 5-by-5 sparse diagonal matrix.
S = sparse(1:5,1:5,1:5)
S = (1,1) 1 (2,2) 2 (3,3) 3 (4,4) 4 (5,5) 5
Estimate the 2-norm of the matrix
n = normest(S)
n = 5.0000
Estimate 2-Norm to Speed Up Calculation
Create a 1000-by-1000 matrix of uniformly distributed random numbers.
rng default S = rand(1000);
Evaluate the 2-norm of the matrix
S by using
norm. Measure the elapsed time with a pair of
ans = 500.4856
Elapsed time is 0.458821 seconds.
To speed up the 2-norm evaluation, estimate the 2-norm of
S by using
normest with a specified tolerance of
ans = 500.4856
Elapsed time is 0.052954 seconds.
Estimate 2-Norm and Return Number of Power Iterations
Create a 7-by-7 matrix.
S = gallery('clement',7,7)
S = 7×7 0 2.4495 0 0 0 0 0 2.4495 0 3.1623 0 0 0 0 0 3.1623 0 3.4641 0 0 0 0 0 3.4641 0 3.4641 0 0 0 0 0 3.4641 0 3.1623 0 0 0 0 0 3.1623 0 2.4495 0 0 0 0 0 2.4495 0
Estimate the 2-norm of the matrix and return the number of power iterations used in the computation.
[n,count] = normest(S)
n = 6.0000
count = 4
S — Input matrix
sparse matrix | full matrix
Input matrix, specified as a sparse or full matrix.
Complex Number Support: Yes
tol — Relative error tolerance
1e-6 (default) | nonnegative real number
Relative error tolerance, specified as a nonnegative real number. The value of
tol determines when the norm estimate is considered acceptable: the
iteration is performed until two successive estimates agree to within the specified
n — Matrix norm
Matrix norm, returned as a scalar.
NaN if the input contains
count — Number of power iterations
Number of power iterations used in estimating the 2-norm, returned as a nonnegative integer.
The power iteration involves repeated multiplication by the matrix
and its transpose,
S'. The iteration is performed until two successive norm
estimates agree to within the specified relative error tolerance.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Code generation does not support sparse matrix inputs for this function.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Introduced before R2006a