Skip to main content

outer_product

Function outer_product 

Source
pub fn outer_product(a: &[f32], b: &[f32]) -> Vec<Vec<f32>>
Expand description

SIMD-optimized outer product computation

Computes the outer product of two vectors, resulting in a matrix where element (i,j) = a[i] * b[j].

§Arguments

  • a - First vector (m elements)
  • b - Second vector (n elements)

§Returns

An m×n matrix represented as Vec<Vec<f32>>

§Examples

use sklears_simd::vector::basic_operations::outer_product;

let a = vec![1.0, 2.0];
let b = vec![3.0, 4.0, 5.0];
let result = outer_product(&a, &b);
// Expected: [[3.0, 4.0, 5.0], [6.0, 8.0, 10.0]]
assert_eq!(result[0], vec![3.0, 4.0, 5.0]);
assert_eq!(result[1], vec![6.0, 8.0, 10.0]);