@@ -157,8 +157,9 @@ pub trait BooleanFunctionImpl: Debug {
157157 /// A hashmap containing the absolute Walsh-Hadamard values as keys, and the number of occurrences as values.
158158 fn absolute_walsh_hadamard_spectrum ( & self ) -> HashMap < u32 , usize > {
159159 let mut absolute_walsh_value_count_map: HashMap < u32 , usize > = HashMap :: new ( ) ;
160+ let walsh_hadamard_values_list = self . walsh_hadamard_values ( ) ;
160161 ( 0 ..=self . get_max_input_value ( ) ) . for_each ( |w| {
161- let absolute_walsh_value = self . walsh_hadamard_transform ( w ) . unsigned_abs ( ) ;
162+ let absolute_walsh_value = walsh_hadamard_values_list [ w as usize ] . unsigned_abs ( ) ;
162163 if !absolute_walsh_value_count_map. contains_key ( & absolute_walsh_value) {
163164 absolute_walsh_value_count_map. insert ( absolute_walsh_value, 1 ) ;
164165 } else {
@@ -379,9 +380,10 @@ pub trait BooleanFunctionImpl: Debug {
379380 /// # Returns
380381 /// The nonlinearity of the Boolean function, as an unsigned 32-bit integer.
381382 fn nonlinearity ( & self ) -> u32 {
383+ let walsh_hadamard_values_list = self . walsh_hadamard_values ( ) ;
382384 ( ( 1 << self . variables_count ( ) )
383385 - ( 0 ..=self . get_max_input_value ( ) )
384- . map ( |x| self . walsh_hadamard_transform ( x ) . unsigned_abs ( ) )
386+ . map ( |x| walsh_hadamard_values_list [ x as usize ] . unsigned_abs ( ) )
385387 . max ( )
386388 . unwrap_or ( 0 ) )
387389 >> 1
@@ -415,8 +417,9 @@ pub trait BooleanFunctionImpl: Debug {
415417 return false ;
416418 }
417419 let absolute_walsh_allowed_value = 1 << ( ( self . variables_count ( ) + 1 ) >> 1 ) ;
420+ let walsh_hadamard_values_list = self . walsh_hadamard_values ( ) ;
418421 let walsh_hadamard_spectrum = ( 0 ..=self . get_max_input_value ( ) )
419- . map ( |x| self . walsh_hadamard_transform ( x ) )
422+ . map ( |x| walsh_hadamard_values_list [ x as usize ] )
420423 . collect :: < HashSet < _ > > ( ) ;
421424
422425 walsh_hadamard_spectrum. len ( ) == 3 && walsh_hadamard_spectrum. iter ( ) . all ( |w| {
@@ -544,8 +547,9 @@ pub trait BooleanFunctionImpl: Debug {
544547 /// # Returns
545548 /// The correlation immunity order of the Boolean function.
546549 fn correlation_immunity ( & self ) -> usize {
550+ let walsh_hadamard_values_list = self . walsh_hadamard_values ( ) ;
547551 ( 1 ..=self . get_max_input_value ( ) )
548- . filter ( |x| self . walsh_hadamard_transform ( * x ) != 0 )
552+ . filter ( |x| walsh_hadamard_values_list [ * x as usize ] != 0 )
549553 . map ( |x| x. count_ones ( ) as usize )
550554 . min ( )
551555 . unwrap_or ( self . variables_count ( ) + 1 )
0 commit comments