Skip to content

Commit a5bc1e3

Browse files
author
Katharine Hyatt
committed
Support for norm of Diagonal
1 parent 8a50584 commit a5bc1e3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/blas/highlevel.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function LinearAlgebra.:(*)(
4545
dotu(n, x, stride(x, 1), y, stride(y, 1))
4646
end
4747

48+
LinearAlgebra.norm(x::Diagonal{T, <:StridedROCVector{T}}, p::Real=2) where {T<:Union{Float16, ComplexF16, ROCBLASFloat}} = norm(x.diag, p)
4849
LinearAlgebra.norm(x::ROCArray{T}) where T <: ROCBLASFloat = nrm2(length(x), x, stride(x, 1))
4950
LinearAlgebra.BLAS.asum(x::ROCArray{T}) where T <: ROCBLASFloat = asum(length(x), x, stride(x, 1))
5051

test/rocarray/blas.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ end
5858

5959
@test testf(reflect!, rand(T, m), rand(T, m), rand(real(T)), rand(real(T)))
6060
@test testf(reflect!, rand(T, m), rand(T, m), rand(real(T)), rand(T))
61+
62+
# norm of Diagonal
63+
x = rand(T, m)
64+
dDx = Diagonal(ROCArray(x))
65+
Dx = Diagonal(x)
66+
@test norm(dDx, 1) norm(Dx, 1)
67+
@test norm(dDx, 2) norm(Dx, 2)
68+
@test norm(dDx, Inf) norm(Dx, Inf)
6169
end
6270
end
6371

0 commit comments

Comments
 (0)