Skip to content

Commit 73be7fd

Browse files
committed
Fixed DLLNormalization, DLLPolynomial, DLLStatistics, DistancesTests, MatrixxTests and RegularizationTests
1 parent 71fb237 commit 73be7fd

File tree

6 files changed

+122
-146
lines changed

6 files changed

+122
-146
lines changed

KhivaCsharp/KhivaCSharpNUnitTest/DistancesTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,5 @@ public void TestSquaredEuclidean()
100100
Assert.AreEqual(expected, result);
101101
}
102102
}
103-
104103
}
105104
}

KhivaCsharp/KhivaCSharpNUnitTest/MatrixTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,5 @@ public void TestFindbestNMotifsConsecutive()
329329
}
330330
}
331331
}
332-
333332
}
334333
}

KhivaCsharp/KhivaCSharpNUnitTest/RegularizationTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,5 @@ public void TestGroupByDoubleKeyDoubleValueColumn()
7070
Assert.AreEqual(expected, result);
7171
}
7272
}
73-
7473
}
7574
}

KhivaCsharp/KhivaCsharp/Interop/DLLNormalization.cs

Lines changed: 64 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,102 +18,92 @@ namespace khiva.interop
1818
/// </summary>
1919
public static class DLLNormalization
2020
{
21-
22-
/// <summary> Normalizes the given time series according to its maximum value and adjusts each value within the range
23-
/// (-1, 1).
24-
///</summary>
25-
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
26-
/// one indicates the number of time series.</param>
27-
/// <param name="result">An array with the same dimensions as tss, whose values (time series in dimension 0) have been
28-
/// normalized by dividing each number by 10^j, where j is the number of integer digits of the max number in the time
29-
/// series.</param>
21+
/// <summary> Normalizes the given time series according to its maximum value and adjusts each value within the range
22+
/// (-1, 1).
23+
///</summary>
24+
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
25+
/// one indicates the number of time series.</param>
26+
/// <param name="result">An array with the same dimensions as tss, whose values (time series in dimension 0) have been
27+
/// normalized by dividing each number by 10^j, where j is the number of integer digits of the max number in the time series.</param>
3028
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
3129
public extern static void decimal_scaling_norm([In] ref IntPtr tss, [Out] out IntPtr result);
32-
3330

34-
/// <summary> Same as decimal_scaling_norm, but it performs the operation in place, without allocating further memory.
35-
///</summary>
36-
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
37-
/// one indicates the number of time series.</param>
31+
/// <summary> Same as decimal_scaling_norm, but it performs the operation in place, without allocating further memory.
32+
///</summary>
33+
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
34+
/// one indicates the number of time series.</param>
3835
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
3936
public extern static void decimal_scaling_norm_in_place([In, Out] ref IntPtr tss);
40-
4137

42-
/// <summary> Normalizes the given time series according to its minimum and maximum value and adjusts each value within the
43-
/// range [low, high].
44-
///</summary>
45-
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
46-
/// one indicates the number of time series.</param>
47-
/// <param name="high">Maximum final value (Defaults to 1.0).</param>
48-
/// <param name="low"> Minimum final value (Defaults to 0.0).</param>
49-
/// <param name="epsilon">Safeguard for constant (or near constant) time series as the operation implies a unit scale operation
50-
/// between min and max values in the tss.</param>
51-
/// <param name="result">KhivaArray with the same dimensions as tss, whose values (time series in dimension 0) have been
52-
/// normalized by maximum and minimum values, and scaled as per high and low parameters.</param>
38+
/// <summary> Normalizes the given time series according to its minimum and maximum value and adjusts each value within the
39+
/// range [low, high].
40+
///</summary>
41+
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
42+
/// one indicates the number of time series.</param>
43+
/// <param name="high">Maximum final value (Defaults to 1.0).</param>
44+
/// <param name="low"> Minimum final value (Defaults to 0.0).</param>
45+
/// <param name="epsilon">Safeguard for constant (or near constant) time series as the operation implies a unit scale operation
46+
/// between min and max values in the tss.</param>
47+
/// <param name="result">KhivaArray with the same dimensions as tss, whose values (time series in dimension 0) have been
48+
/// normalized by maximum and minimum values, and scaled as per high and low parameters.</param>
5349
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
5450
public extern static void max_min_norm([In] ref IntPtr tss, [In] ref double high, [In] ref double low, [In] ref double epsilon, [Out] out IntPtr result);
55-
5651

57-
/// <summary> Same as max_min_norm, but it performs the operation in place, without allocating further memory.
58-
///</summary>
59-
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
60-
/// one indicates the number of time series.</param>
61-
/// <param name="high">Maximum final value (Defaults to 1.0).</param>
62-
/// <param name="low"> Minimum final value (Defaults to 0.0).</param>
63-
/// <param name="epsilon">Safeguard for constant (or near constant) time series as the operation implies a unit scale operation
64-
/// between min and max values in the tss.</param>
52+
/// <summary> Same as max_min_norm, but it performs the operation in place, without allocating further memory.
53+
///</summary>
54+
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
55+
/// one indicates the number of time series.</param>
56+
/// <param name="high">Maximum final value (Defaults to 1.0).</param>
57+
/// <param name="low"> Minimum final value (Defaults to 0.0).</param>
58+
/// <param name="epsilon">Safeguard for constant (or near constant) time series as the operation implies a unit scale operation
59+
/// between min and max values in the tss.</param>
6560
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
6661
public extern static void max_min_norm_in_place([In, Out] ref IntPtr tss, [In] ref double high, [In] ref double low, [In] ref double epsilon);
67-
6862

69-
/// <summary> Normalizes the given time series according to its maximum-minimum value and its mean. It follows the following
70-
/// formulae:
71-
/// \f[
72-
/// \acute{x} = \frac{x - mean(x)}{max(x) - min(x)}.
73-
/// \f]
74-
///</summary>
75-
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
76-
/// one indicates the number of time series.
77-
///</param>
78-
/// <param name="result">An array with the same dimensions as tss, whose values (time series in dimension 0) have been
79-
/// normalized by substracting the mean from each number and dividing each number by \f$ max(x) - min(x)\f$, in the
80-
/// time series.</param>
63+
/// <summary> Normalizes the given time series according to its maximum-minimum value and its mean. It follows the following
64+
/// formulae:
65+
/// \f[
66+
/// \acute{x} = \frac{x - mean(x)}{max(x) - min(x)}.
67+
/// \f]
68+
///</summary>
69+
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
70+
/// one indicates the number of time series.
71+
///</param>
72+
/// <param name="result">An array with the same dimensions as tss, whose values (time series in dimension 0) have been
73+
/// normalized by substracting the mean from each number and dividing each number by \f$ max(x) - min(x)\f$, in the
74+
/// time series.</param>
8175
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
8276
public extern static void mean_norm([In] ref IntPtr tss, [Out] out IntPtr result);
83-
8477

85-
/// <summary> Normalizes the given time series according to its maximum-minimum value and its mean. It follows the following
86-
/// formulae:
87-
/// \f[
88-
/// \acute{x} = \frac{x - mean(x)}{max(x) - min(x)}.
89-
/// \f]
90-
///</summary>
91-
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
92-
/// one indicates the number of time series.</param>
78+
/// <summary> Normalizes the given time series according to its maximum-minimum value and its mean. It follows the following
79+
/// formulae:
80+
/// \f[
81+
/// \acute{x} = \frac{x - mean(x)}{max(x) - min(x)}.
82+
/// \f]
83+
///</summary>
84+
/// <param name="tss">Expects an input array whose dimension zero is the length of the time series (all the same) and dimension
85+
/// one indicates the number of time series.</param>
9386
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
9487
public extern static void mean_norm_in_place([In, Out] ref IntPtr tss);
95-
9688

97-
/// <summary> Calculates a new set of times series with zero mean and standard deviation one.
98-
///</summary>
99-
/// <param name="tss">Time series concatenated in a single row.</param>
100-
/// <param name="epsilon">Minimum standard deviation to consider. It acts as a gatekeeper for
101-
/// those time series that may be constant or near constant.</param>
102-
/// <param name="result">KhivaArray with the same dimensions as tss where the time series have been
103-
/// adjusted for zero mean and one as standard deviation.</param>
89+
/// <summary> Calculates a new set of times series with zero mean and standard deviation one.
90+
///</summary>
91+
/// <param name="tss">Time series concatenated in a single row.</param>
92+
/// <param name="epsilon">Minimum standard deviation to consider. It acts as a gatekeeper for
93+
/// those time series that may be constant or near constant.</param>
94+
/// <param name="result">KhivaArray with the same dimensions as tss where the time series have been
95+
/// adjusted for zero mean and one as standard deviation.</param>
10496
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
10597
public extern static void znorm([In] ref IntPtr tss, [In] ref double epsilon, [Out] out IntPtr result);
106-
10798

108-
/// <summary> Adjusts the time series in the given input and performs z-norm
109-
/// inplace (without allocating further memory).
110-
///</summary>
111-
/// <param name="tss">Expects an input array whose dimension zero is the length of the time
112-
/// series (all the same) and dimension one indicates the number of time series.</param>
113-
/// <param name="epsilon">Minimum standard deviation to consider. It acts as a gatekeeper for
114-
/// those time series that may be constant or near constant.</param>
99+
/// <summary> Adjusts the time series in the given input and performs z-norm
100+
/// inplace (without allocating further memory).
101+
///</summary>
102+
/// <param name="tss">Expects an input array whose dimension zero is the length of the time
103+
/// series (all the same) and dimension one indicates the number of time series.</param>
104+
/// <param name="epsilon">Minimum standard deviation to consider. It acts as a gatekeeper for
105+
/// those time series that may be constant or near constant.</param>
115106
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
116107
public extern static void znorm_in_place([In, Out] ref IntPtr tss, [In] ref double epsilon);
117-
118108
}
119109
}

