AUTH's THMMY "Parallel and distributed systems" course assignments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 dagen geleden
3 dagen geleden
3 dagen geleden
3 dagen geleden
3 dagen geleden
3 dagen geleden
3 dagen geleden
3 dagen geleden
3 dagen geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /**
  2. * \file tests.cpp
  3. * \brief PDS homework_1 tests
  4. *
  5. * \author
  6. * Christos Choutouridis AEM:8997
  7. * <cchoutou@ece.auth.gr>
  8. */
  9. #include <gtest/gtest.h>
  10. #include "matrix.hpp"
  11. #include "v0.hpp"
  12. #include "v1.hpp"
  13. #include "utils.hpp"
  14. #include "config.h"
  15. using matrix_t = mtx::Matrix<int>;
  16. extern void loadMtx(MatrixDst& Corpus, MatrixDst& Query);
  17. extern void storeMtx(MatrixIdx& Idx, MatrixDst& Dst);
  18. // =====================================
  19. // C1, Q1
  20. mtx::Matrix<double> C1(10,2, {
  21. 0.8147, 0.1576,
  22. 0.9058, 0.9706,
  23. 0.1270, 0.9572,
  24. 0.9134, 0.4854,
  25. 0.6324, 0.8003,
  26. 0.0975, 0.1419,
  27. 0.2785, 0.4218,
  28. 0.5469, 0.9157,
  29. 0.9575, 0.7922,
  30. 0.9649, 0.9595
  31. });
  32. mtx::Matrix<double> Q1(5,2, {
  33. 0.6557, 0.7577,
  34. 0.0357, 0.7431,
  35. 0.8491, 0.3922,
  36. 0.9340, 0.6555,
  37. 0.6787, 0.1712
  38. });
  39. // =====================================
  40. // C2, Q2
  41. mtx::Matrix<double> C2(16,4, {
  42. 0.7060, 0.4456, 0.5060, 0.6160,
  43. 0.0318, 0.6463, 0.6991, 0.4733,
  44. 0.2769, 0.7094, 0.8909, 0.3517,
  45. 0.0462, 0.7547, 0.9593, 0.8308,
  46. 0.0971, 0.2760, 0.5472, 0.5853,
  47. 0.8235, 0.6797, 0.1386, 0.5497,
  48. 0.6948, 0.6551, 0.1493, 0.9172,
  49. 0.3171, 0.1626, 0.2575, 0.2858,
  50. 0.9502, 0.1190, 0.8407, 0.7572,
  51. 0.0344, 0.4984, 0.2543, 0.7537,
  52. 0.4387, 0.9597, 0.8143, 0.3804,
  53. 0.3816, 0.3404, 0.2435, 0.5678,
  54. 0.7655, 0.5853, 0.9293, 0.0759,
  55. 0.7952, 0.2238, 0.3500, 0.0540,
  56. 0.1869, 0.7513, 0.1966, 0.5308,
  57. 0.4898, 0.2551, 0.2511, 0.7792
  58. });
  59. mtx::Matrix<double> Q2(8,4, {
  60. 0.9340, 0.3112, 0.4505, 0.0782,
  61. 0.1299, 0.5285, 0.0838, 0.4427,
  62. 0.5688, 0.1656, 0.2290, 0.1067,
  63. 0.4694, 0.6020, 0.9133, 0.9619,
  64. 0.0119, 0.2630, 0.1524, 0.0046,
  65. 0.3371, 0.6541, 0.8258, 0.7749,
  66. 0.1622, 0.6892, 0.5383, 0.8173,
  67. 0.7943, 0.7482, 0.9961, 0.8687
  68. });
  69. /*
  70. * ==========================================
  71. * pdist2
  72. */
  73. TEST(Tv0_UT, pdist2_test1) {
  74. mtx::Matrix<double> D1_exp(10, 5, {
  75. 0.6208, 0.9745, 0.2371, 0.5120, 0.1367,
  76. 0.3284, 0.8993, 0.5811, 0.3164, 0.8310,
  77. 0.5651, 0.2327, 0.9169, 0.8616, 0.9603,
  78. 0.3749, 0.9147, 0.1132, 0.1713, 0.3921,
  79. 0.0485, 0.5994, 0.4621, 0.3346, 0.6308,
  80. 0.8312, 0.6044, 0.7922, 0.9815, 0.5819,
  81. 0.5052, 0.4028, 0.5714, 0.6959, 0.4722,
  82. 0.1919, 0.5395, 0.6045, 0.4665, 0.7561,
  83. 0.3037, 0.9231, 0.4144, 0.1387, 0.6807,
  84. 0.3692, 0.9540, 0.5790, 0.3056, 0.8386
  85. });
  86. mtx::Matrix<double> D (10,5);
  87. v0::pdist2(C1, Q1, D);
  88. for (size_t i = 0 ; i< D.rows() ; ++i)
  89. for (size_t j = 0 ; j<D.columns() ; ++j) {
  90. EXPECT_EQ (D1_exp.get(i ,j) + 0.01 > D(i, j), true);
  91. EXPECT_EQ (D1_exp.get(i ,j) - 0.01 < D(i, j), true);
  92. }
  93. }
  94. TEST(Tv0_UT, pdist2_test2) {
  95. mtx::Matrix<double> D2_exp(16, 8, {
  96. 0.6020, 0.7396, 0.6583, 0.6050, 1.0070, 0.5542, 0.6298, 0.6352,
  97. 1.0696, 0.6348, 0.9353, 0.6914, 0.8160, 0.4475, 0.4037, 0.9145,
  98. 0.9268, 0.8450, 0.9376, 0.6492, 0.9671, 0.4360, 0.5956, 0.7400,
  99. 1.3455, 0.9876, 1.2953, 0.4709, 1.2557, 0.3402, 0.4417, 0.7500,
  100. 0.9839, 0.5476, 0.7517, 0.7216, 0.7074, 0.5605, 0.4784, 0.9954,
  101. 0.6839, 0.7200, 0.7305, 0.9495, 1.0628, 0.8718, 0.8178, 0.9179,
  102. 0.9850, 0.7514, 0.9585, 0.7996, 1.2054, 0.7784, 0.6680, 0.8591,
  103. 0.6950, 0.4730, 0.3103, 1.0504, 0.4397, 0.8967, 0.8140, 1.2066,
  104. 0.8065, 1.2298, 0.9722, 0.7153, 1.3933, 0.8141, 1.0204, 0.6758,
  105. 1.1572, 0.3686, 0.9031, 0.8232, 0.7921, 0.6656, 0.3708, 1.0970,
  106. 0.9432, 0.9049, 1.0320, 0.6905, 1.1167, 0.5094, 0.6455, 0.6653,
  107. 0.7672, 0.3740, 0.5277, 0.8247, 0.6842, 0.6945, 0.5648, 0.9968,
  108. 0.5768, 1.1210, 0.8403, 0.9345, 1.1316, 0.8292, 1.0380, 0.8127,
  109. 0.1939, 0.8703, 0.2684, 1.1794, 0.8103, 1.0683, 1.1115, 1.1646,
  110. 1.0106, 0.2708, 0.8184, 0.8954, 0.7402, 0.6982, 0.4509, 1.0594,
  111. 0.8554, 0.5878, 0.6834, 0.7699, 0.9155, 0.7161, 0.6162, 0.9481
  112. });
  113. mtx::Matrix<double> D (16,8);
  114. v0::pdist2(C2, Q2, D);
  115. for (size_t i = 0 ; i< D.rows() ; ++i)
  116. for (size_t j = 0 ; j<D.columns() ; ++j) {
  117. EXPECT_EQ (D2_exp.get(i ,j) + 0.01 > D(i, j), true);
  118. EXPECT_EQ (D2_exp.get(i ,j) - 0.01 < D(i, j), true);
  119. }
  120. }
  121. TEST(Tv0_UT, pdist2_test3) {
  122. mtx::Matrix<double> D2_exp(16, 16, {
  123. 0, 0.7433, 0.6868, 0.8846, 0.6342, 0.4561, 0.5118, 0.6341, 0.5461, 0.7322, 0.6974, 0.4330, 0.7028, 0.6303, 0.6826, 0.4179,
  124. 0.7433, 0, 0.3400, 0.4555, 0.4207, 0.9736, 0.9690, 0.7386, 1.1055, 0.5462, 0.5345, 0.6576, 0.8677, 1.0291, 0.5393, 0.8106,
  125. 0.6868, 0.3400, 0, 0.5380, 0.6268, 0.9512, 1.0234, 0.8403, 0.9843, 0.8187, 0.3091, 0.7829, 0.5759, 0.9411, 0.7239, 0.9186,
  126. 0.8846, 0.4555, 0.5380, 0, 0.6796, 1.1672, 1.0460, 1.1016, 1.1139, 0.7542, 0.6480, 0.9304, 1.0568, 1.3482, 0.8316, 0.9750,
  127. 0.6342, 0.4207, 0.6268, 0.6796, 0, 0.9267, 0.8772, 0.4847, 0.9317, 0.4093, 0.8351, 0.4215, 0.9736, 0.9007, 0.5999, 0.5291,
  128. 0.4561, 0.9736, 0.9512, 1.1672, 0.9267, 0, 0.3903, 0.7795, 0.9308, 0.8429, 0.8436, 0.5672, 0.9284, 0.7064, 0.6435, 0.5975,
  129. 0.5118, 0.9690, 1.0234, 1.0460, 0.8772, 0.3903, 0, 0.8920, 0.9253, 0.7060, 0.9427, 0.5728, 1.1515, 0.9907, 0.6471, 0.4811,
  130. 0.6341, 0.7386, 0.8403, 1.1016, 0.4847, 0.7795, 0.8920, 0, 0.9824, 0.6416, 0.9844, 0.3398, 0.9355, 0.5428, 0.6536, 0.5309,
  131. 0.5461, 1.1055, 0.9843, 1.1139, 0.9317, 0.9308, 0.9253, 0.9824, 0, 1.1517, 1.0541, 0.8746, 0.8506, 0.8777, 1.2036, 0.7607,
  132. 0.7322, 0.5462, 0.8187, 0.7542, 0.4093, 0.8429, 0.7060, 0.6416, 1.1517, 0, 0.9106, 0.4245, 1.2071, 1.0738, 0.3745, 0.5170,
  133. 0.6974, 0.5345, 0.3091, 0.6480, 0.8351, 0.8436, 0.9427, 0.9844, 1.0541, 0.9106, 0, 0.8647, 0.5941, 0.9954, 0.7148, 0.9876,
  134. 0.4330, 0.6576, 0.7829, 0.9304, 0.4215, 0.5672, 0.5728, 0.3398, 0.8746, 0.4245, 0.8647, 0, 0.9590, 0.6782, 0.4586, 0.2525,
  135. 0.7028, 0.8677, 0.5759, 1.0568, 0.9736, 0.9284, 1.1515, 0.9355, 0.8506, 1.2071, 0.5941, 0.9590, 0, 0.6838, 1.0517, 1.0675,
  136. 0.6303, 1.0291, 0.9411, 1.3482, 0.9007, 0.7064, 0.9907, 0.5428, 0.8777, 1.0738, 0.9954, 0.6782, 0.6838, 0, 0.9482, 0.7937,
  137. 0.6826, 0.5393, 0.7239, 0.8316, 0.5999, 0.6435, 0.6471, 0.6536, 1.2036, 0.3745, 0.7148, 0.4586, 1.0517, 0.9482, 0, 0.6345,
  138. 0.4179, 0.8106, 0.9186, 0.9750, 0.5291, 0.5975, 0.4811, 0.5309, 0.7607, 0.5170, 0.9876, 0.2525, 1.0675, 0.7937, 0.6345, 0
  139. });
  140. mtx::Matrix<double> D (16,16);
  141. v0::pdist2(C2, C2, D);
  142. for (size_t i = 0 ; i< D.rows() ; ++i)
  143. for (size_t j = 0 ; j<D.columns() ; ++j) {
  144. EXPECT_EQ (D2_exp.get(i ,j) + 0.01 > D(i, j), true);
  145. EXPECT_EQ (D2_exp.get(i ,j) - 0.01 < D(i, j), true);
  146. }
  147. }
  148. /*
  149. * ==========================================
  150. * v0::knn
  151. */
  152. TEST(Tv0_UT, knn_v0_test1) {
  153. size_t k = 3;
  154. mtx::Matrix<uint32_t> Idx_exp(5, k, {
  155. 5, 8, 9,
  156. 3, 7, 8,
  157. 4, 1, 9,
  158. 9, 4, 10,
  159. 1, 4, 7
  160. });
  161. mtx::Matrix<double> Dst_exp(5, k, {
  162. 0.0485, 0.1919, 0.3037,
  163. 0.2327, 0.4028, 0.5395,
  164. 0.1132, 0.2371, 0.4144,
  165. 0.1387, 0.1713, 0.3056,
  166. 0.1367, 0.3921, 0.4722
  167. });
  168. mtx::Matrix<uint32_t> Idx(5, k);
  169. mtx::Matrix<double> Dst(5, k);
  170. v0::knnsearch(C1, Q1, 0, k, 0, Idx, Dst);
  171. for (size_t i = 0 ; i< Idx.rows() ; ++i)
  172. for (size_t j = 0 ; j<Idx.columns() ; ++j) {
  173. EXPECT_EQ (Idx_exp(i ,j) == Idx(i, j) + 1, true); // matlab starts from 1
  174. EXPECT_EQ (Dst_exp.get(i ,j) + 0.01 > Dst(i, j), true);
  175. EXPECT_EQ (Dst_exp.get(i ,j) - 0.01 < Dst(i, j), true);
  176. }
  177. }
  178. TEST(Tv0_UT, knn_v0_test2) {
  179. size_t k = 3;
  180. mtx::Matrix<uint32_t> Idx_exp(8, k, {
  181. 14, 13, 1,
  182. 15, 10, 12,
  183. 14, 8, 12,
  184. 4, 1, 3,
  185. 8, 12, 5,
  186. 4, 3, 2,
  187. 10, 2, 4,
  188. 1, 11, 9
  189. });
  190. mtx::Matrix<double> Dst_exp(8, k, {
  191. 0.1939, 0.5768, 0.6020,
  192. 0.2708, 0.3686, 0.3740,
  193. 0.2684, 0.3103, 0.5277,
  194. 0.4709, 0.6050, 0.6492,
  195. 0.4397, 0.6842, 0.7074,
  196. 0.3402, 0.4360, 0.4475,
  197. 0.3708, 0.4037, 0.4417,
  198. 0.6352, 0.6653, 0.6758
  199. });
  200. mtx::Matrix<uint32_t> Idx(8, k);
  201. mtx::Matrix<double> Dst(8, k);
  202. v0::knnsearch(C2, Q2, 0, k, 0, Idx, Dst);
  203. for (size_t i = 0 ; i< Idx.rows() ; ++i)
  204. for (size_t j = 0 ; j<Idx.columns() ; ++j) {
  205. EXPECT_EQ (Idx_exp(i ,j) == Idx(i, j) + 1, true); // matlab starts from 1
  206. EXPECT_EQ (Dst_exp.get(i ,j) + 0.01 > Dst(i, j), true);
  207. EXPECT_EQ (Dst_exp.get(i ,j) - 0.01 < Dst(i, j), true);
  208. }
  209. }
  210. /*
  211. * ==========================================
  212. * v1::knn
  213. */
  214. TEST(Tv1_UT, knn_v1_1slice) {
  215. size_t k = 3;
  216. mtx::Matrix<uint32_t> Idx_exp(8, k, {
  217. 14, 13, 1,
  218. 15, 10, 12,
  219. 14, 8, 12,
  220. 4, 1, 3,
  221. 8, 12, 5,
  222. 4, 3, 2,
  223. 10, 2, 4,
  224. 1, 11, 9
  225. });
  226. mtx::Matrix<double> Dst_exp(8, k, {
  227. 0.1939, 0.5768, 0.6020,
  228. 0.2708, 0.3686, 0.3740,
  229. 0.2684, 0.3103, 0.5277,
  230. 0.4709, 0.6050, 0.6492,
  231. 0.4397, 0.6842, 0.7074,
  232. 0.3402, 0.4360, 0.4475,
  233. 0.3708, 0.4037, 0.4417,
  234. 0.6352, 0.6653, 0.6758
  235. });
  236. mtx::Matrix<uint32_t> Idx(8, k);
  237. mtx::Matrix<double> Dst(8, k);
  238. v1::knnsearch(C2, Q2, 1, k, k, Idx, Dst);
  239. for (size_t i = 0 ; i< Idx.rows() ; ++i)
  240. for (size_t j = 0 ; j<Idx.columns() ; ++j) {
  241. EXPECT_EQ (Idx_exp(i ,j) == Idx(i, j) + 1, true); // matlab starts from 1
  242. EXPECT_EQ (Dst_exp.get(i ,j) + 0.01 > Dst(i, j), true);
  243. EXPECT_EQ (Dst_exp.get(i ,j) - 0.01 < Dst(i, j), true);
  244. }
  245. }
  246. TEST(Tv1_UT, knn_v1_2slice) {
  247. size_t k = 3;
  248. mtx::Matrix<uint32_t> Idx_exp(8, k, {
  249. 14, 13, 1,
  250. 15, 10, 12,
  251. 14, 8, 12,
  252. 4, 1, 3,
  253. 8, 12, 5,
  254. 4, 3, 2,
  255. 10, 2, 4,
  256. 1, 11, 9
  257. });
  258. mtx::Matrix<double> Dst_exp(8, k, {
  259. 0.1939, 0.5768, 0.6020,
  260. 0.2708, 0.3686, 0.3740,
  261. 0.2684, 0.3103, 0.5277,
  262. 0.4709, 0.6050, 0.6492,
  263. 0.4397, 0.6842, 0.7074,
  264. 0.3402, 0.4360, 0.4475,
  265. 0.3708, 0.4037, 0.4417,
  266. 0.6352, 0.6653, 0.6758
  267. });
  268. mtx::Matrix<uint32_t> Idx(8, k);
  269. mtx::Matrix<double> Dst(8, k);
  270. v1::knnsearch(C2, Q2, 2, k, k, Idx, Dst);
  271. for (size_t i = 0 ; i< Idx.rows() ; ++i)
  272. for (size_t j = 0 ; j<Idx.columns() ; ++j) {
  273. EXPECT_EQ (Idx_exp(i ,j) == Idx(i, j) + 1, true); // matlab starts from 1
  274. EXPECT_EQ (Dst_exp.get(i ,j) + 0.01 > Dst(i, j), true);
  275. EXPECT_EQ (Dst_exp.get(i ,j) - 0.01 < Dst(i, j), true);
  276. }
  277. }
  278. // all-to-all
  279. TEST(Tv1_UT, knn_v1_4slice) {
  280. size_t k = 3;
  281. mtx::Matrix<uint32_t> Idx_exp(16, k, {
  282. 1, 16, 12,
  283. 2, 3, 5,
  284. 3, 11, 2,
  285. 4, 2, 3,
  286. 5, 10, 2,
  287. 6, 7, 1,
  288. 7, 6, 16,
  289. 8, 12, 5,
  290. 9, 1, 16,
  291. 10, 15, 5,
  292. 11, 3, 2,
  293. 12, 16, 8,
  294. 13, 3, 11,
  295. 14, 8, 1,
  296. 15, 10, 12,
  297. 16, 12, 1
  298. });
  299. mtx::Matrix<double> Dst_exp(16, k, {
  300. 0, 0.4179, 0.4331,
  301. 0, 0.3401, 0.4207,
  302. 0, 0.3092, 0.3401,
  303. 0, 0.4555, 0.5381,
  304. 0, 0.4093, 0.4207,
  305. 0, 0.3903, 0.4560,
  306. 0, 0.3903, 0.4811,
  307. 0, 0.3398, 0.4846,
  308. 0, 0.5461, 0.7607,
  309. 0, 0.3745, 0.4093,
  310. 0, 0.3092, 0.5345,
  311. 0, 0.2524, 0.3398,
  312. 0, 0.5759, 0.5941,
  313. 0, 0.5428, 0.6304,
  314. 0, 0.3745, 0.4586,
  315. 0, 0.2524, 0.4179
  316. });
  317. mtx::Matrix<uint32_t> Idx(16, k);
  318. mtx::Matrix<double> Dst(16, k);
  319. v1::knnsearch(C2, C2, 4, k, k, Idx, Dst);
  320. for (size_t i = 0 ; i< Idx.rows() ; ++i)
  321. for (size_t j = 0 ; j<Idx.columns() ; ++j) {
  322. EXPECT_EQ (Idx_exp(i ,j) == Idx(i, j) + 1, true); // matlab starts from 1
  323. EXPECT_EQ (Dst_exp.get(i ,j) + 0.01 > Dst(i, j), true);
  324. EXPECT_EQ (Dst_exp.get(i ,j) - 0.01 < Dst(i, j), true);
  325. }
  326. }
  327. /*
  328. * ============== Live hdf5 tests ===============
  329. *
  330. * In order to run these test we need the followin hdf5 files in ./mtx directory:
  331. *
  332. * - fasion-mnist-784-euclidean.hdf5
  333. * - mnist-784-euclidean.hdf5
  334. * - sift-128-euclidean.hdf5
  335. * - gist-960-euclidean.hdf5
  336. *
  337. */
  338. TEST(Tlive_UT, knn_v0_sift_test) {
  339. // Instantiate matrixes
  340. MatrixDst Corpus;
  341. MatrixDst Query;
  342. MatrixIdx Idx;
  343. MatrixDst Dst;
  344. // setup environment
  345. session.corpusMtxFile = "mtx/sift-128-euclidean.hdf5";
  346. session.corpusDataSet = "/test";
  347. session.queryMtx = false;
  348. session.k = 100;
  349. size_t m = session.k;
  350. session.timing = true;
  351. session.outMtxFile = "test/knn_v0.hdf5";
  352. loadMtx(Corpus, Query);
  353. // Prepare output memory (There is no Query, so from Corpus
  354. Idx.resize(Corpus.rows(), session.k);
  355. Dst.resize(Corpus.rows(), session.k);
  356. v0::knnsearch(Corpus, Corpus, 0, session.k, m, Idx, Dst);
  357. storeMtx(Idx, Dst);
  358. EXPECT_EQ(true, true);
  359. }
  360. TEST(Tlive_UT, knn_v1_sift_test_1slice) {
  361. // Instantiate matrixes
  362. MatrixDst Corpus;
  363. MatrixDst Query;
  364. MatrixIdx Idx;
  365. MatrixDst Dst;
  366. // setup environment
  367. session.corpusMtxFile = "mtx/sift-128-euclidean.hdf5";
  368. session.corpusDataSet = "/test";
  369. session.queryMtx = false;
  370. session.k = 100;
  371. size_t m = session.k;
  372. session.timing = true;
  373. session.outMtxFile = "test/knn_v1ser.hdf5";
  374. loadMtx(Corpus, Query);
  375. // Prepare output memory (There is no Query, so from Corpus
  376. Idx.resize(Corpus.rows(), session.k);
  377. Dst.resize(Corpus.rows(), session.k);
  378. v1::knnsearch(Corpus, Corpus, 0, session.k, m, Idx, Dst);
  379. storeMtx(Idx, Dst);
  380. EXPECT_EQ(true, true);
  381. }
  382. TEST(Tlive_UT, knn_v1_sift_test_2slice) {
  383. // Instantiate matrixes
  384. MatrixDst Corpus;
  385. MatrixDst Query;
  386. MatrixIdx Idx;
  387. MatrixDst Dst;
  388. // setup environment
  389. session.corpusMtxFile = "mtx/sift-128-euclidean.hdf5";
  390. session.corpusDataSet = "/test";
  391. session.queryMtx = false;
  392. session.k = 100;
  393. size_t m = session.k;
  394. session.timing = true;
  395. session.outMtxFile = "test/knn_v1ser.hdf5";
  396. loadMtx(Corpus, Query);
  397. // Prepare output memory (There is no Query, so from Corpus
  398. Idx.resize(Corpus.rows(), session.k);
  399. Dst.resize(Corpus.rows(), session.k);
  400. v1::knnsearch(Corpus, Corpus, 2, session.k, m, Idx, Dst);
  401. storeMtx(Idx, Dst);
  402. EXPECT_EQ(true, true);
  403. }
  404. TEST(Tlive_UT, knn_v1_sift_test_4slice) {
  405. // Instantiate matrixes
  406. MatrixDst Corpus;
  407. MatrixDst Query;
  408. MatrixIdx Idx;
  409. MatrixDst Dst;
  410. // setup environment
  411. session.corpusMtxFile = "mtx/sift-128-euclidean.hdf5";
  412. session.corpusDataSet = "/test";
  413. session.queryMtx = false;
  414. session.k = 100;
  415. size_t m = session.k;
  416. session.timing = true;
  417. session.outMtxFile = "test/knn_v1ser.hdf5";
  418. loadMtx(Corpus, Query);
  419. // Prepare output memory (There is no Query, so from Corpus
  420. Idx.resize(Corpus.rows(), session.k);
  421. Dst.resize(Corpus.rows(), session.k);
  422. v1::knnsearch(Corpus, Corpus, 4, session.k, m, Idx, Dst);
  423. storeMtx(Idx, Dst);
  424. EXPECT_EQ(true, true);
  425. }