CNLMath : Utilities : matrix_norm_coordinate
matrix_norm_coordinate
Computes various norms of a matrix stored in coordinate format.
Synopsis
#include <imsl.h>
float imsl_f_matrix_norm_coordinate (int m, int n, int nz, Imsl_f_sparse_elem a[], ..., 0)
The type double function is imsl_d_matrix_norm_coordinate.
Required Arguments
int m (Input)
The number of rows in matrix A.
int n (Input)
The number of columns in matrix A.
int nz (Input)
The number of nonzeros in the matrix A.
Imsl_f_sparse_elem a[] (Input)
Matrix for which the norm will be computed.
Return Value
The requested norm of the input matrix, by default, the Frobenius norm. If the norm cannot be computed, NaN is returned.
Synopsis with Optional Arguments
#include <imsl.h>
float imsl_f_matrix_norm_coordinate (int m, int n, int nz, Imsl_f_sparse_elem a[],
IMSL_ONE_NORM,
IMSL_INF_NORM,
IMSL_SYMMETRIC,
0)
Optional Arguments
IMSL_ONE_NORM,
Compute the 1-norm of matrix A.
IMSL_INF_NORM,
Compute the infinity norm of matrix A.
IMSL_SYMMETRIC,
Matrix A is stored in symmetric coordinate format.
Description
By default, imsl_f_matrix_norm_coordinate computes the Frobenius norm
If the option IMSL_ONE_NORM is selected, the 1-norm
is returned. If the option IMSL_INF_NORM is selected, the infinity norm
is returned.
Examples
Example 1
Compute the Frobenius norm, infinity norm, and one norm of matrix A. Matrix A is stored in coordinate format.
 
#include <imsl.h>
 
int main()
{
Imsl_f_sparse_elem a[] = {0, 0, 10.0,
1, 1, 10.0,
1, 2, -3.0,
1, 3, -1.0,
2, 2, 15.0,
3, 0, -2.0,
3, 3, 10.0,
3, 4, -1.0,
4, 0, -1.0,
4, 3, -5.0,
4, 4, 1.0,
4, 5, -3.0,
5, 0, -1.0,
5, 1, -2.0,
5, 5, 6.0};
int m = 6, n = 6;
int nz = 15;
float frobenius_norm, inf_norm, one_norm;
 
frobenius_norm = imsl_f_matrix_norm_coordinate (m, n, nz, a, 0);
 
inf_norm = imsl_f_matrix_norm_coordinate(m, n, nz, a,
IMSL_INF_NORM, 0);
 
one_norm = imsl_f_matrix_norm_coordinate(m, n, nz, a,
IMSL_ONE_NORM, 0);
 
printf("Frobenius norm = %f\n", frobenius_norm);
printf("Infinity norm = %f\n", inf_norm);
printf("One norm = %f\n", one_norm);
}
Output
 
Frobenius norm = 24.839485
Infinity norm = 15.000000
One norm = 18.000000
Example 2
Compute the Frobenius norm, infinity norm and one norm of matrix A. Matrix A is stored in symmetric coordinate format.
 
#include <imsl.h>
 
int main()
{
Imsl_f_sparse_elem a[] = {0, 0, 10.0,
0, 2, -1.0,
0, 5, 5.0,
1, 3, 2.0,
1, 4, 3.0,
2, 2, 3.0,
2, 5, 4.0,
4, 4, -1.0,
4, 5, 4.0};
int m = 6, n = 6;
int nz = 9;
float frobenius_norm, inf_norm, one_norm;
 
frobenius_norm = imsl_f_matrix_norm_coordinate (m, n, nz, a,
IMSL_SYMMETRIC, 0);
 
inf_norm = imsl_f_matrix_norm_coordinate(m, n, nz, a,
IMSL_INF_NORM,
IMSL_SYMMETRIC, 0);
 
one_norm = imsl_f_matrix_norm_coordinate(m, n, nz, a,
IMSL_ONE_NORM,
IMSL_SYMMETRIC, 0);
 
printf("Frobenius norm = %f\n", frobenius_norm);
printf("Infinity norm = %f\n", inf_norm);
printf("One norm = %f\n", one_norm);
}
Output
 
Frobenius norm = 15.874508
Infinity norm = 16.000000
One norm = 16.000000