KhivaCsharp/KhivaCsharp/Interop/DLLPolynomial.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,25 @@ namespace khiva.interop
1818
/// </summary>
1919
public static class DLLPolynomial
2020
{
21-
22-
/// <summary> Least squares polynomial fit. Fit a polynomial \f$p(x) = p[0] /// x^{deg} + ... + p[deg]\f$ of degree \f$deg\f$
23-
/// to points \f$(x, y)\f$. Returns a vector of coefficients \f$p\f$ that minimises the squared error.
24-
///</summary>
25-
/// <param name="x">x-coordinates of the M sample points \f$(x[i], y[i])\f$.</param>
26-
/// <param name="y">y-coordinates of the sample points.</param>
27-
/// <param name="deg">Degree of the fitting polynomial.</param>
28-
/// <param name="result">Polynomial coefficients, highest power first.</param>
21+
/// <summary> Least squares polynomial fit. Fit a polynomial \f$p(x) = p[0] /// x^{deg} + ... + p[deg]\f$ of degree \f$deg\f$
22+
/// to points \f$(x, y)\f$. Returns a vector of coefficients \f$p\f$ that minimises the squared error.
23+
///</summary>
24+
/// <param name="x">x-coordinates of the M sample points \f$(x[i], y[i])\f$.</param>
25+
/// <param name="y">y-coordinates of the sample points.</param>
26+
/// <param name="deg">Degree of the fitting polynomial.</param>
27+
/// <param name="result">Polynomial coefficients, highest power first.</param>
2928
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
3029
public extern static void polyfit([In] ref IntPtr x, [In] ref IntPtr y, [In] ref int deg, [Out] out IntPtr result);
3130

32-
33-
/// <summary> Calculates the roots of a polynomial with coefficients given in \f$p\f$. The values in the rank-1 array
34-
/// \f$p\f$ are coefficients of a polynomial. If the length of \f$p\f$ is \f$n+1\f$ then the polynomial is described by:
35-
/// \f[
36-
/// p[0] /// x^n + p[1] /// x^{n-1} + ... + p[n-1] /// x + p[n]
37-
/// \f]
38-
///</summary>
39-
/// <param name="p">KhivaArray of polynomial coefficients.</param>
40-
/// <param name="result">KhivaArray containing the roots of the polynomial.</param>
31+
/// <summary> Calculates the roots of a polynomial with coefficients given in \f$p\f$. The values in the rank-1 array
32+
/// \f$p\f$ are coefficients of a polynomial. If the length of \f$p\f$ is \f$n+1\f$ then the polynomial is described by:
33+
/// \f[
34+
/// p[0] /// x^n + p[1] /// x^{n-1} + ... + p[n-1] /// x + p[n]
35+
/// \f]
36+
///</summary>
37+
/// <param name="p">KhivaArray of polynomial coefficients.</param>
38+
/// <param name="result">KhivaArray containing the roots of the polynomial.</param>
4139
[DllImport(DLLLibrary.khivaPath, CallingConvention = CallingConvention.Cdecl)]
4240
public extern static void roots([In] ref IntPtr p, [Out] out IntPtr result);
43-
4441
}
4542
}

0 commit comments

Comments
 (0)