Skip to content

Commit

Permalink
Update interface.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 27, 2023
1 parent a3dae80 commit 84fe2e6
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,6 @@ end
end
end

@testset "similar_array_type_Diagonal" begin
z = zeros(2, 2)
y = MA.operate!!(MA.add_mul, z, big(1), LinearAlgebra.I(2))
@test y == BigFloat[1 0; 0 1]
y = MA.operate!!(MA.add_mul, z, 2.4, LinearAlgebra.I(2))
@test y === z
@test y == Float64[2.4 0; 0 2.4]
z = zeros(2, 2)
y = MA.operate!!(MA.add_mul, z, 2.4, LinearAlgebra.Diagonal(1:2))
@test y == LinearAlgebra.Diagonal(2.4 * (1:2))
end

@testset "similar_array_type" begin
@test MA.similar_array_type(BitArray{2}, Int) == Array{Int,2}
@test MA.similar_array_type(BitArray{2}, Bool) == BitArray{2}
end

@testset "add_mul for BitArray" begin
x = BigInt[0, 0]
MA.operate!!(MA.add_mul, x, big(2), trues(2))
Expand All @@ -155,3 +138,20 @@ end
MA.operate!!(MA.add_mul, x, big(3), BitArray([true false; true true]))
@test x == BigInt[5 2; 5 5]
end

@testset "similar_array_type" begin
@test MA.similar_array_type(BitArray{2}, Int) == Array{Int,2}
@test MA.similar_array_type(BitArray{2}, Bool) == BitArray{2}
end

@testset "similar_array_type_Diagonal" begin
z = zeros(2, 2)
y = MA.operate!!(MA.add_mul, z, big(1), LinearAlgebra.I(2))
@test y == BigFloat[1 0; 0 1]
y = MA.operate!!(MA.add_mul, z, 2.4, LinearAlgebra.I(2))
@test y === z
@test y == Float64[2.4 0; 0 2.4]
z = zeros(2, 2)
y = MA.operate!!(MA.add_mul, z, 2.4, LinearAlgebra.Diagonal(1:2))
@test y == LinearAlgebra.Diagonal(2.4 * (1:2))
end

0 comments on commit 84fe2e6

Please sign in to comment.