Skip to content

Commit 7a3968a

Browse files
committed
Prepare for release.
1 parent fb30284 commit 7a3968a

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# v1.0.4
2+
3+
* Added `Special.GetMemoryFromUnmanagedPointer` to support matrices backed by unmanaged memory.
4+
* Added `DynamicTimeWarping`.
5+
16
# v1.0.3
27

38
* Indexers for `Vec<T>` and `Mat<T>` now return `ref T`, improving usability.

NumFlat/NumFlat.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1010
<Title>NumFlat</Title>
11-
<Version>1.0.3</Version>
11+
<Version>1.0.4</Version>
1212
<Authors>Nobuaki Tanaka</Authors>
1313
<Description>A numerical computation library for C#</Description>
1414
<PackageProjectUrl>https://github.com/sinshu/numflat</PackageProjectUrl>

NumFlat/TimeSeries/DynamicTimeWarping.cs

+54-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static class DynamicTimeWarping
3333
/// <returns>
3434
/// The DTW distance between the input sequences.
3535
/// </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)
3737
{
3838
ThrowHelper.ThrowIfNull(xs, nameof(xs));
3939
ThrowHelper.ThrowIfNull(ys, nameof(ys));
@@ -52,6 +52,32 @@ public static double GetDistance<T, U>(IReadOnlyList<T> xs, IReadOnlyList<U> ys,
5252
return Compute(xs, ys, distance, w, false).Distance;
5353
}
5454

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+
5581
/// <summary>
5682
/// Applies the DTW (dynamic time warping) matching algorithm to the given two sequences.
5783
/// </summary>
@@ -77,7 +103,7 @@ public static double GetDistance<T, U>(IReadOnlyList<T> xs, IReadOnlyList<U> ys,
77103
/// <returns>
78104
/// A tuple containing the DTW distance and the alignment path between the input sequences.
79105
/// </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)
81107
{
82108
ThrowHelper.ThrowIfNull(xs, nameof(xs));
83109
ThrowHelper.ThrowIfNull(ys, nameof(ys));
@@ -97,6 +123,32 @@ public static (double Distance, IndexPair[] Alignment) GetDistanceAndAlignment<T
97123
return (result.Distance, result.Alignment!);
98124
}
99125

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+
100152
private static (double Distance, IndexPair[]? Alignment) Compute<T, U>(IReadOnlyList<T> xs, IReadOnlyList<U> ys, IDistance<T, U> distance, int w, bool computeAlignment)
101153
{
102154
var n = xs.Count;

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ Matrix 3x3-Double
706706
- ⬜ Bayes classifier
707707
- ⬜ SVM (support vector machine)
708708
* ⬜ Time series
709-
- DTW (dynamic time warping)
709+
- DTW (dynamic time warping)
710710
- ⬜ HMM (hidden Markov model)
711711
* 🚧 Signal processing
712712
- ✅ FFT (fast Fourier transform)

0 commit comments

Comments
 (0)