Adelsbach/VSIPL
Core Programming Reference Guide
DD-00016-015
Core

This manual is preliminary and incomplete.
While our Core implementation implements all functions given in the standard we are still working on completing this documentation.

Please refer to the VSIPL standard for a complete function reference of the Core profile until we have completed work on this documentation.

6.1.8 vsip_dvmprod_p - Vector-Matrix Product

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);
Description

This function computes the product of a vector and a matrix, storing the result in an output vector. The operation performed is:

r =∑︁n a ·b
 i j=1 j  j,i

for i= 1,2,...,m, where a is a vector of length n, b is an n ×m matrix, and r is the resulting vector of length m.

This operation is equivalent to the matrix-vector product     T
r= a ·b, where  T
a is the transpose of vector a.

Parameters
Example

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);
Notes