From 2915481adbc7832f9f966ee2d72816c0f377a55f Mon Sep 17 00:00:00 2001 From: Carlo Lucibello Date: Fri, 4 Dec 2020 11:38:50 +0100 Subject: [PATCH 1/8] fix tests --- src/fillalgebra.jl | 84 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 14 deletions(-) diff --git a/src/fillalgebra.jl b/src/fillalgebra.jl index 8bcea244..3a2459a4 100644 --- a/src/fillalgebra.jl +++ b/src/fillalgebra.jl @@ -1,3 +1,10 @@ +const FillVector{F,A} = Fill{F,1,A} +const FillMatrix{F,A} = Fill{F,2,A} +const OnesVector{F,A} = Ones{F,1,A} +const OnesMatrix{F,A} = Ones{F,2,A} +const ZerosVector{F,A} = Zeros{F,1,A} +const ZerosMatrix{F,A} = Zeros{F,2,A} + ## vec vec(a::Ones{T}) where T = Ones{T}(length(a)) @@ -87,11 +94,22 @@ end *(a::Zeros{<:Any,2}, b::Diagonal) = mult_zeros(a, b) *(a::Diagonal, b::Zeros{<:Any,1}) = mult_zeros(a, b) *(a::Diagonal, b::Zeros{<:Any,2}) = mult_zeros(a, b) -function *(a::Diagonal, b::AbstractFill{<:Any,2}) + +# Cannot unify following methods for Diagonal +# due to ambiguity with general array mult. with fill +function *(a::Diagonal, b::FillMatrix) + size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) + a.diag .* b # use special broadcast +end +function *(a::FillMatrix, b::Diagonal) + size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) + a .* permutedims(b.diag) # use special broadcast +end +function *(a::Diagonal, b::OnesMatrix) size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) a.diag .* b # use special broadcast end -function *(a::AbstractFill{<:Any,2}, b::Diagonal) +function *(a::OnesMatrix, b::Diagonal) size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) a .* permutedims(b.diag) # use special broadcast end @@ -100,23 +118,61 @@ end *(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 1}) where T = reshape(sum(parent(a); dims=1) .* b.value, size(parent(a), 2)) *(a::StridedMatrix{T}, b::Fill{T, 1}) where T = reshape(sum(a; dims=2) .* b.value, size(a, 1)) -function *(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T - fB = similar(parent(a), size(b, 1), size(b, 2)) - fill!(fB, b.value) - return a*fB +function *(x::AbstractMatrix, f::FillMatrix) + axes(x, 2) ≠ axes(f, 1) && + throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) + m = size(f, 2) + repeat(sum(x, dims=2) * f.value, 1, m) +end + +function *(f::FillMatrix, x::AbstractMatrix) + axes(f, 2) ≠ axes(x, 1) && + throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) + m = size(f, 1) + repeat(sum(x, dims=1) * f.value, m, 1) end -function *(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T - fB = similar(parent(a), size(b, 1), size(b, 2)) - fill!(fB, b.value) - return a*fB +function *(x::AbstractMatrix, f::OnesMatrix) + axes(x, 2) ≠ axes(f, 1) && + throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) + m = size(f, 2) + repeat(sum(x, dims=2) * one(eltype(f)), 1, m) end -function *(a::StridedMatrix{T}, b::Fill{T, 2}) where T - fB = similar(a, size(b, 1), size(b, 2)) - fill!(fB, b.value) - return a*fB +function *(f::OnesMatrix, x::AbstractMatrix) + axes(f, 2) ≠ axes(x, 1) && + throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) + m = size(f, 1) + repeat(sum(x, dims=1) * one(eltype(f)), m, 1) end + +*(x::FillMatrix, y::FillMatrix) = mult_fill(x, y) +*(x::FillMatrix, y::OnesMatrix) = mult_fill(x, y) +*(x::OnesMatrix, y::FillMatrix) = mult_fill(x, y) +*(x::OnesMatrix, y::OnesMatrix) = mult_fill(x, y) +*(x::ZerosMatrix, y::OnesMatrix) = mult_zeros(x, y) +*(x::ZerosMatrix, y::FillMatrix) = mult_zeros(x, y) +*(x::FillMatrix, y::ZerosMatrix) = mult_zeros(x, y) +*(x::OnesMatrix, y::ZerosMatrix) = mult_zeros(x, y) + +# function *(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T +# fB = similar(parent(a), size(b, 1), size(b, 2)) +# fill!(fB, b.value) +# return a*fB +# end + +# function *(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T +# fB = similar(parent(a), size(b, 1), size(b, 2)) +# fill!(fB, b.value) +# return a*fB +# end + +# function *(a::StridedMatrix{T}, b::Fill{T, 2}) where T +# fB = similar(a, size(b, 1), size(b, 2)) +# fill!(fB, b.value) +# return a*fB +# end + function _adjvec_mul_zeros(a::Adjoint{T}, b::Zeros{S, 1}) where {T, S} la, lb = length(a), length(b) if la ≠ lb From 2766105720174a9d390fc47450018052388cd8bd Mon Sep 17 00:00:00 2001 From: Carlo Lucibello Date: Fri, 4 Dec 2020 18:39:35 +0100 Subject: [PATCH 2/8] faster matrix-fillmatrix multiplication cleanup --- src/fillalgebra.jl | 64 +++++++++++++++++----------------------------- test/runtests.jl | 13 ++++++++++ 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/fillalgebra.jl b/src/fillalgebra.jl index 3a2459a4..e977f20c 100644 --- a/src/fillalgebra.jl +++ b/src/fillalgebra.jl @@ -84,8 +84,10 @@ end *(a::Zeros{<:Any,1}, b::AbstractMatrix) = mult_zeros(a, b) *(a::Zeros{<:Any,2}, b::AbstractMatrix) = mult_zeros(a, b) +*(a::Zeros{<:Any,2}, b::AbstractTriangular) = mult_zeros(a, b) *(a::AbstractMatrix, b::Zeros{<:Any,1}) = mult_zeros(a, b) *(a::AbstractMatrix, b::Zeros{<:Any,2}) = mult_zeros(a, b) +*(a::AbstractTriangular, b::Zeros{<:Any,2}) = mult_zeros(a, b) *(a::Zeros{<:Any,1}, b::AbstractVector) = mult_zeros(a, b) *(a::Zeros{<:Any,2}, b::AbstractVector) = mult_zeros(a, b) *(a::AbstractVector, b::Zeros{<:Any,2}) = mult_zeros(a, b) @@ -95,66 +97,36 @@ end *(a::Diagonal, b::Zeros{<:Any,1}) = mult_zeros(a, b) *(a::Diagonal, b::Zeros{<:Any,2}) = mult_zeros(a, b) -# Cannot unify following methods for Diagonal -# due to ambiguity with general array mult. with fill -function *(a::Diagonal, b::FillMatrix) +function *(a::Diagonal, b::AbstractFill{T,2}) where T size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) a.diag .* b # use special broadcast end -function *(a::FillMatrix, b::Diagonal) +function *(a::AbstractFill{T,2}, b::Diagonal) where T size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) a .* permutedims(b.diag) # use special broadcast end -function *(a::Diagonal, b::OnesMatrix) - size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) - a.diag .* b # use special broadcast -end -function *(a::OnesMatrix, b::Diagonal) - size(a,2) == size(b,1) || throw(DimensionMismatch("A has dimensions $(size(a)) but B has dimensions $(size(b))")) - a .* permutedims(b.diag) # use special broadcast -end - -*(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 1}) where T = reshape(sum(conj.(parent(a)); dims=1) .* b.value, size(parent(a), 2)) -*(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 1}) where T = reshape(sum(parent(a); dims=1) .* b.value, size(parent(a), 2)) -*(a::StridedMatrix{T}, b::Fill{T, 1}) where T = reshape(sum(a; dims=2) .* b.value, size(a, 1)) -function *(x::AbstractMatrix, f::FillMatrix) +function mult_sum2(x::AbstractMatrix, f::AbstractFill{T,2}) where T axes(x, 2) ≠ axes(f, 1) && throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) m = size(f, 2) - repeat(sum(x, dims=2) * f.value, 1, m) + repeat(sum(x, dims=2) * getindex_value(f), 1, m) end -function *(f::FillMatrix, x::AbstractMatrix) +function mult_sum1(f::AbstractFill{T,2}, x::AbstractMatrix) where T axes(f, 2) ≠ axes(x, 1) && throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) m = size(f, 1) - repeat(sum(x, dims=1) * f.value, m, 1) + repeat(sum(x, dims=1) * getindex_value(f), m, 1) end -function *(x::AbstractMatrix, f::OnesMatrix) - axes(x, 2) ≠ axes(f, 1) && - throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) - m = size(f, 2) - repeat(sum(x, dims=2) * one(eltype(f)), 1, m) -end +*(x::AbstractMatrix, y::AbstractFill{<:Any,2}) = mult_sum2(x, y) +*(x::AbstractTriangular, y::AbstractFill{<:Any,2}) = mult_sum2(x, y) +*(x::AbstractFill{<:Any,2}, y::AbstractMatrix) = mult_sum1(x, y) +*(x::AbstractFill{<:Any,2}, y::AbstractTriangular) = mult_sum1(x, y) -function *(f::OnesMatrix, x::AbstractMatrix) - axes(f, 2) ≠ axes(x, 1) && - throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) - m = size(f, 1) - repeat(sum(x, dims=1) * one(eltype(f)), m, 1) -end - -*(x::FillMatrix, y::FillMatrix) = mult_fill(x, y) -*(x::FillMatrix, y::OnesMatrix) = mult_fill(x, y) -*(x::OnesMatrix, y::FillMatrix) = mult_fill(x, y) -*(x::OnesMatrix, y::OnesMatrix) = mult_fill(x, y) -*(x::ZerosMatrix, y::OnesMatrix) = mult_zeros(x, y) -*(x::ZerosMatrix, y::FillMatrix) = mult_zeros(x, y) -*(x::FillMatrix, y::ZerosMatrix) = mult_zeros(x, y) -*(x::OnesMatrix, y::ZerosMatrix) = mult_zeros(x, y) +### These methods are faster for small n ############# # function *(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T # fB = similar(parent(a), size(b, 1), size(b, 2)) # fill!(fB, b.value) @@ -173,6 +145,16 @@ end # return a*fB # end +## Matrix-Vector multiplication + +*(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 1}) where T = + reshape(sum(conj.(parent(a)); dims=1) .* b.value, size(parent(a), 2)) +*(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 1}) where T = + reshape(sum(parent(a); dims=1) .* b.value, size(parent(a), 2)) +*(a::StridedMatrix{T}, b::Fill{T, 1}) where T = + reshape(sum(a; dims=2) .* b.value, size(a, 1)) + + function _adjvec_mul_zeros(a::Adjoint{T}, b::Zeros{S, 1}) where {T, S} la, lb = length(a), length(b) if la ≠ lb diff --git a/test/runtests.jl b/test/runtests.jl index 74f01d69..2c91c6d1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1028,6 +1028,19 @@ end @test E*(1:5) ≡ 1.0:5.0 @test (1:5)'E == (1.0:5)' @test E*E ≡ E + + # Adjoint / Transpose / Triangular / Symmetric + for x in [transpose(rand(2, 2)), + adjoint(rand(2,2)), + UpperTriangular(rand(2,2)), + Symmetric(rand(2,2))] + @test x * Ones(2, 2) isa Matrix + @test Ones(2, 2) * x isa Matrix + @test x * Zeros(2, 2) isa Zeros + @test Zeros(2, 2) * x isa Zeros + @test x * Fill(1., 2, 2) isa Matrix + @test Fill(1., 2, 2) * x isa Matrix + end end @testset "count" begin From e7dcb947aab8804e7686fc847b5bada04b477a47 Mon Sep 17 00:00:00 2001 From: Carlo Lucibello Date: Fri, 4 Dec 2020 19:08:16 +0100 Subject: [PATCH 3/8] add hermitian to tests --- test.jl | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 5 ++-- 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 test.jl diff --git a/test.jl b/test.jl new file mode 100644 index 00000000..9f0d008d --- /dev/null +++ b/test.jl @@ -0,0 +1,76 @@ +using FillArrays, BenchmarkTools +import Base: * +using Test + +# const FillVector{F,A} = Fill{F,1,A} +# const FillMatrix{F,A} = Fill{F,2,A} +# const OnesVector{F,A} = Ones{F,1,A} +# const OnesMatrix{F,A} = Ones{F,2,A} +# const ZerosVector{F,A} = Zeros{F,1,A} +# const ZerosMatrix{F,A} = Zeros{F,2,A} + +# function *(x::AbstractMatrix, f::FillMatrix) +# axes(x, 2) ≠ axes(f, 1) && +# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) +# m = size(f, 2) +# repeat(sum(x, dims=2) * f.value, 1, m) +# end + +# function *(f::FillMatrix, x::AbstractMatrix) +# axes(f, 2) ≠ axes(x, 1) && +# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) +# m = size(f, 1) +# repeat(sum(x, dims=1) * f.value, m, 1) +# end + +# function *(x::AbstractMatrix, f::OnesMatrix) +# axes(x, 2) ≠ axes(f, 1) && +# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) +# m = size(f, 2) +# repeat(sum(x, dims=2) * one(eltype(f)), 1, m) +# end + +# function *(f::OnesMatrix, x::AbstractMatrix) +# axes(f, 2) ≠ axes(x, 1) && +# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) +# m = size(f, 1) +# repeat(sum(x, dims=1) * one(eltype(f)), m, 1) +# end + +# function *(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T +# fB = similar(parent(a), size(b, 1), size(b, 2)) +# fill!(fB, b.value) +# return a*fB +# end + +# function *(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T +# fB = similar(parent(a), size(b, 1), size(b, 2)) +# fill!(fB, b.value) +# return a*fB +# end + +# function *(a::StridedMatrix{T}, b::Fill{T, 2}) where T +# fB = similar(a, size(b, 1), size(b, 2)) +# fill!(fB, b.value) +# return a*fB +# end + +# @test x * o ≈ x * ones(n,n) +# @test o * x ≈ ones(n,n) * x + +for n in [2, 5, 10, 20, 200, 2000] + x, y = rand(n, n), rand(n, n) + o, f = Ones(n, n), Fill(1.0, n, n) + + println("RIGHT n=$n") + @btime $x * $y + @btime $x * $o + @btime $x * $f + + println("LEFT n=$n") + @btime $x * $y + @btime $o * $y + @btime $f * $y + + println() +end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 2c91c6d1..d2d4f260 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1029,11 +1029,12 @@ end @test (1:5)'E == (1.0:5)' @test E*E ≡ E - # Adjoint / Transpose / Triangular / Symmetric + # Adjoint / Transpose / Triangular / Symmetric / Hermitian for x in [transpose(rand(2, 2)), adjoint(rand(2,2)), UpperTriangular(rand(2,2)), - Symmetric(rand(2,2))] + Symmetric(rand(2,2)), + Hermitian(rand(2,2))] @test x * Ones(2, 2) isa Matrix @test Ones(2, 2) * x isa Matrix @test x * Zeros(2, 2) isa Zeros From 4f08ad613ad2934abc7dcbd49e6bb38695678e26 Mon Sep 17 00:00:00 2001 From: Carlo Lucibello Date: Fri, 4 Dec 2020 19:08:41 +0100 Subject: [PATCH 4/8] cleanup --- test.jl | 76 --------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 test.jl diff --git a/test.jl b/test.jl deleted file mode 100644 index 9f0d008d..00000000 --- a/test.jl +++ /dev/null @@ -1,76 +0,0 @@ -using FillArrays, BenchmarkTools -import Base: * -using Test - -# const FillVector{F,A} = Fill{F,1,A} -# const FillMatrix{F,A} = Fill{F,2,A} -# const OnesVector{F,A} = Ones{F,1,A} -# const OnesMatrix{F,A} = Ones{F,2,A} -# const ZerosVector{F,A} = Zeros{F,1,A} -# const ZerosMatrix{F,A} = Zeros{F,2,A} - -# function *(x::AbstractMatrix, f::FillMatrix) -# axes(x, 2) ≠ axes(f, 1) && -# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) -# m = size(f, 2) -# repeat(sum(x, dims=2) * f.value, 1, m) -# end - -# function *(f::FillMatrix, x::AbstractMatrix) -# axes(f, 2) ≠ axes(x, 1) && -# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) -# m = size(f, 1) -# repeat(sum(x, dims=1) * f.value, m, 1) -# end - -# function *(x::AbstractMatrix, f::OnesMatrix) -# axes(x, 2) ≠ axes(f, 1) && -# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) -# m = size(f, 2) -# repeat(sum(x, dims=2) * one(eltype(f)), 1, m) -# end - -# function *(f::OnesMatrix, x::AbstractMatrix) -# axes(f, 2) ≠ axes(x, 1) && -# throw(DimensionMismatch("Incompatible matrix multiplication dimensions")) -# m = size(f, 1) -# repeat(sum(x, dims=1) * one(eltype(f)), m, 1) -# end - -# function *(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T -# fB = similar(parent(a), size(b, 1), size(b, 2)) -# fill!(fB, b.value) -# return a*fB -# end - -# function *(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 2}) where T -# fB = similar(parent(a), size(b, 1), size(b, 2)) -# fill!(fB, b.value) -# return a*fB -# end - -# function *(a::StridedMatrix{T}, b::Fill{T, 2}) where T -# fB = similar(a, size(b, 1), size(b, 2)) -# fill!(fB, b.value) -# return a*fB -# end - -# @test x * o ≈ x * ones(n,n) -# @test o * x ≈ ones(n,n) * x - -for n in [2, 5, 10, 20, 200, 2000] - x, y = rand(n, n), rand(n, n) - o, f = Ones(n, n), Fill(1.0, n, n) - - println("RIGHT n=$n") - @btime $x * $y - @btime $x * $o - @btime $x * $f - - println("LEFT n=$n") - @btime $x * $y - @btime $o * $y - @btime $f * $y - - println() -end \ No newline at end of file From 5a999ba00a4b14a634a3a87d5c0868f15e68b226 Mon Sep 17 00:00:00 2001 From: Carlo Lucibello Date: Sat, 5 Dec 2020 07:22:25 +0100 Subject: [PATCH 5/8] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index cbb0c6dc..aa4b761f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "FillArrays" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "0.10.1" +version = "0.11.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" From 9ef396f77625f3996e1de255e05d117ff8890101 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 10 Dec 2020 11:03:49 +0000 Subject: [PATCH 6/8] generalise to AbstractFill for consistency --- src/fillalgebra.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fillalgebra.jl b/src/fillalgebra.jl index e977f20c..2f87aa3c 100644 --- a/src/fillalgebra.jl +++ b/src/fillalgebra.jl @@ -147,12 +147,12 @@ end ## Matrix-Vector multiplication -*(a::Adjoint{T, <:StridedMatrix{T}}, b::Fill{T, 1}) where T = - reshape(sum(conj.(parent(a)); dims=1) .* b.value, size(parent(a), 2)) -*(a::Transpose{T, <:StridedMatrix{T}}, b::Fill{T, 1}) where T = - reshape(sum(parent(a); dims=1) .* b.value, size(parent(a), 2)) -*(a::StridedMatrix{T}, b::Fill{T, 1}) where T = - reshape(sum(a; dims=2) .* b.value, size(a, 1)) +*(a::Adjoint{T, <:StridedMatrix{T}}, b::AbstractFill{T, 1}) where T = + reshape(sum(conj.(parent(a)); dims=1) .* getindex_value(b), size(parent(a), 2)) +*(a::Transpose{T, <:StridedMatrix{T}}, b::AbstractFill{T, 1}) where T = + reshape(sum(parent(a); dims=1) .* getindex_value(b), size(parent(a), 2)) +*(a::StridedMatrix{T}, b::AbstractFill{T, 1}) where T = + reshape(sum(a; dims=2) .* getindex_value(b), size(a, 1)) function _adjvec_mul_zeros(a::Adjoint{T}, b::Zeros{S, 1}) where {T, S} From 15a15f19bc991c8c850a849c3cd6fea3e19d4e09 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 10 Dec 2020 11:09:47 +0000 Subject: [PATCH 7/8] Add vector' tests --- test/runtests.jl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index d2d4f260..59e99c15 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1037,10 +1037,21 @@ end Hermitian(rand(2,2))] @test x * Ones(2, 2) isa Matrix @test Ones(2, 2) * x isa Matrix + @test x * Ones(2) isa Vector + @test Ones(2)' * x isa Adjoint{Float64,<:Vector} @test x * Zeros(2, 2) isa Zeros @test Zeros(2, 2) * x isa Zeros + @test x * Zeros(2) isa Vector + @test x * Zeros(2) isa Zeros + @test Zeros(2)' * x isa Adjoint{Float64,<:Zeros} @test x * Fill(1., 2, 2) isa Matrix @test Fill(1., 2, 2) * x isa Matrix + @test x * Fill(1.,2) isa Vector + @test Fill(1.,2)' * x isa Adjoint{Float64,<:Vector} + @test x * Ones(2,2) == x * Fill(1., 2, 2) == x * ones(2,2) + @test Ones(2,2) * x == Fill(1., 2, 2) * x == Ones(2,2) * x + @test x * Ones(2) == x * Fill(1.,2) == x * ones(2) + @test Ones(2)'x == Fill(1.,2)'x == ones(2)'x end end @@ -1168,4 +1179,4 @@ end @test FillArrays.getindex_value(transpose(a)) == FillArrays.unique_value(transpose(a)) == 2.0 @test convert(Fill, transpose(a)) ≡ Fill(2.0,1,5) end -end \ No newline at end of file +end From 8350786996b5580d72bc9b01f3f9369435d3bbb4 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 10 Dec 2020 11:10:41 +0000 Subject: [PATCH 8/8] Update runtests.jl