Skip to content

Commit 67a3bd7

Browse files
authored
Merge branch 'master' into genericsyrk2
2 parents e91c1c4 + e53b50c commit 67a3bd7

File tree

6 files changed

+43
-15
lines changed

6 files changed

+43
-15
lines changed

src/LinearAlgebra.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,8 @@ end
726726
(\)(F::TransposeFactorization{T,<:LU}, B::VecOrMat{Complex{T}}) where {T<:BlasReal} =
727727
ldiv(F, B)
728728

729+
const default_peakflops_size = Int === Int32 ? 2048 : 4096
730+
729731
"""
730732
LinearAlgebra.peakflops(n::Integer=4096; eltype::DataType=Float64, ntrials::Integer=3, parallel::Bool=false)
731733
@@ -750,7 +752,7 @@ of the problem that is solved on each processor.
750752
This function requires at least Julia 1.1. In Julia 1.0 it is available from
751753
the standard library `InteractiveUtils`.
752754
"""
753-
function peakflops(n::Integer=4096; eltype::DataType=Float64, ntrials::Integer=3, parallel::Bool=false)
755+
function peakflops(n::Integer=default_peakflops_size; eltype::DataType=Float64, ntrials::Integer=3, parallel::Bool=false)
754756
t = zeros(Float64, ntrials)
755757
for i=1:ntrials
756758
a = ones(eltype,n,n)

src/bunchkaufman.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,8 @@ julia> d, u, p = S; # destructuring via iteration
182182
julia> d == S.D && u == S.U && p == S.p
183183
true
184184
185-
julia> S.U*S.D*S.U' - S.P*A*S.P'
186-
2×2 Matrix{Float64}:
187-
0.0 0.0
188-
0.0 0.0
185+
julia> S.U * S.D * S.U' ≈ S.P * A * S.P'
186+
true
189187
190188
julia> S = bunchkaufman(Symmetric(A, :L))
191189
BunchKaufman{Float64, Matrix{Float64}, Vector{Int64}}
@@ -202,10 +200,8 @@ permutation:
202200
2
203201
1
204202
205-
julia> S.L*S.D*S.L' - A[S.p, S.p]
206-
2×2 Matrix{Float64}:
207-
0.0 0.0
208-
0.0 0.0
203+
julia> S.L * S.D * S.L' ≈ A[S.p, S.p]
204+
true
209205
```
210206
"""
211207
bunchkaufman(A::AbstractMatrix{T}, rook::Bool=false; check::Bool = true) where {T} =

src/matmul.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ function __generic_matvecmul!(f::F, C::AbstractVector, A::AbstractVecOrMat, B::A
10231023
@inbounds begin
10241024
if length(B) == 0
10251025
for k = eachindex(C)
1026-
@stable_muladdmul _modify!(MulAddMul(alpha,beta), false, C, k)
1026+
@stable_muladdmul _modify!(MulAddMul(alpha,beta), zero(eltype(C)), C, k)
10271027
end
10281028
else
10291029
for k = eachindex(C)
@@ -1046,7 +1046,7 @@ function __generic_matvecmul!(::typeof(identity), C::AbstractVector, A::Abstract
10461046
if !iszero(beta)
10471047
C[i] *= beta
10481048
elseif length(B) == 0
1049-
C[i] = false
1049+
C[i] = zero(eltype(C))
10501050
else
10511051
C[i] = zero(A[i]*B[1] + A[i]*B[1])
10521052
end

src/symmetric.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function copyto!(dest::Symmetric, src::Symmetric)
352352
elseif src.uplo == dest.uplo
353353
copytrito!(dest.data, src.data, src.uplo)
354354
else
355-
transpose!(dest.data, Base.unalias(dest.data, src.data))
355+
copytrito!(dest.data, transpose(Base.unalias(dest.data, src.data)), dest.uplo)
356356
end
357357
return dest
358358
end
@@ -363,7 +363,7 @@ function copyto!(dest::Hermitian, src::Hermitian)
363363
elseif src.uplo == dest.uplo
364364
copytrito!(dest.data, src.data, src.uplo)
365365
else
366-
adjoint!(dest.data, Base.unalias(dest.data, src.data))
366+
copytrito!(dest.data, adjoint(Base.unalias(dest.data, src.data)), dest.uplo)
367367
end
368368
return dest
369369
end
@@ -445,8 +445,6 @@ adjoint(A::Hermitian) = A
445445
transpose(A::Symmetric) = A
446446
adjoint(A::Symmetric{<:Real}) = A
447447
transpose(A::Hermitian{<:Real}) = A
448-
adjoint(A::Symmetric) = Adjoint(A)
449-
transpose(A::Hermitian) = Transpose(A)
450448

451449
real(A::Symmetric{<:Real}) = A
452450
real(A::Hermitian{<:Real}) = A

test/matmul.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ using Base: rtoldefault
66
using Test, LinearAlgebra, Random
77
using LinearAlgebra: mul!, Symmetric, Hermitian
88

9+
const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
10+
11+
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
12+
using .Main.SizedArrays
13+
914
## Test Julia fallbacks to BLAS routines
1015

1116
mul_wrappers = [
@@ -1176,4 +1181,16 @@ end
11761181
end
11771182
end
11781183

1184+
@testset "zero-length generic matvec" begin
1185+
m = SizedArrays.SizedArray{(2,2)}(ones(2,2))
1186+
A = fill(m, 2, 0)
1187+
v = fill(m, size(A,2))
1188+
w = similar(v, size(A,1))
1189+
mul!(w, A, v)
1190+
@test all(iszero, w)
1191+
A = fill(m, 0, 2)
1192+
mul!(w, A', v)
1193+
@test all(iszero, w)
1194+
end
1195+
11791196
end # module TestMatmul

test/symmetric.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,4 +1163,19 @@ end
11631163
end
11641164
end
11651165

1166+
@testset "copyto! with mismatched uplo" begin
1167+
for (S,tf) in ((Symmetric, transpose), (Hermitian, adjoint))
1168+
for (uplo1,uplo2) in [(:U,:L), (:L, :U)]
1169+
M = Matrix{Complex{BigFloat}}(undef, 2, 2)
1170+
M[1,1] = M[2,2] = 3
1171+
isupper = uplo1 == :U
1172+
M[1+!isupper, 1+isupper] = 4+3im
1173+
H1 = S(M, uplo1)
1174+
H2 = 2 * S(tf(M), uplo2)
1175+
copyto!(H2, H1)
1176+
@test H2 == H1
1177+
end
1178+
end
1179+
end
1180+
11661181
end # module TestSymmetric

0 commit comments

Comments
 (0)