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

for
, where
is a vector of length
,
is an
matrix, and
is the resulting vector of length
.
This operation is equivalent to the matrix-vector product
, where
is the transpose of vector
.
const vsip_dvview_p* a: Input vector of length
.
const vsip_dmview_p* b: Input matrix of size
.
const vsip_dvview_p* r: Output vector of length
that will store the result.
vsip_vview_f *a, *r; vsip_mview_f *b; vsip_length n = 4, m = 3; // Create vector and matrices a = vsip_vcreate_f(n, VSIP_MEM_NONE); b = vsip_mcreate_f(n, m, VSIP_ROW, VSIP_MEM_NONE); r = vsip_vcreate_f(m, VSIP_MEM_NONE); // Initialize vector a and matrix b with some values vsip_vramp_f(1.0f, 1.0f, a); // a = [1, 2, 3, 4] // Initialize matrix b (4x3) for (vsip_index i = 0; i < n; i++) { for (vsip_index j = 0; j < m; j++) { vsip_mput_f(b, i, j, (float)(i*m + j + 1)); } } // Compute vector-matrix product: r = a^T * b vsip_vmprod_f(a, b, r); // Print the result printf("Result vector r:\n"); for (vsip_index i = 0; i < m; i++) { printf("%8.2f ", vsip_vget_f(r, i)); } printf("\n"); // Clean up vsip_valldestroy_f(a); vsip_malldestroy_f(b); vsip_valldestroy_f(r);
The input vector
must have length
.
The input matrix
must have dimensions
.
The output vector
must have length
.
This operation is equivalent to the matrix-vector product
.
This operation is not commutative:
.