void vsip_mprodt_f(const vsip_mview_f *a, const vsip_mview_f *b, const vsip_mview_f *r); void vsip_cmprodt_f(const vsip_cmview_f *a, const vsip_cmview_f *b, const vsip_cmview_f *r);
This function computes the product of matrix
and the transpose of matrix
, storing the result in matrix
. The operation
performed is:

for all
and
, where
is an
matrix,
is an
matrix, and
is the resulting
matrix.
This operation is equivalent to the matrix product
.
const vsip_dmview_p* a: First input matrix of size
.
const vsip_dmview_p* b: Second input matrix of size
(will be transposed in the operation).
const vsip_dmview_p* r: Output matrix of size
that will store the result.
vsip_mview_f *A, *B, *R; vsip_length m = 3, n = 4, p = 2; // Create matrices A = vsip_mcreate_f(m, n, VSIP_ROW, VSIP_MEM_NONE); // 3x4 matrix B = vsip_mcreate_f(p, n, VSIP_ROW, VSIP_MEM_NONE); // 2x4 matrix R = vsip_mcreate_f(m, p, VSIP_ROW, VSIP_MEM_NONE); // 3x2 result matrix // Initialize matrices A and B with some values // Initialize matrix A (3x4) for (vsip_index i = 0; i < m; i++) { for (vsip_index j = 0; j < n; j++) { vsip_mput_f(A, i, j, (float)(i*n + j + 1)); } } // Initialize matrix B (2x4) for (vsip_index i = 0; i < p; i++) { for (vsip_index j = 0; j < n; j++) { vsip_mput_f(B, i, j, (float)(i*n + j + 1)); } } // Compute matrix product with transposition: R = A * B^T vsip_mprodt_f(A, B, R); // Print the matrices printf("Matrix A (%lux%lu):\n", m, n); for (vsip_index i = 0; i < m; i++) { for (vsip_index j = 0; j < n; j++) { printf("%8.2f ", vsip_mget_f(A, i, j)); } printf("\n"); } printf("\nMatrix B (%lux%lu):\n", p, n); for (vsip_index i = 0; i < p; i++) { for (vsip_index j = 0; j < n; j++) { printf("%8.2f ", vsip_mget_f(B, i, j)); } printf("\n"); } printf("\nResult matrix R = A * B^T (%lux%lu):\n", m, p); for (vsip_index i = 0; i < m; i++) { for (vsip_index j = 0; j < p; j++) { printf("%8.2f ", vsip_mget_f(R, i, j)); } printf("\n"); } // Clean up vsip_malldestroy_f(A); vsip_malldestroy_f(B); vsip_malldestroy_f(R);
The input matrices must have compatible dimensions: Both
and
must have the same number of columns
(
).
The output matrix
must have dimensions
, where
is the number of rows in
and
is the number of
rows in
.
This operation is equivalent to computing the covariance matrix when
and
contain centered data.
If you need more flexibility in choosing which matrix to transpose, consider using vsip_dgemp_p instead.