matMulRectBandComplex¶
Computes the transpose of a matrix, a matrix-vector product, or a matrix-matrix product for all matrices of complex type and stored in band form.
Synopsis¶
matMulRectBandComplex (string)
Required Arguments¶
- char
string
(Input) - String indicating matrix multiplication to be performed.
Return Value¶
The result of the multiplication is returned.
Optional Arguments¶
aMatrix
, intnrowa
, intncola
, intnlca
, intnuca
, complexa
(Input)- The sparse matrix
bMatrix
, intnrowb
, intncolb
, intnlcb
, intnucb
, complexb
(Input)- The sparse matrix
xVector
, intnx
, complexx
, (Input)- The vector x of length
nx
. returnMatrixCodiagonals
, intnlc_result
, intnuc_result
, (Output)- If the function
matMulRectBandComplex
returns data for a band matrix, use this option to retrieve the number of lower and upper codiagonals of the return matrix.
Description¶
The function matMulRectBandComplex
computes a matrix-matrix product or a
matrix‑vector product, where the matrices are specified in band format. The
operation performed is specified by string
. For example, if
“A*x
” is given, Ax is computed. In string
, the matrices A
and B and the vector x can be used. Any of these names can be used with
trans
, indicating transpose. The vector x is treated as a dense n ×
1 matrix. If string
contains only one item, such as “x
” or
“trans(A)
”, then a copy of the array, or its transpose is returned.
The matrices and/or vector referred to in string must be given as optional
arguments. Therefore, if string
is “A*x
”, then aMatrix
and
xVector
must be given.
Examples¶
Example 1¶
Let
and
This example computes the product Ax.
from pyimsl.math.matMulRectBandComplex import matMulRectBandComplex
from pyimsl.math.writeMatrixComplex import writeMatrixComplex
n = 4
nlca = 1
nuca = 1
# Note that a is in band storage mode
a = [[0 + 0j, 4 + 0j, -2 + 2j, -4 - 1j],
[-2 - 3j, -.5 + 3j, 3 - 3j, 1 - 1j],
[6 + 1j, 1 + 1j, 0 + 2j, 0 + 0j]]
x = [3 + 0j, -1 + 1j, 3 + 0j, -1 + 1j]
# Set b = A*x
b = matMulRectBandComplex(
"A*x", aMatrix={'nrowa': n, 'ncola': n, 'nlca': nlca, 'nuca': nuca, 'a': a}, xVector=x)
writeMatrixComplex("Product, Ax", b)
Output¶
Product, Ax
1 2
( -10.0, -5.0) ( 9.5, 5.5)
3 4
( 12.0, -12.0) ( 0.0, 8.0)
Example 2¶
Using the same matrix A and vector x given in the last example, the products Ax, \(A^Tx\), \(A^Hx\) and \(AA^H\) are computed.
from pyimsl.math.matMulRectBandComplex import matMulRectBandComplex
from pyimsl.math.writeMatrixComplex import writeMatrixComplex
n = 4
nlca = 1
nuca = 1
# Note that a is in band storage mode
a = [[0 + 0j, 4 + 0j, -2 + 2j, -4 - 1j],
[-2 - 3j, -.5 + 3j, 3 - 3j, 1 - 1j],
[6 + 1j, 1 + 1j, 0 + 2j, 0 + 0j]]
x = [3 + 0j, -1 + 1j, 3 + 0j, -1 + 1j]
# Set b = A*x
b = matMulRectBandComplex(
"A*x", aMatrix={'nrowa': n, 'ncola': n, 'nlca': nlca, 'nuca': nuca, 'a': a}, xVector=x)
writeMatrixComplex("Product, Ax", b)
# Set b = trans(A)*x
b = matMulRectBandComplex(
"trans(A)*x", aMatrix={'nrowa': n, 'ncola': n, 'nlca': nlca, 'nuca': nuca, 'a': a}, xVector=x)
writeMatrixComplex("trans(A)*x", b)
# Set b = ctrans(A)*x
b = matMulRectBandComplex(
"ctrans(A)*x", aMatrix={'nrowa': n, 'ncola': n, 'nlca': nlca, 'nuca': nuca, 'a': a}, xVector=x)
writeMatrixComplex("ctrans(A)*x", b)
# Set z = A*ctrans(A
codiags = []
b = matMulRectBandComplex("A*ctrans(A)", aMatrix={'nrowa': n, 'ncola': n,
'nlca': nlca, 'nuca': nuca, 'a': a}, returnMatrixCodiagonals=codiags)
writeMatrixComplex("A*ctrans(A)", b)
Output¶
Product, Ax
1 2
( -10.0, -5.0) ( 9.5, 5.5)
3 4
( 12.0, -12.0) ( 0.0, 8.0)
trans(A)*x
1 2
( -13.0, -4.0) ( 12.5, -0.5)
3 4
( 7.0, -15.0) ( -12.0, -1.0)
ctrans(A)*x
1 2
( -11.0, 16.0) ( 18.5, -0.5)
3 4
( 15.0, 11.0) ( -14.0, 3.0)
A*ctrans(A)
1 2
1 ( 0.00, 0.00) ( 0.00, 0.00)
2 ( 0.00, 0.00) ( -17.00, -28.00)
3 ( 29.00, 0.00) ( 54.25, 0.00)
4 ( -17.00, 28.00) ( -9.50, -3.50)
5 ( 4.00, 4.00) ( 4.00, -4.00)
3 4
1 ( 4.00, -4.00) ( 4.00, 4.00)
2 ( -9.50, 3.50) ( -9.00, -11.00)
3 ( 37.00, 0.00) ( 6.00, 0.00)
4 ( -9.00, 11.00) ( 0.00, 0.00)
5 ( 0.00, 0.00) ( 0.00, 0.00)