matAddBandComplex

Adds two band matrices, both in band storage mode, \(C\leftarrow\alpha A+\beta B\).

Synopsis

matAddBandComplex (nlca, nuca, alpha, a, nlcb, nucb, beta, b, nlcc, nucc)

Required Arguments

int nlca (Input)
Number of lower codiagonals of A.
int nuca (Input)
Number of upper codiagonals of A.
complex alpha (Input)
Scalar multiplier for A.
complex a[] (Input)
An n by n band matrix with nlca lower codiagonals and nuca upper codiagonals stored in band mode with dimension (nlca + nuca + 1) by n.
int nlcb (Input)
Number of lower codiagonals of B.
int nucb (Input)
Number of upper codiagonals of B.
complex beta (Input)
Scalar multiplier for B.
complex b[] (Input)
An n by n band matrix with nlcb lower codiagonals and nucb upper codiagonals stored in band mode with dimension (nlcb + nucb + 1) by n.
int nlcc (Output)
Number of lower codiagonals of C.
int nucc (Output)
Number of upper codiagonals of C.

Return Value

An array of type complex containing the computed sum. In the event of an error or if the return matrix has no nonzero elements, None is returned.

Optional Arguments

aTranspose,
Replace A with \(A^T\) in the expression \(\alpha A+\beta B\).
bTranspose,
Replace B with \(B^T\) in the expression \(\alpha A+\beta B\).
aConjugateTranspose,
Replace A with \(A^H\) in the expression \(\alpha A+\beta B\).
bConjugateTranspose,
Replace B with \(B^H\) in the expression \(\alpha A+\beta B\).
symmetric,
Matrix A, B, and C are stored in band symmetric storage mode.

Description

The function matAddBandComplex forms the sum αA + βB, given the scalars α and β, and the matrices A and B in band format. The transpose or conjugate transpose of A and/or B may be used during the computation if optional arguments are specified. Symmetric storage mode may be used if the optional argument is specified.

If symmetric is specified, the return value for the number of lower codiagonals, nlcc, will be equal to 0.

If the return matrix equals None, the return value for the number of lower codiagonals, nlcc, will be equal to -1 and the number of upper codiagonals, nucc, will be equal to 0.

Examples

Example 1

Add two complex matrices of order 4 stored in band mode. Matrix A has one upper codiagonal and one lower codiagonal. Matrix B has no upper codiagonals and two lower codiagonals.

from pyimsl.math.matAddBandComplex import matAddBandComplex
from pyimsl.math.writeMatrixComplex import writeMatrixComplex

a = [[0 + 0j, 2 + 1j, 3 + 3j, -1 + 0j],
     [1 + 1j, 1 + 3j, 1 - 2j, 1 + 5j],
     [0 + 0j, 3 - 2j, 4 + 0j, 0 + 0j]]
b = [[3 + 1j, 3 - 5j, 3 - 1j, 3 + 1j],
     [1 - 3j, -2 + 0j, 1 + 2j, 0 + 0j],
     [-1 + 4j, 2 + 1j, 0 + 0j, 0 + 0j]]
nucb = 0
nlcb = 2
nuca = 1
nlca = 1
n = 4
alpha = 1 + 0j
beta = 1 + 0j
nlcc = []
nucc = []

c = matAddBandComplex(nlca, nuca, alpha, a, nlcb, nucb, beta, b, nlcc, nucc)

m = nlcc[0] + nucc[0] + 1
writeMatrixComplex("C = A + B", c)

Output

 
                       C = A + B
                           1                          2
1  (          0,          0)  (          2,          1)
2  (          4,          2)  (          4,         -2)
3  (          1,         -3)  (          1,         -2)
4  (         -1,          4)  (          2,          1)
 
                           3                          4
1  (          3,          3)  (         -1,          0)
2  (          4,         -3)  (          4,          6)
3  (          5,          2)  (          0,          0)
4  (          0,          0)  (          0,          0)

Example 2

Compute

\[(3 + 2i)A^H + (4 + i) B^H\]

where

\[\begin{split}A = \begin{bmatrix} 2+3i & 1+3i & 0 & 0 \\ 0 & 6+2i & 3+i & 0 \\ 0 & 0 & 4+i & 2+5i \\ 0 & 0 & 0 & 1+2i \\ \end{bmatrix} \text{ and } B = \begin{bmatrix} 1+2i & 5+i & 0 & 0 \\ 4+i & 1+3i & 2+3i & 0 \\ 0 & 2+3i & 3+2i & 4+2i \\ 0 & 0 & 2+6i & 1+4i \\ \end{bmatrix}\end{split}\]
from pyimsl.math.matAddBandComplex import matAddBandComplex
from pyimsl.math.writeMatrixComplex import writeMatrixComplex

a = [[0 + 0j, 1 + 3j, 3 + 1j, 2 + 5j],
     [2 + 3j, 6 + 2j, 4 + 1j, 1 + 2j]]
b = [[0 + 0j, 5 + 1j, 2 + 3j, 4 + 2j],
     [1 + 2j, 1 + 3j, 3 + 2j, 1 + 4j],
     [4 + 1j, 2 + 3j, 2 + 6j, 0 + 0j]]
nucb = 1
nlcb = 1
nuca = 1
nlca = 0
n = 4
alpha = 3 + 2j
beta = 4 + 1j
nlcc = []
nucc = []

c = matAddBandComplex(nlca, nuca, alpha, a, nlcb, nucb, beta, b,
                      nlcc, nucc, aConjugateTranspose=True, bConjugateTranspose=True)

m = nlcc[0] + nucc[0] + 1
writeMatrixComplex("C = (3+2i)*ctrans(A) + (4+i)*ctrans(B)", c)

Output

 
        C = (3+2i)*ctrans(A) + (4+i)*ctrans(B)
                           1                          2
1  (          0,          0)  (         17,          0)
2  (         18,        -12)  (         29,         -5)
3  (         30,         -6)  (         22,         -7)
 
                           3                          4
1  (         11,        -10)  (         14,        -22)
2  (         28,          0)  (         15,        -19)
3  (         34,        -15)  (          0,          0)