diff --git a/fluid/example/slicing/dtw/average-series.fld b/fluid/example/slicing/dtw/average-series.fld new file mode 100644 index 000000000..b5b998103 --- /dev/null +++ b/fluid/example/slicing/dtw/average-series.fld @@ -0,0 +1,15 @@ +let d x y = (x - y) * (x - y); +let avg x y = (x + y) / 2; +let avgSeq seq1 seq2 fn pairs = + let worker seq1 seq2 fn (i, j) = + let x = nth (i - 1) seq1; + y = nth (j - 1) seq2 + in + fn x y + in map (worker seq1 seq2 fn) pairs; + +let seq1 = [3,1,2,2,1]; + seq2 = [2,0,0,3,3,1,0]; + window = 2; + (costs, matched) = computeDTW seq1 seq2 d window +in avgSeq seq1 seq2 avg matched \ No newline at end of file diff --git a/fluid/example/slicing/dtw/compute-dtw.fld b/fluid/example/slicing/dtw/compute-dtw.fld index dfb018984..2b8ae2e7c 100644 --- a/fluid/example/slicing/dtw/compute-dtw.fld +++ b/fluid/example/slicing/dtw/compute-dtw.fld @@ -2,4 +2,4 @@ let d x y = (x - y) * (x - y); let seq1 = [3,1,2,2,1]; seq2 = [2,0,0,3,3,1,0]; window = 2 -in computeDTW seq1 seq2 d window +in computeDTW seq1 seq2 d window \ No newline at end of file diff --git a/test/Spec/Specs.purs b/test/Spec/Specs.purs index 01142b58c..c0d9598cd 100644 --- a/test/Spec/Specs.purs +++ b/test/Spec/Specs.purs @@ -49,6 +49,10 @@ misc_cases = \ Infty, Infty, FNum 6, FNum 10, FNum 5, FNum 5, FNum 6, Infty,\n\ \ Infty, Infty, Infty, FNum 7, FNum 9, FNum 9, FNum 5, FNum 6, ((1, 1) : ((2, 2) : ((2, 3) : ((3, 4) : ((4, 5) : ((5, 6) : ((5, 7) : []))))))))" } + , { file: "slicing/dtw/average-series" + , fwd_expect: + "(2.5 : (0.5 : (0.5 : (2.5 : (2.5 : (1.0 : (0.5 : [])))))))" + } ] desugar_cases :: Array TestSpec