@@ -25,6 +25,7 @@ pub fn scalar_error() {
2525 let approx_1 = unsafe { x. sin_fast_approx :: < 1 > ( ) } ;
2626 let approx_2 = unsafe { x. sin_fast_approx :: < 2 > ( ) } ;
2727 let approx_3 = unsafe { x. sin_fast_approx :: < 3 > ( ) } ;
28+
2829 let exact = x. sin ( ) ;
2930
3031 assert ! (
@@ -68,34 +69,14 @@ pub fn simd_error() {
6869 LaneCount < LANES > : SupportedLaneCount ,
6970 {
7071 for _i in 0 ..ITERS {
71- let mut vec_uninit: core:: mem:: MaybeUninit < Simd < f32 , LANES > > =
72- core:: mem:: MaybeUninit :: uninit ( ) ;
73- let vec_ptr = vec_uninit. as_mut_ptr ( ) ;
74-
75- for i in 0 ..LANES {
76- unsafe {
77- ( * vec_ptr) [ i] = rng. gen_range ( RANGE ) ;
78- }
79- }
80-
81- let x = unsafe { vec_uninit. assume_init ( ) } ;
72+ let x = Simd :: from_array ( [ 0 ; LANES ] . map ( |_| rng. gen_range ( RANGE ) ) ) ;
8273
8374 let approx_0 = unsafe { x. sin_fast_approx :: < 0 > ( ) } ;
8475 let approx_1 = unsafe { x. sin_fast_approx :: < 1 > ( ) } ;
8576 let approx_2 = unsafe { x. sin_fast_approx :: < 2 > ( ) } ;
8677 let approx_3 = unsafe { x. sin_fast_approx :: < 3 > ( ) } ;
8778
88- let mut vec_uninit: core:: mem:: MaybeUninit < Simd < f32 , LANES > > =
89- core:: mem:: MaybeUninit :: uninit ( ) ;
90- let vec_ptr = vec_uninit. as_mut_ptr ( ) ;
91-
92- for i in 0 ..LANES {
93- unsafe {
94- ( * vec_ptr) [ i] = x[ i] . sin ( ) ;
95- }
96- }
97-
98- let exact = unsafe { vec_uninit. assume_init ( ) } ;
79+ let exact = Simd :: from_array ( x. to_array ( ) . map ( |x| x. sin ( ) ) ) ;
9980
10081 assert ! (
10182 ( exact - approx_0)
@@ -157,31 +138,9 @@ pub fn simd_ilog_error() {
157138 LaneCount < LANES > : SupportedLaneCount ,
158139 {
159140 for _i in 0 ..ITERS {
160- let mut vec_uninit: core:: mem:: MaybeUninit < Simd < u32 , LANES > > =
161- core:: mem:: MaybeUninit :: uninit ( ) ;
162- let vec_ptr = vec_uninit. as_mut_ptr ( ) ;
163-
164- for i in 0 ..LANES {
165- unsafe {
166- ( * vec_ptr) [ i] = rng. next_u32 ( ) ;
167- }
168- }
169-
170- let x = unsafe { vec_uninit. assume_init ( ) } ;
171-
141+ let x = Simd :: from_array ( [ 0 ; LANES ] . map ( |_| rng. next_u32 ( ) ) ) ;
172142 let fast = unsafe { x. ilog_const_base_unchecked :: < 3 > ( ) } ;
173-
174- let mut vec_uninit: core:: mem:: MaybeUninit < Simd < u32 , LANES > > =
175- core:: mem:: MaybeUninit :: uninit ( ) ;
176- let vec_ptr = vec_uninit. as_mut_ptr ( ) ;
177-
178- for i in 0 ..LANES {
179- unsafe {
180- ( * vec_ptr) [ i] = x[ i] . ilog ( 3 ) ;
181- }
182- }
183-
184- let exact = unsafe { vec_uninit. assume_init ( ) } ;
143+ let exact = Simd :: from_array ( x. to_array ( ) . map ( |x| x. ilog ( 3 ) ) ) ;
185144
186145 assert ! (
187146 exact. simd_eq( fast) . all( ) ,
@@ -194,6 +153,35 @@ pub fn simd_ilog_error() {
194153 }
195154}
196155
156+ // #[derive(Clone, Copy, Default)]
157+ // struct Color(u32, u32, u32);
158+ //
159+ // #[inline(never)]
160+ // #[test]
161+ // pub fn mandelbrot_test() {
162+ // use alloc::boxed::Box;
163+ //
164+ // const SIZE: usize = 100;
165+ // const ITERS: usize = 10;
166+ // const COLOR_1: Color = Color(0, 255, 0);
167+ // const COLOR_2: Color = Color(255, 0, 0);
168+ // const ARRAY_LEN: usize = SIZE * SIZE;
169+ //
170+ // const START_X: f32 = 0.0;
171+ // const START_Y: f32 = 0.0;
172+ // const END_X: f32 = 1.0;
173+ // const END_Y: f32 = 1.0;
174+ //
175+ // let color_array: Box<[Color;ARRAY_LEN]> = Box::new([Default::default();ARRAY_LEN]);
176+ //
177+ // for y in 0..SIZE {
178+ // let y_pos = START_X
179+ // for x in 0..SIZE {
180+ // let idx = y * SIZE + x;
181+ // }
182+ // }
183+ // }
184+
197185// /// Options:
198186// /// --cfg print_values
199187// /// --cfg print_error
0 commit comments