[lab4] Simplified to procedures on f64
This commit is contained in:
parent
91fa4cefe2
commit
70742fad8b
@ -3,15 +3,11 @@ fn compute_potential<const Is: usize, const Os: usize>(
|
|||||||
input_data: &[f64; Is],
|
input_data: &[f64; Is],
|
||||||
potential_data: &mut [f64; Is],
|
potential_data: &mut [f64; Is],
|
||||||
output_data: &mut [f64; Is],
|
output_data: &mut [f64; Is],
|
||||||
f: impl Fn(f64) -> f64
|
f: impl Fn(f64) -> f64,
|
||||||
) {
|
) {
|
||||||
for (i, n) in weights.iter().enumerate() {
|
for (i, n) in weights.iter().enumerate() {
|
||||||
let P = input_data
|
let P = input_data.iter().zip(n).map(|(x, w)| x * w).sum();
|
||||||
.iter()
|
|
||||||
.zip(n)
|
|
||||||
.map(|(x, w)| x.apply_weight(*w))
|
|
||||||
.sum();
|
|
||||||
potential_data[i] = P;
|
potential_data[i] = P;
|
||||||
output_data[i] = f(P);
|
output_data[i] = f(P);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user