Skip to content

Commit

Permalink
implement suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
lxvm committed Jun 24, 2024
1 parent f38c796 commit 2b9e19d
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/SHermitianCompact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,25 @@ LinearAlgebra.issymmetric(a::SHermitianCompact) = true
end
end

@inline Base.:*(a::Number, b::SHermitianCompact) = SHermitianCompact(a * b.lowertriangle)
@inline Base.:*(a::SHermitianCompact, b::Number) = SHermitianCompact(a.lowertriangle * b)
@inline Base.:*(a::Complex, b::SHermitianCompact) = a * SMatrix(b)
@inline Base.:*(a::SHermitianCompact, b::Complex) = SMatrix(a) * b

@inline Base.:/(a::SHermitianCompact, b::Number) = SHermitianCompact(a.lowertriangle / b)
@inline Base.:\(a::Number, b::SHermitianCompact) = SHermitianCompact(a \ b.lowertriangle)
@inline Base.:/(a::SHermitianCompact, b::Complex) = SMatrix(a) / b
@inline Base.:\(a::Complex, b::SHermitianCompact) = a \ SMatrix(b)

@inline Base.muladd(scalar::Complex, a::SHermitianCompact, b::StaticArray) = muladd(scalar, SMatrix(a), b)
@inline Base.muladd(a::SHermitianCompact, scalar::Complex, b::StaticArray) = muladd(SMatrix(a), scalar, b)

@inline Base.FastMath.mul_fast(a::Complex, b::SHermitianCompact) = Base.FastMath.mul_fast(a, SMatrix(b))
@inline Base.FastMath.mul_fast(a::SHermitianCompact, b::Complex) = Base.FastMath.mul_fast(SMatrix(a), b)
@inline Base.:*(a::Real, b::SHermitianCompact) = SHermitianCompact(a * b.lowertriangle)
@inline Base.:*(a::SHermitianCompact, b::Real) = SHermitianCompact(a.lowertriangle * b)
@inline Base.:*(a::Number, b::SHermitianCompact) = a * SMatrix(b)
@inline Base.:*(a::SHermitianCompact, b::Number) = SMatrix(a) * b

Check warning on line 157 in src/SHermitianCompact.jl

View check run for this annotation

Codecov / codecov/patch

src/SHermitianCompact.jl#L154-L157

Added lines #L154 - L157 were not covered by tests

@inline Base.:/(a::SHermitianCompact, b::Real) = SHermitianCompact(a.lowertriangle / b)
@inline Base.:\(a::Real, b::SHermitianCompact) = SHermitianCompact(a \ b.lowertriangle)
@inline Base.:/(a::SHermitianCompact, b::Number) = SMatrix(a) / b
@inline Base.:\(a::Number, b::SHermitianCompact) = a \ SMatrix(b)

Check warning on line 162 in src/SHermitianCompact.jl

View check run for this annotation

Codecov / codecov/patch

src/SHermitianCompact.jl#L159-L162

Added lines #L159 - L162 were not covered by tests

@inline Base.muladd(scalar::Number, a::SHermitianCompact, b::StaticArray) = muladd(scalar, SMatrix(a), b)
@inline Base.muladd(a::SHermitianCompact, scalar::Number, b::StaticArray) = muladd(SMatrix(a), scalar, b)
@inline Base.muladd(scalar::Real, a::SHermitianCompact, b::StaticArray) = map((ai, bi) -> muladd(scalar, ai, bi), a, b)
@inline Base.muladd(a::SHermitianCompact, scalar::Real, b::StaticArray) = map((ai, bi) -> muladd(ai, scalar, bi), a, b)

Check warning on line 167 in src/SHermitianCompact.jl

View check run for this annotation

Codecov / codecov/patch

src/SHermitianCompact.jl#L164-L167

Added lines #L164 - L167 were not covered by tests

@inline Base.FastMath.mul_fast(a::Number, b::SHermitianCompact) = Base.FastMath.mul_fast(a, SMatrix(b))
@inline Base.FastMath.mul_fast(a::SHermitianCompact, b::Number) = Base.FastMath.mul_fast(SMatrix(a), b)
@inline Base.FastMath.mul_fast(a::Real, b::SHermitianCompact) = map(c -> Base.FastMath.mul_fast(a, c), b)
@inline Base.FastMath.mul_fast(a::SHermitianCompact, b::Real) = map(c -> Base.FastMath.mul_fast(c, b), a)

Check warning on line 172 in src/SHermitianCompact.jl

View check run for this annotation

Codecov / codecov/patch

src/SHermitianCompact.jl#L169-L172

Added lines #L169 - L172 were not covered by tests

@generated function _plus_uniform(::Size{S}, a::SHermitianCompact{N, T, L}, λ) where {S, N, T, L}
@assert S[1] == N
Expand Down

0 comments on commit 2b9e19d

Please sign in to comment.