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

for all
and
, where
is an
matrix,
is an
matrix, and
is the resulting
matrix.
const vsip_dmview_p* a: First input matrix of size
.
const vsip_dmview_p* b: Second input matrix of size
.
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 = 2, p = 4; // Create matrices A = vsip_mcreate_f(m, n, VSIP_ROW, VSIP_MEM_NONE); B = vsip_mcreate_f(n, p, VSIP_ROW, VSIP_MEM_NONE); R = vsip_mcreate_f(m, p, VSIP_ROW, VSIP_MEM_NONE); // Initialize matrices A and B with some values // Initialize matrix A (3x2) 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 < n; i++) { for (vsip_index j = 0; j < p; j++) { vsip_mput_f(B, i, j, (float)(i*p + j + 1)); } } // Compute matrix product: R = A * B vsip_mprod_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", n, p); for (vsip_index i = 0; i < n; i++) { for (vsip_index j = 0; j < p; j++) { printf("%8.2f ", vsip_mget_f(B, i, j)); } printf("\n"); } printf("\nResult matrix R (%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:
must be
and
must be
.
The output matrix
must have dimensions
.
The matrix product is not commutative:
in general.
If you need to compute
or other variants, consider using vsip_dgemp_p instead.