Skip to content

Commit 2a8f6dc

Browse files
committed
minor simplifications
1 parent c90ff8e commit 2a8f6dc

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/fillmap.jl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
struct FillMap{T} <: LinearMap{T}
22
λ::T
33
size::Dims{2}
4-
function FillMap::T, dims) where {T}
5-
all(d -> d >= 0, dims) || throw(ArgumentError("dims of FillMap must be non-negative"))
6-
promote_type(T, typeof(λ)) == T || throw(InexactError())
4+
function FillMap::T, dims::Dims{2}) where {T}
5+
all(>=(0), dims) || throw(ArgumentError("dims of FillMap must be non-negative"))
76
return new{T}(λ, dims)
87
end
98
end
@@ -12,7 +11,7 @@ end
1211
Base.size(A::FillMap) = A.size
1312
MulStyle(A::FillMap) = FiveArg()
1413
LinearAlgebra.issymmetric(A::FillMap) = A.size[1] == A.size[2]
15-
LinearAlgebra.ishermitian(A::FillMap) = isreal(A) && A.size[1] == A.size[2]
14+
LinearAlgebra.ishermitian(A::FillMap) = isreal(A.λ) && A.size[1] == A.size[2]
1615
LinearAlgebra.isposdef(A::FillMap) = (size(A, 1) == size(A, 2) == 1 && isposdef(A.λ))
1716
Base.:(==)(A::FillMap, B::FillMap) = A.λ == B.λ && A.size == B.size
1817

@@ -31,7 +30,6 @@ end
3130
function _unsafe_mul!(y::AbstractVecOrMat, A::FillMap, x::AbstractVector, α::Number, β::Number)
3231
if iszero(α)
3332
!isone(β) && rmul!(y, β)
34-
return y
3533
else
3634
temp = A.λ * sum(x) * α
3735
if iszero(β)
@@ -53,8 +51,6 @@ Base.:(*)(λ::RealOrComplex, A::FillMap) = FillMap(λ * A.λ, size(A))
5351
Base.:(*)(A::FillMap, λ::RealOrComplex) = FillMap(A.λ * λ, size(A))
5452

5553
function Base.:(*)(A::FillMap, B::FillMap)
56-
mA, nA = size(A)
57-
mB, nB = size(B)
58-
nA != mB && throw(DimensionMismatch())
59-
return FillMap(A.λ*B.λ*nA, (mA, nB))
54+
check_dim_mul(A, B)
55+
return FillMap(A.λ*B.λ*nA, (size(A, 1), size(B, 2)))
6056
end

0 commit comments

Comments
 (0)