@@ -51,6 +51,24 @@ StaticArrays.similar_type(::Union{RotMat2,Type{RotMat2}}) = SMatrix{2,2,Float64,
5151 end
5252 end
5353
54+ @testset " Ternary operators" begin
55+ for T in (Int, Float32, Float64)
56+ c = convert (T, 2 )
57+ v1 = @SVector T[2 , 4 , 6 , 8 ]
58+ v2 = @SVector T[4 , 3 , 2 , 1 ]
59+ m1 = @SMatrix T[2 4 ; 6 8 ]
60+ m2 = @SMatrix T[4 3 ; 2 1 ]
61+
62+ # Use that these small integers can be represetnted exactly
63+ # as floating point numbers. In general, the comparison of
64+ # floats should use `≈` instead of `===`.
65+ @test @inferred (muladd (c, v1, v2)) === @SVector T[8 , 11 , 14 , 17 ]
66+ @test @inferred (muladd (v1, c, v2)) === @SVector T[8 , 11 , 14 , 17 ]
67+ @test @inferred (muladd (c, m1, m2)) === @SMatrix T[8 11 ; 14 17 ]
68+ @test @inferred (muladd (m1, c, m2)) === @SMatrix T[8 11 ; 14 17 ]
69+ end
70+ end
71+
5472 @testset " Interaction with `UniformScaling`" begin
5573 @test @inferred (@SMatrix ([0 1 ; 2 3 ]) + I) === @SMatrix [1 1 ; 2 4 ]
5674 @test @inferred (I + @SMatrix ([0 1 ; 2 3 ])) === @SMatrix [1 1 ; 2 4 ]
0 commit comments