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.3 vsip_dvouter_p - Outer Product of Two Vectors

void vsip_vouter_f(vsip_scalar_f alpha, const vsip_vview_f *x, const vsip_vview_f *y, const vsip_mview_f *r); 
void vsip_cvouter_f(vsip_cscalar_f alpha, const vsip_cvview_f *x, const vsip_cvview_f *y, const vsip_cmview_f *r);
Description

This function computes the outer product of two vectors x and y, scaled by α, and stores the result in matrix r. The outer product is defined as:

ri,j= α·xi·yj

for all i and j, where xi is the i-th element of vector x and yj is the j-th element of vector y.

Parameters
Example

vsip_vview_f *x, *y; 
vsip_mview_f *r; 
vsip_length m = 5, n = 4; 
 
// Create vectors and matrix 
x = vsip_vcreate_f(m, VSIP_MEM_NONE); 
y = vsip_vcreate_f(n, VSIP_MEM_NONE); 
r = vsip_mcreate_f(m, n, VSIP_ROW, VSIP_MEM_NONE); 
 
// Initialize vectors 
vsip_vramp_f(1.0f, 1.0f, x);  // x = [1, 2, 3, 4, 5] 
vsip_vramp_f(0.5f, 0.5f, y);  // y = [0.5, 1.0, 1.5, 2.0] 
 
// Compute outer product: r = x * y^T 
vsip_vouter_f(1.0f, x, y, r); 
 
// Print the resulting matrix 
printf("Outer product result:\n"); 
for (vsip_index i = 0; i < m; i++) { 
    for (vsip_index j = 0; j < n; j++) { 
        printf("%8.2f ", vsip_mget_f(r, i, j)); 
    } 
    printf("\n"); 
} 
 
// Compute scaled outer product: r = 2.0 * x * y^T 
vsip_vouter_f(2.0f, x, y, r); 
 
// Clean up 
vsip_valldestroy_f(x); 
vsip_valldestroy_f(y); 
vsip_malldestroy_f(r);
Notes