@@ -33,7 +33,7 @@ public static class DynamicTimeWarping
33
33
/// <returns>
34
34
/// The DTW distance between the input sequences.
35
35
/// </returns>
36
- public static double GetDistance < T , U > ( IReadOnlyList < T > xs , IReadOnlyList < U > ys , IDistance < T , U > distance , int w = int . MaxValue )
36
+ public static double GetDistance < T , U > ( IReadOnlyList < T > xs , IReadOnlyList < U > ys , IDistance < T , U > distance , int w )
37
37
{
38
38
ThrowHelper . ThrowIfNull ( xs , nameof ( xs ) ) ;
39
39
ThrowHelper . ThrowIfNull ( ys , nameof ( ys ) ) ;
@@ -52,6 +52,32 @@ public static double GetDistance<T, U>(IReadOnlyList<T> xs, IReadOnlyList<U> ys,
52
52
return Compute ( xs , ys , distance , w , false ) . Distance ;
53
53
}
54
54
55
+ /// <summary>
56
+ /// Applies the DTW (dynamic time warping) matching algorithm to the given two sequences.
57
+ /// </summary>
58
+ /// <typeparam name="T">
59
+ /// The type of elements in the first sequence.
60
+ /// </typeparam>
61
+ /// <typeparam name="U">
62
+ /// The type of elements in the second sequence.
63
+ /// </typeparam>
64
+ /// <param name="xs">
65
+ /// The first input sequence.
66
+ /// </param>
67
+ /// <param name="ys">
68
+ /// The second input sequence.
69
+ /// </param>
70
+ /// <param name="distance">
71
+ /// An instance of <see cref="IDistance{T, U}"/> to compute the distance between two elements.
72
+ /// </param>
73
+ /// <returns>
74
+ /// The DTW distance between the input sequences.
75
+ /// </returns>
76
+ public static double GetDistance < T , U > ( IReadOnlyList < T > xs , IReadOnlyList < U > ys , IDistance < T , U > distance )
77
+ {
78
+ return GetDistance ( xs , ys , distance , int . MaxValue ) ;
79
+ }
80
+
55
81
/// <summary>
56
82
/// Applies the DTW (dynamic time warping) matching algorithm to the given two sequences.
57
83
/// </summary>
@@ -77,7 +103,7 @@ public static double GetDistance<T, U>(IReadOnlyList<T> xs, IReadOnlyList<U> ys,
77
103
/// <returns>
78
104
/// A tuple containing the DTW distance and the alignment path between the input sequences.
79
105
/// </returns>
80
- public static ( double Distance , IndexPair [ ] Alignment ) GetDistanceAndAlignment < T , U > ( IReadOnlyList < T > xs , IReadOnlyList < U > ys , IDistance < T , U > distance , int w = int . MaxValue )
106
+ public static ( double Distance , IndexPair [ ] Alignment ) GetDistanceAndAlignment < T , U > ( IReadOnlyList < T > xs , IReadOnlyList < U > ys , IDistance < T , U > distance , int w )
81
107
{
82
108
ThrowHelper . ThrowIfNull ( xs , nameof ( xs ) ) ;
83
109
ThrowHelper . ThrowIfNull ( ys , nameof ( ys ) ) ;
@@ -97,6 +123,32 @@ public static (double Distance, IndexPair[] Alignment) GetDistanceAndAlignment<T
97
123
return ( result . Distance , result . Alignment ! ) ;
98
124
}
99
125
126
+ /// <summary>
127
+ /// Applies the DTW (dynamic time warping) matching algorithm to the given two sequences.
128
+ /// </summary>
129
+ /// <typeparam name="T">
130
+ /// The type of elements in the first sequence.
131
+ /// </typeparam>
132
+ /// <typeparam name="U">
133
+ /// The type of elements in the second sequence.
134
+ /// </typeparam>
135
+ /// <param name="xs">
136
+ /// The first input sequence.
137
+ /// </param>
138
+ /// <param name="ys">
139
+ /// The second input sequence.
140
+ /// </param>
141
+ /// <param name="distance">
142
+ /// An instance of <see cref="IDistance{T, U}"/> to compute the distance between two elements.
143
+ /// </param>
144
+ /// <returns>
145
+ /// A tuple containing the DTW distance and the alignment path between the input sequences.
146
+ /// </returns>
147
+ public static ( double Distance , IndexPair [ ] Alignment ) GetDistanceAndAlignment < T , U > ( IReadOnlyList < T > xs , IReadOnlyList < U > ys , IDistance < T , U > distance )
148
+ {
149
+ return GetDistanceAndAlignment ( xs , ys , distance , int . MaxValue ) ;
150
+ }
151
+
100
152
private static ( double Distance , IndexPair [ ] ? Alignment ) Compute < T , U > ( IReadOnlyList < T > xs , IReadOnlyList < U > ys , IDistance < T , U > distance , int w , bool computeAlignment )
101
153
{
102
154
var n = xs . Count ;
0 commit comments