nag_matop_complex_addsub (f01cw) performs one of the operations
- ,
- ,
- ,
- ,
- ,
- ,
- ,
- or
- ,
where
,
and
are matrices,
and
are scalars,
denotes transposition and
denotes conjugate transposition. For efficiency, the function contains special code for the cases when one or both of
,
is equal to zero, unity or minus unity. The matrices, or their transposes, must be compatible for addition.
and
are either
by
or
by
matrices, depending on whether they are to be transposed before addition.
is an
by
matrix.
None.
None.
The time taken for a call of
nag_matop_complex_addsub (f01cw) varies with
m,
n and the values of
and
. The function is quickest if either or both of
and
are equal to zero, or plus or minus unity.
The following program reads in a pair of matrices
and
, along with values for
transa,
transb,
alpha and
beta, and adds them together, printing the result matrix
. The process is continued until the end of the input stream is reached.
function f01cw_example
fprintf('f01cw example results\n\n');
a = [ 1.0 + 2.0i 2.5 - 1.5i 2.5 - 1.0i;
-2.0 - 2.0i 2.0 - 1.0i -1.5 - 1.0i;
3.5 - 1.5i 2.0 + 1.5i 2.0 + 3.0i;
-2.5 + 0.0i -3.0 + 2.5i -2.0 + 2.0i];
b = [ 2.0 + 1.0i -2.5 + 3.0i -0.5 + 0.0i;
1.0 + 0.0i 1.0 - 1.5i 1.5 - 1.5i;
-1.5 - 0.5i 2.5 - 2.0i -0.5 + 1.0i;
2.5 - 1.5i -1.0 + 1.5i 2.0 + 3.0i];
[m,n] = size(a);
m = int64(m);
n = int64(n);
transa = 'N';
transb = 'N';
alpha = complex(1);
beta = complex(1);
[c1, ifail] = f01cw( ...
transa, transb, m, n, alpha, a, beta, b);
disp('Example 1: C = A + B');
disp(c1);
a = [ 1.0 + 1.0i 2.5 - 1.5i 3.0 + 1.5i;
-2.0 - 0.5i 2.0 + 1.5i -1.5 - 2.5i];
b = [ 2.0 + 1.0i -2.5 + 2.0i;
1.0 + 0.0i 1.0 + 1.5i;
-1.5 - 0.5i 2.5 - 1.0i];
[m,n] = size(a);
m = int64(m);
n = int64(n);
transa = 'N';
transb = 'T';
alpha = complex(1);
beta = complex(-1);
[c2, ifail] = f01cw( ...
transa, transb, m, n, alpha, a, beta, b);
disp('Example 2: C = A - B^T');
disp(c2);
f01cw example results
Example 1: C = A + B
3.0000 + 3.0000i 0.0000 + 1.5000i 2.0000 - 1.0000i
-1.0000 - 2.0000i 3.0000 - 2.5000i 0.0000 - 2.5000i
2.0000 - 2.0000i 4.5000 - 0.5000i 1.5000 + 4.0000i
0.0000 - 1.5000i -4.0000 + 4.0000i 0.0000 + 5.0000i
Example 2: C = A - B^T
-1.0000 + 0.0000i 1.5000 - 1.5000i 4.5000 + 2.0000i
0.5000 - 2.5000i 1.0000 + 0.0000i -4.0000 - 1.5000i