我正在编写Rust中的一个并行矩阵乘法代码,我希望在其中并行计算乘积的每个元素.我用ndarray
来存储数据.因此,我的代码将是一行中的内容
fn mul(lhs: &Array2<f32>, rhs: &Array2<f32>) -> Array2<f32> {
let N = lhs.raw_size()[0];
let M = rhs.raw_size()[1];
let mut result = Array2::zeros((N,M));
range_2d(0..N,0..M).par_iter().map(|(i, j)| {
// load the result for the (i,j) element into 'result'
}).count();
result
}
有什么办法可以做到这一点吗?