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);
This function computes the outer product of two vectors
and
, scaled by
, and stores the result in matrix
. The outer
product is defined as:

for all
and
, where
is the
-th element of vector
and
is the
-th element of vector
.
vsip_dscalar_p alpha: Scalar multiplier for the outer product.
const vsip_dvview_p* x: Pointer to the first input vector of length
.
const vsip_dvview_p* y: Pointer to the second input vector of length
.
const vsip_dmview_p* r: Pointer to the output matrix of size
that will store the result.
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);
The output matrix
must have dimensions
where
is the length of vector
and
is the length of vector
.
The outer product is not commutative:
.
If
, the result will be a zero matrix regardless of the input vectors.