Skip to content

Commit f2db9d8

Browse files
authored
Add norm to Vcat and Hcat (#67)
* Add norm to Vcat and Hcat * v0.12.2 * fix empty vcat norm * don't overload normMinusInf
1 parent 8dc5c4f commit f2db9d8

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LazyArrays"
22
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
3-
version = "0.12.1"
3+
version = "0.12.2"
44

55
[deps]
66
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"

src/LazyArrays.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ import Base.Broadcast: BroadcastStyle, AbstractArrayStyle, Broadcasted, broadcas
3636
combine_eltypes, DefaultArrayStyle, instantiate, materialize,
3737
materialize!, eltypes
3838

39-
import LinearAlgebra: AbstractTriangular, AbstractQ, checksquare, pinv, fill!, tilebufsize, Abuf, Bbuf, Cbuf, dot, factorize, qr, lu, cholesky
39+
import LinearAlgebra: AbstractTriangular, AbstractQ, checksquare, pinv, fill!, tilebufsize, Abuf, Bbuf, Cbuf, dot, factorize, qr, lu, cholesky,
40+
norm2, norm1, normInf, normMinusInf
4041

4142
import LinearAlgebra.BLAS: BlasFloat, BlasReal, BlasComplex
4243

src/lazyconcat.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,15 @@ end
538538

539539
dot(a::CachedArray, b::AbstractArray) = materialize(Dot(a,b))
540540
dot(a::LazyArray, b::AbstractArray) = materialize(Dot(a,b))
541+
542+
543+
###
544+
# norm
545+
###
546+
547+
for Cat in (:Vcat, :Hcat)
548+
for (op,p) in ((:norm1,1), (:norm2,2), (:normInf,Inf))
549+
@eval $op(a::$Cat) = $op(norm.(a.args,$p))
550+
end
551+
@eval normp(a::$Cat, p) = norm(norm.(a.args, p), p)
552+
end

test/concattests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,12 @@ import LazyArrays: MemoryLayout, DenseColumnMajor, PaddedLayout, materialize!, M
347347
a[3] = 2; b[3] = 2; b[5]=0;
348348
@test a == b
349349
end
350+
351+
@testset "norm" begin
352+
for a in (Vcat(1,2,Fill(5,3)), Hcat([1,2],randn(2,2)), Vcat(1,Float64[])),
353+
p in (-Inf, 0, 0.1, 1, 2, 3, Inf)
354+
@show p
355+
@test norm(a,p) norm(Array(a),p)
356+
end
357+
end
350358
end

0 commit comments

Comments
 (0)