void vsip_mvprod_f(const vsip_mview_f *a, const vsip_vview_f *b, const vsip_vview_f *r); void vsip_cmvprod_f(const vsip_cmview_f *a, const vsip_cvview_f *b, const vsip_cvview_f *r);
This function computes the product of a matrix and a vector, storing the result in an output vector. The operation performed is:

for
, where
is an
matrix,
is a vector of length
, and
is the resulting vector of length
.
This operation is equivalent to the matrix-vector product
.
const vsip_dmview_p* a: Input matrix of size
.
const vsip_dvview_p* b: Input vector of length
.
const vsip_dvview_p* r: Output vector of length
that will store the result.
vsip_mview_f *A; vsip_vview_f *b, *r; vsip_length m = 4, n = 3; // Create matrix and vectors A = vsip_mcreate_f(m, n, VSIP_ROW, VSIP_MEM_NONE); b = vsip_vcreate_f(n, VSIP_MEM_NONE); r = vsip_vcreate_f(m, VSIP_MEM_NONE); // Initialize matrix A and vector b with some values // Initialize A (4x3 matrix) 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 vector b vsip_vramp_f(1.0f, 1.0f, b); // b = [1, 2, 3] // Compute matrix-vector product: r = A * b vsip_mvprod_f(A, b, r); // Print the result 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("\nVector b (%lu):\n", n); for (vsip_index i = 0; i < n; i++) { printf("%8.2f ", vsip_vget_f(b, i)); } printf("\n"); printf("\nResult vector r (%lu):\n", m); for (vsip_index i = 0; i < m; i++) { printf("%8.2f ", vsip_vget_f(r, i)); } printf("\n"); // Clean up vsip_malldestroy_f(A); vsip_valldestroy_f(b); vsip_valldestroy_f(r);
The input matrix
must have dimensions
.
The input vector
must have length
.
The output vector
must have length
.
This operation is equivalent to the matrix-vector product
.
If you need to compute
(vector-matrix product), use vsip_dvmprod_p instead.