matMulRectComplex¶
Computes the transpose of a matrix, the conjugate-transpose of a matrix, a matrix-vector product, a matrix-matrix product, the bilinear form, or any triple product.
Synopsis¶
matMulRectComplex (string)
Required Arguments¶
- char
string
(Input) - String indicating matrix multiplication to be performed.
Return Value¶
The result of the multiplication. This is always a complex, even if the
result is a single number. If no answer was computed, then None
is
returned.
Optional Arguments¶
aMatrix
, complexa
(Input)- The
nrowa
×ncola
matrix A. bMatrix
, complexb
(Input)- The
nrowb
×ncolb
matrixB
. xVector
, complexx
(Input)- The vector x of size
nx
. yVector
, complexy
(Input)- The vector y of size
ny
.
Description¶
This function computes a matrix-vector product, a matrix-matrix product, a
bilinear form of a matrix, or a triple product according to the
specification given by string
. For example, if “A
× x
” is
given, Ax is computed. In string
, the matrices A and B and the
vectors x and y can be used. Any of these four names can be used with
trans
, indicating transpose, or with ctrans
, indicating conjugate
(or Hermitian) transpose. The vectors x and y are treated as n × 1
matrices.
If string
contains only one item, such as “x
” or
“trans(A)
”, then a copy of the array, or its transpose, is returned.
If string
contains one multiplication, such as “A
× x
” or
“B
× A
”, then the indicated product is returned. Some other
legal values for string
are “trans(y)
× A
”, “A
×
ctrans(B)
”, “x
× trans(y)
”, or “ctrans(x)
×
y
”.
The matrices and/or vectors referred to in string must be given as optional
arguments. If string
is “B
× x
”, then bMatrix
and
xVector
must be given.
Example¶
Let
The arrays \(A^H\), Ax, \(x^T A^T\), AB, \(B^H A^T\), \(x^Ty\), and \(xy^H\) are computed and printed.
from pyimsl.math.matMulRectComplex import matMulRectComplex
from pyimsl.math.writeMatrixComplex import writeMatrixComplex
from pyimsl.util.imslUtils import isLinux64
a = [[1 + 4j, 2 + 3j, 9 + 6j], [5 + 2j, 4 - 3j, 7 + 1j]]
b = [[3 - 6j, 2 + 4j], [7 + 3j, 4 - 5j], [9 + 2j, 1 + 3j]]
x = [7 + 4j, 2 + 2j, 1 - 5j]
y = [3 + 4j, 4 - 2j, 2 + 3j]
ans = matMulRectComplex("ctrans(A)", aMatrix=a)
writeMatrixComplex("ctrans(A)", ans)
ans = matMulRectComplex("A*x", aMatrix=a, xVector=x)
writeMatrixComplex("A*x", ans)
ans = matMulRectComplex("trans(x)*trans(A)", aMatrix=a, xVector=x)
writeMatrixComplex("trans(x)*trans(A)", ans)
ans = matMulRectComplex("A*B", aMatrix=a, bMatrix=b)
writeMatrixComplex("A*B", ans)
ans = matMulRectComplex("ctrans(B)*trans(A)", aMatrix=a, bMatrix=b)
writeMatrixComplex("ctrans(B)*trans(A)", ans)
if not isLinux64():
ans = matMulRectComplex("trans(x)*y", xVector=x, yVector=y)
writeMatrixComplex("trans(x)*y", ans)
ans = matMulRectComplex("x*ctrans(y)", xVector=x, yVector=y)
writeMatrixComplex("x*ctrans(y)", ans)
Output¶
ctrans(A)
1 2
1 ( 1, -4) ( 5, -2)
2 ( 2, -3) ( 4, 3)
3 ( 9, -6) ( 7, -1)
A*x
1 2
( 28, 3) ( 53, 2)
trans(x)*trans(A)
1 2
( 28, 3) ( 53, 2)
A*B
1 2
1 ( 101, 105) ( 0, 47)
2 ( 125, -10) ( 7, 14)
ctrans(B)*trans(A)
1 2
1 ( 95, 69) ( 87, -2)
2 ( 38, 5) ( 59, -28)
trans(x)*y
( 34, 37)
x*ctrans(y)
1 2
1 ( 37, -16) ( 20, 30)
2 ( 14, -2) ( 4, 12)
3 ( -17, -19) ( 14, -18)
3
1 ( 26, -13)
2 ( 10, -2)
3 ( -13, -13)