JuliaMath / Calculus.jl

Calculus functions in Julia
Other
275 stars 78 forks source link

norm(matrix) -> opnorm(matrix) in Julia 0.7 #125

Closed stevengj closed 10 months ago

stevengj commented 6 years ago

It looks like may be using norm(matrix). In Julia 0.7, this will compute the Frobenius norm (vecnorm in Julia 0.6), due to JuliaLang/julia#27401. If you want the induced/operator norm as in Julia 0.6, use opnorm(matrix) instead, or Compat.opnorm(matrix) to work in 0.6 and 0.7 (JuliaLang/Compat.jl#577).

Note that, for testing purposes, rather than @test norm(A - B) ≤ tol, it is usually preferred to do @test A ≈ B or @test A ≈ B rtol=... (which uses isapprox).

MahyarFardin commented 10 months ago

It looks like may be using norm(matrix). In Julia 0.7, this will compute the Frobenius norm (vecnorm in Julia 0.6), due to JuliaLang/julia#27401. If you want the induced/operator norm as in Julia 0.6, use opnorm(matrix) instead, or Compat.opnorm(matrix) to work in 0.6 and 0.7 (JuliaLang/Compat.jl#577).

Note that, for testing purposes, rather than @test norm(A - B) ≤ tol, it is usually preferred to do @test A ≈ B or @test A ≈ B rtol=... (which uses isapprox).

Hi, although the documentation is not clear about this, you can find that they are the same; as they define an inequality in isapprox function it does not really affect except this one is faster.

stevengj commented 10 months ago

I'm not sure what you mean by "they". norm(A - B) ≤ tol is not the same as A ≈ B since the former is an absolute tolerance while the latter uses a relative tolerance by default (though you could specify @test A ≈ B atol=tol to get a mathematically equivalent test to @test norm(A - B) ≤ tol. Also, @test A ≈ B has more informative printing if there is an error.

In any case, that's an aside to the reason for this issue, which is that this package was using a function (norm) which changed meaning in Julia 0.7, so we wanted to notify them in case they were reliant on the old behavior. As this package declared itself to be compatible with Julia 1, with passing tests, I think this issue can be closed.