Created
September 13, 2024 02:18
-
-
Save jmcph4/c42d70fb487e8a744ebd529ffdf6ecc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn foo(x: &[f64], y: &[f64], out: &mut [f64]) { | |
| if x.len() != y.len() || x.len() != out.len() { | |
| return; | |
| } else { | |
| let n: usize = x.len(); | |
| for i in 0..n { | |
| out[i] = x[i] * y[i]; | |
| } | |
| } | |
| } | |
| fn main() { | |
| let x = [1.0, 2.0, 3.0]; | |
| let y = [4.0, 4.0, 4.0]; | |
| let mut z = [0.0;3]; | |
| foo(&x, &y, &mut z); | |
| println!("{x:?} * {y:?} = {z:?}"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment