Routines to perform basic matrix operations.
The routines LAL<datatype>MatrixMultiply()
perform matrix multiplication, contracting the columns of *in1
against the rows of *in2
, and storing the result in *out
. The number of columns of *in1
must equal the number of rows of *in2
, and *out
must have the same number of columns as *in1
and the same number of rows as *in2
.
The routines LAL<datatype>MatrixTranspose()
take the transpose of the matrix *in
and store the result in *out
. The number of rows of *out
must equal the number of columns of *in
, and vice-versa.
The prototype templates above in fact refer to several separate routines each, corresponding to different numerical atomic datatypes <datatype>
referred to by <typecode>
:
<typecode> | <datatype> | <typecode> | <datatype> |
---|---|---|---|
D | REAL8 |
The matrix product \(\mathsf{Z}^a{}_b=\mathsf{X}^a{}_c \mathsf{Y}^c{}_b\) of two matrices \(\mathsf{X}^a{}_c\) and \(\mathsf{Y}^c{}_b\) is given by the element formula \(Z^i{}_j=\sum_{k=1}^N X^i{}_k Y^k{}_j\), where \(N\) is the number of columns of \(\mathsf{X}^a{}_c\) and the number of rows of \(\mathsf{Y}^c{}_b\). This can also be used to compute the inner product of two vectors \(\mathsf{x}^a\) and \(\mathsf{y}^a\): simply store the transpose \((\mathsf{x}^T)_a\) as a row vector (single-row matrix) as the first operand, and \(\mathsf{y}^a\) as a column vector (single-column matrix) as the second operand. To compute the vector outer product, simply transpose the second argument rather than the first. These computations involve \(N\) additions and multiplications per element of the output matrix.
The transpose \((\mathsf{X}^T){}^a{}_b\) of a matrix \(\mathsf{X}^a{}_b\) is given by \((X^T){}^i{}_j=X^j{}_i\). Transposition involves no arithmetic operations, just one assignment per element of the output.
Prototypes | |
void | LALDMatrixMultiply (LALStatus *, REAL8Array *out, REAL8Array *in1, REAL8Array *in2) |
void | LALDMatrixTranspose (LALStatus *, REAL8Array *out, REAL8Array *in1) |
void LALDMatrixMultiply | ( | LALStatus * | stat, |
REAL8Array * | out, | ||
REAL8Array * | in1, | ||
REAL8Array * | in2 | ||
) |
Definition at line 71 of file MatrixOps.c.
void LALDMatrixTranspose | ( | LALStatus * | stat, |
REAL8Array * | out, | ||
REAL8Array * | in1 | ||
) |
Definition at line 128 of file MatrixOps.c.