Mercurial > hg > match-vamp
comparison test/TestFeatureConditioner.cpp @ 185:a17b22abd551 re-minimise
Code now builds, DistanceMetric tests fail
author | Chris Cannam |
---|---|
date | Thu, 26 Feb 2015 10:28:23 +0000 |
parents | 8e240bbea845 |
children |
comparison
equal
deleted
inserted
replaced
184:6c12db195986 | 185:a17b22abd551 |
---|---|
10 #define BOOST_TEST_DYN_LINK | 10 #define BOOST_TEST_DYN_LINK |
11 #define BOOST_TEST_MAIN | 11 #define BOOST_TEST_MAIN |
12 | 12 |
13 #include <boost/test/unit_test.hpp> | 13 #include <boost/test/unit_test.hpp> |
14 | 14 |
15 static vector<double> getTestFeature(double m) | 15 static feature_t getTestFeature(double m) |
16 { | 16 { |
17 vector<double> f; | 17 feature_t f; |
18 double fd[] = { 0, 1, 2, 3 }; | 18 int fd[] = { 0, 1, 2, 3 }; |
19 for (int i = 0; i < 4; ++i) { | 19 for (int i = 0; i < 4; ++i) { |
20 f.push_back(fd[i] * m); | 20 f.push_back(featurebin_t(fd[i] * m)); |
21 } | 21 } |
22 return f; | 22 return f; |
23 } | 23 } |
24 | 24 |
25 BOOST_AUTO_TEST_SUITE(TestFeatureConditioner) | 25 BOOST_AUTO_TEST_SUITE(TestFeatureConditioner) |
27 BOOST_AUTO_TEST_CASE(nonorm_features) | 27 BOOST_AUTO_TEST_CASE(nonorm_features) |
28 { | 28 { |
29 FeatureConditioner::Parameters params; | 29 FeatureConditioner::Parameters params; |
30 params.norm = FeatureConditioner::NoNormalisation; | 30 params.norm = FeatureConditioner::NoNormalisation; |
31 params.order = FeatureConditioner::OutputFeatures; | 31 params.order = FeatureConditioner::OutputFeatures; |
32 vector<double> | 32 feature_t |
33 e1 = getTestFeature(1), | 33 e1 = getTestFeature(1), |
34 e2 = getTestFeature(2), | 34 e2 = getTestFeature(2), |
35 e0 = getTestFeature(0); | 35 e0 = getTestFeature(0); |
36 | 36 |
37 params.silenceThreshold = 1.0; | 37 params.silenceThreshold = 1.0; |
38 FeatureConditioner fc(params); | 38 FeatureConditioner fc(params); |
39 vector<double> out = fc.process(e1); | 39 feature_t out = fc.process(e1); |
40 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); | 40 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); |
41 out = fc.process(e2); | 41 out = fc.process(e2); |
42 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e2.begin(), e2.end()); | 42 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e2.begin(), e2.end()); |
43 | 43 |
44 params.silenceThreshold = 7.0; | 44 params.silenceThreshold = 7.0; |
52 BOOST_AUTO_TEST_CASE(nonorm_rectderiv) | 52 BOOST_AUTO_TEST_CASE(nonorm_rectderiv) |
53 { | 53 { |
54 FeatureConditioner::Parameters params; | 54 FeatureConditioner::Parameters params; |
55 params.norm = FeatureConditioner::NoNormalisation; | 55 params.norm = FeatureConditioner::NoNormalisation; |
56 params.order = FeatureConditioner::OutputRectifiedDerivative; | 56 params.order = FeatureConditioner::OutputRectifiedDerivative; |
57 vector<double> | 57 feature_t |
58 e1 = getTestFeature(1), | 58 e1 = getTestFeature(1), |
59 e2 = getTestFeature(2), | 59 e2 = getTestFeature(2), |
60 e0 = getTestFeature(0); | 60 e0 = getTestFeature(0); |
61 | 61 |
62 params.silenceThreshold = 1.0; | 62 params.silenceThreshold = 1.0; |
63 FeatureConditioner fc(params); | 63 FeatureConditioner fc(params); |
64 vector<double> out = fc.process(e1); | 64 feature_t out = fc.process(e1); |
65 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); | 65 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); |
66 out = fc.process(e2); | 66 out = fc.process(e2); |
67 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); | 67 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); |
68 out = fc.process(e1); | 68 out = fc.process(e1); |
69 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e0.begin(), e0.end()); | 69 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e0.begin(), e0.end()); |
83 BOOST_AUTO_TEST_CASE(nonorm_deriv) | 83 BOOST_AUTO_TEST_CASE(nonorm_deriv) |
84 { | 84 { |
85 FeatureConditioner::Parameters params; | 85 FeatureConditioner::Parameters params; |
86 params.norm = FeatureConditioner::NoNormalisation; | 86 params.norm = FeatureConditioner::NoNormalisation; |
87 params.order = FeatureConditioner::OutputDerivative; | 87 params.order = FeatureConditioner::OutputDerivative; |
88 vector<double> | 88 feature_t |
89 e1 = getTestFeature(1), | 89 e1 = getTestFeature(1), |
90 e2 = getTestFeature(2), | 90 e2 = getTestFeature(2), |
91 e3 = getTestFeature(3), | 91 e3 = getTestFeature(3), |
92 e0 = getTestFeature(0); | 92 e0 = getTestFeature(0); |
93 | 93 |
94 params.silenceThreshold = 1.0; | 94 params.silenceThreshold = 1.0; |
95 FeatureConditioner fc(params); | 95 FeatureConditioner fc(params); |
96 vector<double> out = fc.process(e1); | 96 feature_t out = fc.process(e1); |
97 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); | 97 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); |
98 out = fc.process(e2); | 98 out = fc.process(e2); |
99 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); | 99 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); |
100 out = fc.process(e1); | 100 out = fc.process(e1); |
101 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); | 101 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e1.begin(), e1.end()); |
115 BOOST_AUTO_TEST_CASE(sum1_features) | 115 BOOST_AUTO_TEST_CASE(sum1_features) |
116 { | 116 { |
117 FeatureConditioner::Parameters params; | 117 FeatureConditioner::Parameters params; |
118 params.norm = FeatureConditioner::NormaliseToSum1; | 118 params.norm = FeatureConditioner::NormaliseToSum1; |
119 params.order = FeatureConditioner::OutputFeatures; | 119 params.order = FeatureConditioner::OutputFeatures; |
120 vector<double> | 120 feature_t |
121 e1 = getTestFeature(1), | 121 e1 = getTestFeature(1), |
122 e2 = getTestFeature(2), | 122 e2 = getTestFeature(2), |
123 en = getTestFeature(1.0/6.0), | 123 en = getTestFeature(1.0/6.0), |
124 e0 = getTestFeature(0); | 124 e0 = getTestFeature(0); |
125 | 125 |
126 params.silenceThreshold = 1.0; | 126 params.silenceThreshold = 1.0; |
127 FeatureConditioner fc(params); | 127 FeatureConditioner fc(params); |
128 vector<double> out = fc.process(e1); | 128 feature_t out = fc.process(e1); |
129 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en.begin(), en.end()); | 129 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en.begin(), en.end()); |
130 out = fc.process(e2); | 130 out = fc.process(e2); |
131 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en.begin(), en.end()); | 131 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en.begin(), en.end()); |
132 | 132 |
133 params.silenceThreshold = 7.0; | 133 params.silenceThreshold = 7.0; |
141 BOOST_AUTO_TEST_CASE(sum1_rectderiv) | 141 BOOST_AUTO_TEST_CASE(sum1_rectderiv) |
142 { | 142 { |
143 FeatureConditioner::Parameters params; | 143 FeatureConditioner::Parameters params; |
144 params.norm = FeatureConditioner::NormaliseToSum1; | 144 params.norm = FeatureConditioner::NormaliseToSum1; |
145 params.order = FeatureConditioner::OutputRectifiedDerivative; | 145 params.order = FeatureConditioner::OutputRectifiedDerivative; |
146 vector<double> | 146 feature_t |
147 e1 = getTestFeature(1), | 147 e1 = getTestFeature(1), |
148 e2 = getTestFeature(2), | 148 e2 = getTestFeature(2), |
149 en = getTestFeature(1.0/6.0), | 149 en = getTestFeature(1.0/6.0), |
150 en2 = getTestFeature(1.0/12.0), | 150 en2 = getTestFeature(1.0/12.0), |
151 e0 = getTestFeature(0); | 151 e0 = getTestFeature(0); |
152 | 152 |
153 params.silenceThreshold = 1.0; | 153 params.silenceThreshold = 1.0; |
154 FeatureConditioner fc(params); | 154 FeatureConditioner fc(params); |
155 vector<double> out = fc.process(e1); | 155 feature_t out = fc.process(e1); |
156 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en.begin(), en.end()); | 156 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en.begin(), en.end()); |
157 out = fc.process(e2); | 157 out = fc.process(e2); |
158 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en2.begin(), en2.end()); | 158 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), en2.begin(), en2.end()); |
159 out = fc.process(e1); | 159 out = fc.process(e1); |
160 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e0.begin(), e0.end()); | 160 BOOST_CHECK_EQUAL_COLLECTIONS(out.begin(), out.end(), e0.begin(), e0.end()); |