如何解决Rust Arrayfire闭包乘法
我正在尝试将arrayfire矩阵乘以闭包矩阵。无论如何,不使用for循环就可以实现这一目标?
我当前的代码如下:
//Initialize the closures and assign to an arry
let a = |x| {x*2.0};
let b = |x| {x*3.0};
let c = |x| {x*4.0};
let values: [fn(f64) -> f64; 3] = [a,b,c];
//Create an arrayfire Matrix
let dims = Dim4::new(&[3,1,1]);
let v = randu::<f64>(dims);
//Printing out the original arrayfire matrix
arrayfire::print(&v);
//A failed attempt to apply the closures to the matrix
let v = &v * values;
//The desired output
arrayfire::print(&v);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。