Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_sparse_direct_real_gen_norm (f11ml)

Purpose

nag_sparse_direct_real_gen_norm (f11ml) computes the $1$-norm, the $\infty$-norm or the maximum absolute value of the elements of a real, square, sparse matrix which is held in compressed column (Harwell–Boeing) format.

Syntax

[anorm, ifail] = f11ml(norm_p, n, icolzp, irowix, a)
[anorm, ifail] = nag_sparse_direct_real_gen_norm(norm_p, n, icolzp, irowix, a)

Description

nag_sparse_direct_real_gen_norm (f11ml) computes various quantities relating to norms of a real, sparse $n$ by $n$ matrix $A$ presented in compressed column (Harwell–Boeing) format.

None.

Parameters

Compulsory Input Parameters

1:     $\mathrm{norm_p}$ – string (length ≥ 1)
Specifies the value to be returned in anorm.
${\mathbf{norm_p}}=\text{'1'}$ or $\text{'O'}$
The $1$-norm ${‖A‖}_{1}$ of the matrix is computed, that is $\underset{1\le j\le n}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\sum _{i=1}^{n}\left|{A}_{ij}\right|$.
${\mathbf{norm_p}}=\text{'I'}$
The $\infty$-norm ${‖A‖}_{\infty }$ of the matrix is computed, that is $\underset{1\le i\le n}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\sum _{j=1}^{n}\left|{A}_{ij}\right|$.
${\mathbf{norm_p}}=\text{'M'}$
The value $\underset{1\le i,j\le n}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left|{A}_{ij}\right|$ (not a norm).
Constraint: ${\mathbf{norm_p}}=\text{'1'}$, $\text{'O'}$, $\text{'I'}$ or $\text{'M'}$.
2:     $\mathrm{n}$int64int32nag_int scalar
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
3:     $\mathrm{icolzp}\left(:\right)$int64int32nag_int array
The dimension of the array icolzp must be at least ${\mathbf{n}}+1$
${\mathbf{icolzp}}\left(i\right)$ contains the index in $A$ of the start of a new column. See Compressed column storage (CCS) format in the F11 Chapter Introduction.
4:     $\mathrm{irowix}\left(:\right)$int64int32nag_int array
The dimension of the array irowix must be at least ${\mathbf{icolzp}}\left({\mathbf{n}}+1\right)-1$, the number of nonzeros of the sparse matrix $A$
The row index array of sparse matrix $A$.
5:     $\mathrm{a}\left(:\right)$ – double array
The dimension of the array a must be at least ${\mathbf{icolzp}}\left({\mathbf{n}}+1\right)-1$, the number of nonzeros of the sparse matrix $A$
The array of nonzero values in the sparse matrix $A$.

None.

Output Parameters

1:     $\mathrm{anorm}$ – double scalar
The computed quantity relating the matrix.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{norm_p}}=_$.
Constraint: ${\mathbf{norm_p}}=\text{'1'}$, $\text{'O'}$, $\text{'I'}$ or $\text{'M'}$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

Not applicable.

None.

Example

This example computes norms and maximum absolute value of the matrix $A$, where
 $A= 2.00 1.00 0 0 0 0 0 1.00 -1.00 0 4.00 0 1.00 0 1.00 0 0 0 1.00 2.00 0 -2.00 0 0 3.00 .$
```function f11ml_example

fprintf('f11ml example results\n\n');

% Norms of sparse A
n      = int64(5);
icolzp = [int64(1); 3; 5;  7; 9; 12];
irowix = [int64(1); 3; 1;  5; 2;  3;  2; 4; 3; 4; 5];
a      = [        2;  4; 1; -2; 1;  1; -1; 1; 1; 2; 3];

% Calculate 1-norm
norm_p = '1';
[anorm, ifail] = f11ml( ...
norm_p, n, icolzp, irowix, a);
fprintf('One-norm      = %7.3f\n', anorm);

% Calculate Maximum
norm_p = 'M';
[anorm, ifail] = f11ml( ...
norm_p, n, icolzp, irowix, a);
fprintf('Max           = %7.3f\n', anorm);

% Calculate I-norm
norm_p = 'I';
[anorm, ifail] = f11ml( ...
norm_p, n, icolzp, irowix, a);
fprintf('Infinity-norm = %7.3f\n', anorm);

```
```f11ml example results

One-norm      =   6.000
Max           =   4.000
Infinity-norm =   6.000
```