@@ -37,16 +37,24 @@ using Statistics: mean
3737 v2 = [4 ,3 ,2 ,1 ]; sv2 = SVector {4} (v2)
3838 @test reduce (+ , sv1) === reduce (+ , v1)
3939 @test reduce (+ , sv1; init= 0 ) === reduce (+ , v1; init= 0 )
40+ @test reduce (+ , sv1; init= 99 ) === reduce (+ , v1; init= 99 )
4041 @test reduce (max, sa; dims= Val (1 ), init= - 1. ) === SMatrix {1,J} (reduce (max, a, dims= 1 , init= - 1. ))
4142 @test reduce (max, sa; dims= 1 , init= - 1. ) === SMatrix {1,J} (reduce (max, a, dims= 1 , init= - 1. ))
4243 @test reduce (max, sa; dims= 2 , init= - 1. ) === SMatrix {I,1} (reduce (max, a, dims= 2 , init= - 1. ))
44+ @test reduce (* , sa; dims= (1 ,2 ), init= 2.0 ) === SMatrix {1,1} (reduce (* , a, dims= (1 ,2 ), init= 2.0 ))
45+ @test reduce (* , sa; dims= (), init= (1.0 + im)) === SMatrix {I,J} (reduce (* , a, dims= (), init= (1.0 + im)))
4346 @test mapreduce (- , + , sv1) === mapreduce (- , + , v1)
4447 @test mapreduce (- , + , sv1; init= 0 ) === mapreduce (- , + , v1, init= 0 )
4548 @test mapreduce (* , + , sv1, sv2) === 40
4649 @test mapreduce (* , + , sv1, sv2; init= 0 ) === 40
4750 @test mapreduce (x-> x^ 2 , max, sa; dims= Val (1 ), init= - 1. ) == SMatrix {1,J} (mapreduce (x-> x^ 2 , max, a, dims= 1 , init= - 1. ))
4851 @test mapreduce (x-> x^ 2 , max, sa; dims= 1 , init= - 1. ) == SMatrix {1,J} (mapreduce (x-> x^ 2 , max, a, dims= 1 , init= - 1. ))
4952 @test mapreduce (x-> x^ 2 , max, sa; dims= 2 , init= - 1. ) == SMatrix {I,1} (mapreduce (x-> x^ 2 , max, a, dims= 2 , init= - 1. ))
53+
54+ # Zero-dim array
55+ a0 = fill (rand ()); sa0 = SArray {Tuple{}} (a0)
56+ @test reduce (+ , sa0) === reduce (+ , a0)
57+ @test reduce (/ , sa0, dims= (), init= 1.2 ) === SArray {Tuple{}} (reduce (/ , a0, dims= (), init= 1.2 ))
5058 end
5159
5260 @testset " [map]foldl" begin
0 commit comments