We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
norm(::AbstractFill, p::Int)
1 parent baace96 commit 26a54e1Copy full SHA for 26a54e1
Project.toml
@@ -1,6 +1,6 @@
1
name = "FillArrays"
2
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
3
-version = "1.14.0"
+version = "1.14.1"
4
5
[deps]
6
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
src/fillalgebra.jl
@@ -496,8 +496,14 @@ end
496
normp(a::AbstractZeros, p) = norm(getindex_value(a))
497
498
norm1(a::AbstractFill) = length(a)*norm(getindex_value(a))
499
-norm2(a::AbstractFill) = sqrt(length(a))*norm(getindex_value(a))
500
-normp(a::AbstractFill, p) = (length(a))^(1/p)*norm(getindex_value(a))
+function norm2(a::AbstractFill)
+ nrm1 = norm(getindex_value(a))
501
+ sqrt(oftype(nrm1, length(a)))*nrm1
502
+end
503
+function normp(a::AbstractFill, p)
504
505
+ (length(a))^(1/oftype(nrm1, p))*nrm1
506
507
normInf(a::AbstractFill) = norm(getindex_value(a))
508
normMinusInf(a::AbstractFill) = norm(getindex_value(a))
509
test/runtests.jl
@@ -1888,11 +1888,12 @@ end
1888
end
1889
1890
@testset "norm" begin
1891
- for a in (Zeros{Int}(5), Zeros(5,3), Zeros(2,3,3),
1892
- Ones{Int}(5), Ones(5,3), Ones(2,3,3),
1893
- Fill(2.3,5), Fill([2.3,4.2],5), Fill(4)),
+ for a in (Zeros{Int}(5), Zeros(5,3), Zeros(2,3,3), Zeros{ComplexF32}(5),
+ Ones{Int}(5), Ones(5,3), Ones(2,3,3), Ones{ComplexF32}(5),
+ Fill(2.3,5), Fill([2.3,4.2],5), Fill(4), Fill(2f0+3f0im,5)),
1894
p in (-Inf, 0, 0.1, 1, 2, 3, Inf)
1895
- @test norm(a,p) ≈ norm(Array(a),p)
+ @test @inferred(norm(a,p)) ≈ norm(Array(a),p)
1896
+ @test typeof(norm(a,p)) == typeof(norm(Array(a),p))
1897
1898
1899
0 commit comments