|
837 | 837 | end |
838 | 838 | end |
839 | 839 |
|
| 840 | +@testset "distance functions" begin |
| 841 | + x = [1., 2., 3.]; y = [1., 2.1, 3.4] |
| 842 | + @test lpdist(x, y, 1) ≈ norm(x .- y, 1) |
| 843 | + @test lpdist(x, y, 2) ≈ norm(x .- y, 2) |
| 844 | + @test lpdist(x, y, 4) ≈ norm(x .- y, 4) |
| 845 | + @test lpdist(x, y, 3.5) ≈ norm(x .- y, 3.5) |
| 846 | + @test euclidean(x, y) ≈ norm(x .- y, 2) |
| 847 | + @test l2dist(x, y) ≈ norm(x .- y, 2) |
| 848 | + @test l1dist(x, y) ≈ norm(x .- y, 1) |
| 849 | + @test lpdist(x, y, 0) ≈ norm(x .- y, 0) |
| 850 | + @test lpdist(x, y, Inf) ≈ norm(x .- y, Inf) |
| 851 | + @test_throws DomainError lpdist(x, y, -1) |
| 852 | + @test_throws DomainError lpdist(x, y, -0.5) |
| 853 | + @test_throws DimensionMismatch lpdist(x, [1.5, 2.0, 2.0, 3.1], 1) |
| 854 | +end |
| 855 | + |
840 | 856 | end # module TestGeneric |
0 commit comments