Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ function LinearAlgebra.axpby!(α::Number, x::ComponentArray, β::Number, y::Comp
axpby!(α, getdata(x), β, getdata(y))
return ComponentArray(y, getaxes(y))
end

lmul!(a::Number, B::ComponentArray) = ComponentArray(lmul!(a, getdata(B)), getaxes(B))

14 changes: 13 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ caa = ComponentArray(a = ca, b = sq_mat)

_a, _b, _c = Val.((:a, :b, :c))


## Tests
@testset "Allocations and Inference" begin
@test @ballocated($ca.c.a.a) == 0
Expand Down Expand Up @@ -690,6 +689,19 @@ end
@test_throws ArgumentError axpby!(2, x, 3, y)
end

@testset "lmul!" begin
a = rand()
x = ComponentArray(a = rand(4), b = rand(4))

xdata = copy(getdata(x))
xaxes = getaxes(x)

y = lmul!(a, x)
@test y == x
@test getdata(x) ≈ a * xdata
@test getaxes(x) == xaxes
end

@testset "Autodiff" begin
include("autodiff_tests.jl")
end
Expand Down