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_blast_dgb_norm (f16rb)

## Purpose

nag_blast_dgb_norm (f16rb) calculates the value of the $1$-norm, the $\infty$-norm, the Frobenius norm or the maximum absolute value of the elements of a real $m$ by $n$ band matrix stored in banded form.
It can also be used to compute the value of the $2$-norm of a row $n$-vector or a column $m$-vector.

## Syntax

[result] = f16rb(job, m, kl, ku, ab, 'n', n)
[result] = nag_blast_dgb_norm(job, m, kl, ku, ab, 'n', n)

## Description

Given a real $m$ by $n$ banded matrix, $A$, nag_blast_dgb_norm (f16rb) calculates one of the values given by
 ${‖A‖}_{1}=\underset{j}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\sum _{i=1}^{m}\left|{a}_{ij}\right|$ (the $1$-norm of $A$), ${‖A‖}_{\infty }=\underset{i}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\sum _{j=1}^{n}\left|{a}_{ij}\right|$ (the $\infty$-norm of $A$), ${‖A‖}_{F}={\left(\sum _{i=1}^{m}\sum _{j=1}^{n}{\left|{a}_{ij}\right|}^{2}\right)}^{1/2}$ (the Frobenius norm of $A$),   or $\underset{i,j}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left|{a}_{ij}\right|$ (the maximum absolute element value of $A$).
If $m$ or $n$ is $1$ then additionally nag_blast_dgb_norm (f16rb) can calculate the value ${‖A‖}_{2}=\sqrt{\sum {a}_{i}^{2}}$ (the $2$-norm of $A$).

## References

Basic Linear Algebra Subprograms Technical (BLAST) Forum (2001) Basic Linear Algebra Subprograms Technical (BLAST) Forum Standard University of Tennessee, Knoxville, Tennessee http://www.netlib.org/blas/blast-forum/blas-report.pdf

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{job}$ – string (length ≥ 1)
Specifies the value to be returned.
${\mathbf{job}}=\text{'O'}$
The $1$-norm.
${\mathbf{job}}=\text{'T'}$
The $2$-norm of a row or column vector.
${\mathbf{job}}=\text{'I'}$
The $\infty$-norm.
${\mathbf{job}}=\text{'F'}$
The Frobenius (or Euclidean) norm.
${\mathbf{job}}=\text{'M'}$
The value $\underset{i,j}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left|{a}_{ij}\right|$ (not a norm).
Constraints:
• ${\mathbf{job}}=\text{'O'}$, $\text{'T'}$, $\text{'I'}$, $\text{'F'}$ or $\text{'M'}$;
• if ${\mathbf{job}}=\text{'T'}$, ${\mathbf{m}}=1$ or ${\mathbf{n}}=1$.
2:     $\mathrm{m}$int64int32nag_int scalar
$m$, the number of rows of the matrix $A$. If ${\mathbf{m}}\le 0$ on input, nag_blast_dgb_norm (f16rb) returns $0$.
3:     $\mathrm{kl}$int64int32nag_int scalar
${k}_{l}$, the number of subdiagonals within the band of $A$. If ${\mathbf{kl}}\le 0$ on input, nag_blast_dgb_norm (f16rb) returns $0$.
4:     $\mathrm{ku}$int64int32nag_int scalar
${k}_{u}$, the number of superdiagonals within the band of $A$. If ${\mathbf{ku}}\le 0$ on input, nag_blast_dgb_norm (f16rb) returns $0$.
5:     $\mathrm{ab}\left(\mathit{ldab},:\right)$ – double array
The first dimension of the array ab must be at least ${\mathbf{kl}}+{\mathbf{ku}}+1$.
The second dimension of the array ab must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The $m$ by $n$ band matrix $A$.
The matrix is stored in rows $1$ to ${k}_{l}+{k}_{u}+1$, more precisely, the element ${A}_{ij}$ must be stored in
 $abku+1+i-jj for ​max1,j-ku≤i≤minm,j+kl.$

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the second dimension of the array ab.
$n$, the number of columns of the matrix $A$. If ${\mathbf{n}}\le 0$ on input, nag_blast_dgb_norm (f16rb) returns $0$.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.

## Error Indicators and Warnings

If any constraint on an input parameter is violated, an error message is printed and program execution is terminated.

## Accuracy

The BLAS standard requires accurate implementations which avoid unnecessary over/underflow (see Section 2.7 of Basic Linear Algebra Subprograms Technical (BLAST) Forum (2001)).

None.

## Example

Calculates the various norms of a $6$ by $4$ banded matrix with two subdiagonals and one superdiagonal.
```function f16rb_example

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

kl = int64(2);
ku = int64(2);
m  = int64(6);
a = [ 1, 1, 0, 0;
2, 2, 2, 0;
3, 3, 3, 3;
0, 4, 4, 4;
0, 0, 5, 5;
0, 0, 0, 6];
ab = zeros(5, 6);
% Convert a to packed storage
[a, ab, ifail] = f01zc( ...
'p', kl, ku, a, ab);

fprintf('\nNorms of banded matrix ab:\n\n');

r_one = f16rb('o', m, kl, ku, ab);
fprintf('One norm           = %9.4f\n', r_one);

r_inf = f16rb('i', m, kl, ku, ab);
fprintf('Infinity norm      = %9.4f\n', r_inf);

r_fro = f16rb('f', m, kl, ku, ab);
fprintf('Frobenious norm    = %9.4f\n', r_fro);

r_max = f16rb('m', m, kl, ku, ab);
fprintf('Maximum norm       = %9.4f\n', r_max);

```
```f16rb example results

Norms of banded matrix ab:

One norm           =   18.0000
Infinity norm      =   12.0000
Frobenious norm    =   13.5647
Maximum norm       =    6.0000
```