### ----------------------------------------------------
### -- Math::DistanceFunctions
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/02-distance-functions.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

use lib <. lib>;

use Math::DistanceFunctions;

plan *;

## 1
is hamming-distance([1,2,2],[4,7,2]), 2, 'Hamming distance over integer vectors';

## 2
is hamming-distance('abc'.comb, 'cba'.comb), 2, 'Hamming distance over character vectors';

## 3
is hamming-distance('abc', 'cba'), 2, 'Hamming distance over strings';

## 4
is cosine-distance([1,1,0], [0,1,2]), 1 - 1 / sqrt(10), 'Cosine distance over arrays';

## 5
is euclidean-distance([1,1,0], [0,1,2]), sqrt(5), 'Euclidean distance over arrays';

## 6
dies-ok { euclidean-distance([1,1,0,2], [0,1,2]) }, 'Euclidean distance over non-same length arrays';

## 7
is manhattan-distance([1,2,3], [2,4,6]), 6, 'Manhattan distance over arrays';

## 8
is chessboard-distance([1,2,3], [2,4,6]), 3, 'Chessboard distance over arrays';

## 9
is bray-curtis-distance([1,2,3], [2,4,6]), 1/3, 'Bray-Curtis distance over arrays';

## 10
is canberra-distance([1,2,3], [2,4,6]), 1, 'Canberra distance over arrays';

## 11
# This does not work because of the idiotic Raku ideas about Seq and slurpy arguments.
#is norm([1,2,3] Z- [2,4,6], p => 1), 6, '1-Norm over array';
is norm(([1,2,3] Z- [2,4,6]), p => 1), 6, '1-Norm over array';

## 12
is norm(v => ([1,2,3] Z- [2,4,6]), p => 'max-norm'), 3, 'Max-norm over array';

## 13
is dot-product([1,2,3], [2,4,6]), 28, 'Dot product over arrays';

done-testing;


