hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_sparse_direct_real_gen_matmul (f11mk)

Purpose

nag_sparse_direct_real_gen_matmul (f11mk) computes a matrix-matrix or transposed matrix-matrix product involving a real, square, sparse nonsymmetric matrix stored in compressed column (Harwell–Boeing) format.

Syntax

[c, ifail] = f11mk(trans, alpha, icolzp, irowix, a, b, beta, c, 'n', n, 'm', m)
[c, ifail] = nag_sparse_direct_real_gen_matmul(trans, alpha, icolzp, irowix, a, b, beta, c, 'n', n, 'm', m)

Description

nag_sparse_direct_real_gen_matmul (f11mk) computes either the matrix-matrix product CαAB + βCCαAB+βC, or the transposed matrix-matrix product CαATB + βCCαATB + βC, according to the value of the parameter trans, where AA is a real nn by nn sparse nonsymmetric matrix, of arbitrary sparsity pattern with nnznnz nonzero elements, BB and CC are nn by mm real dense matrices. The matrix AA is stored in compressed column (Harwell–Boeing) storage format. The array a stores all nonzero elements of AA, while arrays icolzp and irowix store the compressed column indices and row indices of AA respectively.

References

None.

Parameters

Compulsory Input Parameters

1:     trans – string (length ≥ 1)
Specifies whether or not the matrix AA is transposed.
trans = 'N'trans='N'
αAB + βCαAB+βC is computed.
trans = 'T'trans='T'
αATB + βCαATB+βC is computed.
Constraint: trans = 'N'trans='N' or 'T''T'.
2:     alpha – double scalar
αα, the scalar factor in the matrix multiplication.
3:     icolzp( : :) – int64int32nag_int array
Note: the dimension of the array icolzp must be at least n + 1n+1.
icolzp(i)icolzpi contains the index in AA of the start of a new column. See Section [Compressed column storage (CCS) format] in the F11 Chapter Introduction.
4:     irowix( : :) – int64int32nag_int array
Note: the dimension of the array irowix must be at least icolzp(n + 1)1icolzpn+1-1, the number of nonzeros of the sparse matrix AA.
The row index array of sparse matrix AA.
5:     a( : :) – double array
Note: the dimension of the array a must be at least icolzp(n + 1)1icolzpn+1-1, the number of nonzeros of the sparse matrix AA.
The array of nonzero values in the sparse matrix AA.
6:     b(ldb, : :) – double array
The first dimension of the array b must be at least max (1,n)max(1,n)
The second dimension of the array must be at least max (1,m)max(1,m)
The nn by mm matrix BB.
7:     beta – double scalar
The scalar factor ββ.
8:     c(ldc, : :) – double array
The first dimension of the array c must be at least max (1,n)max(1,n)
The second dimension of the array must be at least max (1,m)max(1,m)
The nn by mm matrix CC.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the arrays b, c. (An error is raised if these dimensions are not equal.)
nn, the order of the matrix AA.
Constraint: n0n0.
2:     m – int64int32nag_int scalar
Default: The second dimension of the arrays b, c. (An error is raised if these dimensions are not equal.)
mm, the number of columns of matrices BB and CC.
Constraint: m0m0.

Input Parameters Omitted from the MATLAB Interface

ldb ldc

Output Parameters

1:     c(ldc, : :) – double array
The first dimension of the array c will be max (1,n)max(1,n)
The second dimension of the array will be max (1,m)max(1,m)
ldcmax (1,n)ldcmax(1,n).
CC stores αAB + βCαAB+βC or αATB + βCαATB +βC depending on the value of trans.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,trans'N'trans'N' or 'T''T',
orn < 0n<0,
orm < 0m<0,
orldb < max (1,n)ldb<max(1,n),
orldc < max (1,n)ldc<max(1,n).

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_sparse_direct_real_gen_matmul_example
alpha = 1;
beta = 0;
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];
b = [0.7, 1.4;
     0.16, 0.32;
     0.52, 1.04;
     0.77, 1.54;
     0.28, 0.56];
c = [0, 0;
     0, 0;
     0, 0;
     0, 0;
     0, 0];

% Calculate matrix-matrix product
trans = 'N';
[c, ifail] = nag_sparse_direct_real_gen_matmul(trans, alpha, icolzp, irowix, a, b, beta, c);
fprintf('\nMatrix-matrix product:\n');
disp(c);

% Calculate transposed matrix-matrix product
trans = 'T';
[c, ifail] = nag_sparse_direct_real_gen_matmul(trans, alpha, icolzp, irowix, a, b, beta, c);
fprintf('\nTransposed matrix-matrix product:\n');
disp(c);
 

Matrix-matrix product:
    1.5600    3.1200
   -0.2500   -0.5000
    3.6000    7.2000
    1.3300    2.6600
    0.5200    1.0400


Transposed matrix-matrix product:
    3.4800    6.9600
    0.1400    0.2800
    0.6800    1.3600
    0.6100    1.2200
    2.9000    5.8000


function f11mk_example
alpha = 1;
beta = 0;
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];
b = [0.7, 1.4;
     0.16, 0.32;
     0.52, 1.04;
     0.77, 1.54;
     0.28, 0.56];
c = [0, 0;
     0, 0;
     0, 0;
     0, 0;
     0, 0];

% Calculate matrix-matrix product
trans = 'N';
[c, ifail] = f11mk(trans, alpha, icolzp, irowix, a, b, beta, c);
fprintf('\nMatrix-matrix product:\n');
disp(c);

% Calculate transposed matrix-matrix product
trans = 'T';
[c, ifail] = f11mk(trans, alpha, icolzp, irowix, a, b, beta, c);
fprintf('\nTransposed matrix-matrix product:\n');
disp(c);
 

Matrix-matrix product:
    1.5600    3.1200
   -0.2500   -0.5000
    3.6000    7.2000
    1.3300    2.6600
    0.5200    1.0400


Transposed matrix-matrix product:
    3.4800    6.9600
    0.1400    0.2800
    0.6800    1.3600
    0.6100    1.2200
    2.9000    5.8000



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013