Use StdFloat to fix compile error

This commit is contained in:
Magnus Ulimoen 2022-07-05 19:51:48 +02:00
parent f40de866ce
commit bb1909c2a8
2 changed files with 4 additions and 2 deletions

View File

@ -13,6 +13,7 @@ num-traits = "0.2.14"
float = { path = "../utils/float" } float = { path = "../utils/float" }
constmatrix = { path = "../utils/constmatrix" } constmatrix = { path = "../utils/constmatrix" }
core_simd = { git = "https://github.com/rust-lang/portable-simd" } core_simd = { git = "https://github.com/rust-lang/portable-simd" }
std_float = { git = "https://github.com/rust-lang/portable-simd" }
[features] [features]
# Use f32 as precision, default is f64 # Use f32 as precision, default is f64

View File

@ -2,6 +2,7 @@ use super::*;
use ndarray::s; use ndarray::s;
use num_traits::Zero; use num_traits::Zero;
use std::convert::TryInto; use std::convert::TryInto;
use std_float::StdFloat;
pub(crate) use constmatrix::{ColVector, Matrix, RowVector}; pub(crate) use constmatrix::{ColVector, Matrix, RowVector};
@ -442,7 +443,7 @@ pub(crate) fn diff_op_2d_sliceable_y_simd<const M: usize, const N: usize, const
for (iprev, &bl) in bl.iter().enumerate() { for (iprev, &bl) in bl.iter().enumerate() {
f = index_to_simd(iprev).mul_add(SimdT::splat(bl), f); f = index_to_simd(iprev).mul_add(SimdT::splat(bl), f);
} }
f *= idx; f *= SimdT::splat(idx);
fut.clone_from_slice(f.as_array()); fut.clone_from_slice(f.as_array());
} }
for (j, fut) in (simdified..ny).zip(fut.into_remainder()) { for (j, fut) in (simdified..ny).zip(fut.into_remainder()) {
@ -494,7 +495,7 @@ pub(crate) fn diff_op_2d_sliceable_y_simd<const M: usize, const N: usize, const
let offset = ifut - half_diag_width + id; let offset = ifut - half_diag_width + id;
f = index_to_simd(offset).mul_add(SimdT::splat(d), f); f = index_to_simd(offset).mul_add(SimdT::splat(d), f);
} }
f *= idx; f *= SimdT::splat(idx);
fut.clone_from_slice(f.as_array()); fut.clone_from_slice(f.as_array());
} }
for (j, fut) in (simdified..ny).zip(fut.into_remainder()) { for (j, fut) in (simdified..ny).zip(fut.into_remainder()) {