core_func_common.cpp 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2011-01-15
  5. // Updated : 2011-09-13
  6. // Licence : This source is under MIT licence
  7. // File : test/core/func_common.cpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #define GLM_FORCE_EXPLICIT_CTOR
  10. #include <glm/common.hpp>
  11. #include <glm/gtc/constants.hpp>
  12. #include <glm/gtc/epsilon.hpp>
  13. #include <glm/gtc/vec1.hpp>
  14. #include <glm/gtc/random.hpp>
  15. #include <vector>
  16. #include <cstdio>
  17. #include <cmath>
  18. #include <ctime>
  19. namespace floor_
  20. {
  21. int test()
  22. {
  23. int Error(0);
  24. {
  25. float A(1.1f);
  26. float B = glm::floor(A);
  27. }
  28. {
  29. double A(1.1f);
  30. double B = glm::floor(A);
  31. }
  32. {
  33. glm::vec1 A(1.1f);
  34. glm::vec1 B = glm::floor(A);
  35. Error += glm::all(glm::epsilonEqual(B, glm::vec1(1.0), 0.0001f)) ? 0 : 1;
  36. }
  37. {
  38. glm::dvec1 A(1.1f);
  39. glm::dvec1 B = glm::floor(A);
  40. Error += glm::all(glm::epsilonEqual(B, glm::dvec1(1.0), 0.0001)) ? 0 : 1;
  41. }
  42. {
  43. glm::vec2 A(1.1f);
  44. glm::vec2 B = glm::floor(A);
  45. Error += glm::all(glm::epsilonEqual(B, glm::vec2(1.0), 0.0001f)) ? 0 : 1;
  46. }
  47. {
  48. glm::dvec2 A(1.1f);
  49. glm::dvec2 B = glm::floor(A);
  50. Error += glm::all(glm::epsilonEqual(B, glm::dvec2(1.0), 0.0001)) ? 0 : 1;
  51. }
  52. {
  53. glm::vec3 A(1.1f);
  54. glm::vec3 B = glm::floor(A);
  55. Error += glm::all(glm::epsilonEqual(B, glm::vec3(1.0), 0.0001f)) ? 0 : 1;
  56. }
  57. {
  58. glm::dvec3 A(1.1f);
  59. glm::dvec3 B = glm::floor(A);
  60. Error += glm::all(glm::epsilonEqual(B, glm::dvec3(1.0), 0.0001)) ? 0 : 1;
  61. }
  62. {
  63. glm::vec4 A(1.1f);
  64. glm::vec4 B = glm::floor(A);
  65. Error += glm::all(glm::epsilonEqual(B, glm::vec4(1.0), 0.0001f)) ? 0 : 1;
  66. }
  67. {
  68. glm::dvec4 A(1.1f);
  69. glm::dvec4 B = glm::floor(A);
  70. Error += glm::all(glm::epsilonEqual(B, glm::dvec4(1.0), 0.0001)) ? 0 : 1;
  71. }
  72. return Error;
  73. }
  74. }//namespace floor
  75. namespace modf_
  76. {
  77. int test()
  78. {
  79. int Error(0);
  80. {
  81. float X(1.5f);
  82. float I(0.0f);
  83. float A = glm::modf(X, I);
  84. Error += I == 1.0f ? 0 : 1;
  85. Error += A == 0.5f ? 0 : 1;
  86. }
  87. {
  88. glm::vec4 X(1.1f, 1.2f, 1.5f, 1.7f);
  89. glm::vec4 I(0.0f);
  90. glm::vec4 A = glm::modf(X, I);
  91. Error += I == glm::vec4(1.0f) ? 0 : 1;
  92. Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1;
  93. }
  94. {
  95. glm::dvec4 X(1.1, 1.2, 1.5, 1.7);
  96. glm::dvec4 I(0.0);
  97. glm::dvec4 A = glm::modf(X, I);
  98. Error += I == glm::dvec4(1.0) ? 0 : 1;
  99. Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1;
  100. }
  101. {
  102. double X(1.5);
  103. double I(0.0);
  104. double A = glm::modf(X, I);
  105. Error += I == 1.0 ? 0 : 1;
  106. Error += A == 0.5 ? 0 : 1;
  107. }
  108. return Error;
  109. }
  110. }//namespace modf
  111. namespace floatBitsToInt
  112. {
  113. int test()
  114. {
  115. int Error = 0;
  116. {
  117. float A = 1.0f;
  118. int B = glm::floatBitsToInt(A);
  119. float C = glm::intBitsToFloat(B);
  120. int D = *(int*)&A;
  121. Error += B == D ? 0 : 1;
  122. Error += A == C ? 0 : 1;
  123. }
  124. {
  125. glm::vec2 A(1.0f, 2.0f);
  126. glm::ivec2 B = glm::floatBitsToInt(A);
  127. glm::vec2 C = glm::intBitsToFloat(B);
  128. Error += B.x == *(int*)&(A.x) ? 0 : 1;
  129. Error += B.y == *(int*)&(A.y) ? 0 : 1;
  130. Error += A == C? 0 : 1;
  131. }
  132. {
  133. glm::vec3 A(1.0f, 2.0f, 3.0f);
  134. glm::ivec3 B = glm::floatBitsToInt(A);
  135. glm::vec3 C = glm::intBitsToFloat(B);
  136. Error += B.x == *(int*)&(A.x) ? 0 : 1;
  137. Error += B.y == *(int*)&(A.y) ? 0 : 1;
  138. Error += B.z == *(int*)&(A.z) ? 0 : 1;
  139. Error += A == C? 0 : 1;
  140. }
  141. {
  142. glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
  143. glm::ivec4 B = glm::floatBitsToInt(A);
  144. glm::vec4 C = glm::intBitsToFloat(B);
  145. Error += B.x == *(int*)&(A.x) ? 0 : 1;
  146. Error += B.y == *(int*)&(A.y) ? 0 : 1;
  147. Error += B.z == *(int*)&(A.z) ? 0 : 1;
  148. Error += B.w == *(int*)&(A.w) ? 0 : 1;
  149. Error += A == C? 0 : 1;
  150. }
  151. return Error;
  152. }
  153. }//namespace floatBitsToInt
  154. namespace floatBitsToUint
  155. {
  156. int test()
  157. {
  158. int Error = 0;
  159. {
  160. float A = 1.0f;
  161. glm::uint B = glm::floatBitsToUint(A);
  162. float C = glm::intBitsToFloat(B);
  163. Error += B == *(glm::uint*)&A ? 0 : 1;
  164. Error += A == C? 0 : 1;
  165. }
  166. {
  167. glm::vec2 A(1.0f, 2.0f);
  168. glm::uvec2 B = glm::floatBitsToUint(A);
  169. glm::vec2 C = glm::uintBitsToFloat(B);
  170. Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
  171. Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
  172. Error += A == C ? 0 : 1;
  173. }
  174. {
  175. glm::vec3 A(1.0f, 2.0f, 3.0f);
  176. glm::uvec3 B = glm::floatBitsToUint(A);
  177. glm::vec3 C = glm::uintBitsToFloat(B);
  178. Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
  179. Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
  180. Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
  181. Error += A == C? 0 : 1;
  182. }
  183. {
  184. glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
  185. glm::uvec4 B = glm::floatBitsToUint(A);
  186. glm::vec4 C = glm::uintBitsToFloat(B);
  187. Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
  188. Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
  189. Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
  190. Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1;
  191. Error += A == C? 0 : 1;
  192. }
  193. return Error;
  194. }
  195. }//namespace floatBitsToUint
  196. namespace min_
  197. {
  198. int test()
  199. {
  200. int Error = 0;
  201. glm::vec1 A0 = glm::min(glm::vec1(1), glm::vec1(1));
  202. glm::vec2 B0 = glm::min(glm::vec2(1), glm::vec2(1));
  203. glm::vec2 B1 = glm::min(glm::vec2(1), 1.0f);
  204. bool B2 = glm::all(glm::equal(B0, B1));
  205. Error += B2 ? 0 : 1;
  206. glm::vec3 C0 = glm::min(glm::vec3(1), glm::vec3(1));
  207. glm::vec3 C1 = glm::min(glm::vec3(1), 1.0f);
  208. bool C2 = glm::all(glm::equal(C0, C1));
  209. Error += C2 ? 0 : 1;
  210. glm::vec4 D0 = glm::min(glm::vec4(1), glm::vec4(1));
  211. glm::vec4 D1 = glm::min(glm::vec4(1), 1.0f);
  212. bool D2 = glm::all(glm::equal(D0, D1));
  213. Error += D2 ? 0 : 1;
  214. return Error;
  215. }
  216. }//namespace min_
  217. namespace max_
  218. {
  219. int test()
  220. {
  221. int Error = 0;
  222. glm::vec1 A0 = glm::max(glm::vec1(1), glm::vec1(1));
  223. glm::vec2 B0 = glm::max(glm::vec2(1), glm::vec2(1));
  224. glm::vec2 B1 = glm::max(glm::vec2(1), 1.0f);
  225. bool B2 = glm::all(glm::equal(B0, B1));
  226. Error += B2 ? 0 : 1;
  227. glm::vec3 C0 = glm::max(glm::vec3(1), glm::vec3(1));
  228. glm::vec3 C1 = glm::max(glm::vec3(1), 1.0f);
  229. bool C2 = glm::all(glm::equal(C0, C1));
  230. Error += C2 ? 0 : 1;
  231. glm::vec4 D0 = glm::max(glm::vec4(1), glm::vec4(1));
  232. glm::vec4 D1 = glm::max(glm::vec4(1), 1.0f);
  233. bool D2 = glm::all(glm::equal(D0, D1));
  234. Error += D2 ? 0 : 1;
  235. return Error;
  236. }
  237. }//namespace max_
  238. namespace clamp_
  239. {
  240. int test()
  241. {
  242. int Error = 0;
  243. return Error;
  244. }
  245. }//namespace clamp_
  246. namespace mix_
  247. {
  248. template <typename T, typename B>
  249. struct entry
  250. {
  251. T x;
  252. T y;
  253. B a;
  254. T Result;
  255. };
  256. entry<float, bool> TestBool[] =
  257. {
  258. {0.0f, 1.0f, false, 0.0f},
  259. {0.0f, 1.0f, true, 1.0f},
  260. {-1.0f, 1.0f, false, -1.0f},
  261. {-1.0f, 1.0f, true, 1.0f}
  262. };
  263. entry<float, float> TestFloat[] =
  264. {
  265. {0.0f, 1.0f, 0.0f, 0.0f},
  266. {0.0f, 1.0f, 1.0f, 1.0f},
  267. {-1.0f, 1.0f, 0.0f, -1.0f},
  268. {-1.0f, 1.0f, 1.0f, 1.0f}
  269. };
  270. entry<glm::vec2, bool> TestVec2Bool[] =
  271. {
  272. {glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)},
  273. {glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)},
  274. {glm::vec2(-1.0f), glm::vec2(1.0f), false, glm::vec2(-1.0f)},
  275. {glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}
  276. };
  277. entry<glm::vec2, glm::bvec2> TestBVec2[] =
  278. {
  279. {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)},
  280. {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)},
  281. {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(-1.0f)},
  282. {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)},
  283. {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true, false), glm::vec2(1.0f, -1.0f)}
  284. };
  285. entry<glm::vec3, bool> TestVec3Bool[] =
  286. {
  287. {glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)},
  288. {glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)},
  289. {glm::vec3(-1.0f), glm::vec3(1.0f), false, glm::vec3(-1.0f)},
  290. {glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}
  291. };
  292. entry<glm::vec3, glm::bvec3> TestBVec3[] =
  293. {
  294. {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)},
  295. {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)},
  296. {glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(-1.0f)},
  297. {glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)},
  298. {glm::vec3(1.0f, 2.0f, 3.0f), glm::vec3(4.0f, 5.0f, 6.0f), glm::bvec3(true, false, true), glm::vec3(4.0f, 2.0f, 6.0f)}
  299. };
  300. entry<glm::vec4, bool> TestVec4Bool[] =
  301. {
  302. {glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)},
  303. {glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)},
  304. {glm::vec4(-1.0f), glm::vec4(1.0f), false, glm::vec4(-1.0f)},
  305. {glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}
  306. };
  307. entry<glm::vec4, glm::bvec4> TestBVec4[] =
  308. {
  309. {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(0.0f)},
  310. {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)},
  311. {glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(-1.0f)},
  312. {glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)},
  313. {glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f), glm::bvec4(true, false, true, false), glm::vec4(5.0f, 2.0f, 7.0f, 4.0f)}
  314. };
  315. int test()
  316. {
  317. int Error = 0;
  318. // Float with bool
  319. {
  320. for(std::size_t i = 0; i < sizeof(TestBool) / sizeof(entry<float, bool>); ++i)
  321. {
  322. float Result = glm::mix(TestBool[i].x, TestBool[i].y, TestBool[i].a);
  323. Error += glm::epsilonEqual(Result, TestBool[i].Result, glm::epsilon<float>()) ? 0 : 1;
  324. }
  325. }
  326. // Float with float
  327. {
  328. for(std::size_t i = 0; i < sizeof(TestFloat) / sizeof(entry<float, float>); ++i)
  329. {
  330. float Result = glm::mix(TestFloat[i].x, TestFloat[i].y, TestFloat[i].a);
  331. Error += glm::epsilonEqual(Result, TestFloat[i].Result, glm::epsilon<float>()) ? 0 : 1;
  332. }
  333. }
  334. // vec2 with bool
  335. {
  336. for(std::size_t i = 0; i < sizeof(TestVec2Bool) / sizeof(entry<glm::vec2, bool>); ++i)
  337. {
  338. glm::vec2 Result = glm::mix(TestVec2Bool[i].x, TestVec2Bool[i].y, TestVec2Bool[i].a);
  339. Error += glm::epsilonEqual(Result.x, TestVec2Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  340. Error += glm::epsilonEqual(Result.y, TestVec2Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  341. }
  342. }
  343. // vec2 with bvec2
  344. {
  345. for(std::size_t i = 0; i < sizeof(TestBVec2) / sizeof(entry<glm::vec2, glm::bvec2>); ++i)
  346. {
  347. glm::vec2 Result = glm::mix(TestBVec2[i].x, TestBVec2[i].y, TestBVec2[i].a);
  348. Error += glm::epsilonEqual(Result.x, TestBVec2[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  349. Error += glm::epsilonEqual(Result.y, TestBVec2[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  350. }
  351. }
  352. // vec3 with bool
  353. {
  354. for(std::size_t i = 0; i < sizeof(TestVec3Bool) / sizeof(entry<glm::vec3, bool>); ++i)
  355. {
  356. glm::vec3 Result = glm::mix(TestVec3Bool[i].x, TestVec3Bool[i].y, TestVec3Bool[i].a);
  357. Error += glm::epsilonEqual(Result.x, TestVec3Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  358. Error += glm::epsilonEqual(Result.y, TestVec3Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  359. Error += glm::epsilonEqual(Result.z, TestVec3Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  360. }
  361. }
  362. // vec3 with bvec3
  363. {
  364. for(std::size_t i = 0; i < sizeof(TestBVec3) / sizeof(entry<glm::vec3, glm::bvec3>); ++i)
  365. {
  366. glm::vec3 Result = glm::mix(TestBVec3[i].x, TestBVec3[i].y, TestBVec3[i].a);
  367. Error += glm::epsilonEqual(Result.x, TestBVec3[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  368. Error += glm::epsilonEqual(Result.y, TestBVec3[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  369. Error += glm::epsilonEqual(Result.z, TestBVec3[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  370. }
  371. }
  372. // vec4 with bool
  373. {
  374. for(std::size_t i = 0; i < sizeof(TestVec4Bool) / sizeof(entry<glm::vec4, bool>); ++i)
  375. {
  376. glm::vec4 Result = glm::mix(TestVec4Bool[i].x, TestVec4Bool[i].y, TestVec4Bool[i].a);
  377. Error += glm::epsilonEqual(Result.x, TestVec4Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  378. Error += glm::epsilonEqual(Result.y, TestVec4Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  379. Error += glm::epsilonEqual(Result.z, TestVec4Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  380. Error += glm::epsilonEqual(Result.w, TestVec4Bool[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
  381. }
  382. }
  383. // vec4 with bvec4
  384. {
  385. for(std::size_t i = 0; i < sizeof(TestBVec4) / sizeof(entry<glm::vec4, glm::bvec4>); ++i)
  386. {
  387. glm::vec4 Result = glm::mix(TestBVec4[i].x, TestBVec4[i].y, TestBVec4[i].a);
  388. Error += glm::epsilonEqual(Result.x, TestBVec4[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  389. Error += glm::epsilonEqual(Result.y, TestBVec4[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  390. Error += glm::epsilonEqual(Result.z, TestBVec4[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  391. Error += glm::epsilonEqual(Result.w, TestBVec4[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
  392. }
  393. }
  394. return Error;
  395. }
  396. }//namespace mix_
  397. namespace step_
  398. {
  399. template <typename EDGE, typename VEC>
  400. struct entry
  401. {
  402. EDGE edge;
  403. VEC x;
  404. VEC result;
  405. };
  406. entry<float, glm::vec4> TestVec4Scalar [] =
  407. {
  408. { 0.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
  409. { 1.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
  410. { 0.0f, glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(0.0f) }
  411. };
  412. entry<glm::vec4, glm::vec4> TestVec4Vector [] =
  413. {
  414. { glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(-2.0f, -3.0f, -4.0f, -5.0f), glm::vec4(0.0f) },
  415. { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
  416. { glm::vec4( 2.0f, 3.0f, 4.0f, 5.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(0.0f) },
  417. { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4(-1.0f,-2.0f,-3.0f,-4.0f), glm::vec4(0.0f) }
  418. };
  419. int test()
  420. {
  421. int Error = 0;
  422. // vec4 and float
  423. {
  424. for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(entry<float, glm::vec4>); ++i)
  425. {
  426. glm::vec4 Result = glm::step(TestVec4Scalar[i].edge, TestVec4Scalar[i].x);
  427. Error += glm::all(glm::epsilonEqual(Result, TestVec4Scalar[i].result, glm::epsilon<float>())) ? 0 : 1;
  428. }
  429. }
  430. // vec4 and vec4
  431. {
  432. for (std::size_t i = 0; i < sizeof(TestVec4Vector) / sizeof(entry<glm::vec4, glm::vec4>); ++i)
  433. {
  434. glm::vec4 Result = glm::step(TestVec4Vector[i].edge, TestVec4Vector[i].x);
  435. Error += glm::all(glm::epsilonEqual(Result, TestVec4Vector[i].result, glm::epsilon<float>())) ? 0 : 1;
  436. }
  437. }
  438. return Error;
  439. }
  440. }//namespace step_
  441. namespace round_
  442. {
  443. int test()
  444. {
  445. int Error = 0;
  446. {
  447. float A = glm::round(0.0f);
  448. Error += A == 0.0f ? 0 : 1;
  449. float B = glm::round(0.5f);
  450. Error += B == 1.0f ? 0 : 1;
  451. float C = glm::round(1.0f);
  452. Error += C == 1.0f ? 0 : 1;
  453. float D = glm::round(0.1f);
  454. Error += D == 0.0f ? 0 : 1;
  455. float E = glm::round(0.9f);
  456. Error += E == 1.0f ? 0 : 1;
  457. float F = glm::round(1.5f);
  458. Error += F == 2.0f ? 0 : 1;
  459. float G = glm::round(1.9f);
  460. Error += G == 2.0f ? 0 : 1;
  461. }
  462. {
  463. float A = glm::round(-0.0f);
  464. Error += A == 0.0f ? 0 : 1;
  465. float B = glm::round(-0.5f);
  466. Error += B == -1.0f ? 0 : 1;
  467. float C = glm::round(-1.0f);
  468. Error += C == -1.0f ? 0 : 1;
  469. float D = glm::round(-0.1f);
  470. Error += D == 0.0f ? 0 : 1;
  471. float E = glm::round(-0.9f);
  472. Error += E == -1.0f ? 0 : 1;
  473. float F = glm::round(-1.5f);
  474. Error += F == -2.0f ? 0 : 1;
  475. float G = glm::round(-1.9f);
  476. Error += G == -2.0f ? 0 : 1;
  477. }
  478. return Error;
  479. }
  480. }//namespace round_
  481. namespace roundEven
  482. {
  483. int test()
  484. {
  485. int Error = 0;
  486. {
  487. float A1 = glm::roundEven(-1.5f);
  488. Error += glm::epsilonEqual(A1, -2.0f, 0.0001f) ? 0 : 1;
  489. float A2 = glm::roundEven(1.5f);
  490. Error += glm::epsilonEqual(A2, 2.0f, 0.0001f) ? 0 : 1;
  491. float A5 = glm::roundEven(-2.5f);
  492. Error += glm::epsilonEqual(A5, -2.0f, 0.0001f) ? 0 : 1;
  493. float A6 = glm::roundEven(2.5f);
  494. Error += glm::epsilonEqual(A6, 2.0f, 0.0001f) ? 0 : 1;
  495. float A3 = glm::roundEven(-3.5f);
  496. Error += glm::epsilonEqual(A3, -4.0f, 0.0001f) ? 0 : 1;
  497. float A4 = glm::roundEven(3.5f);
  498. Error += glm::epsilonEqual(A4, 4.0f, 0.0001f) ? 0 : 1;
  499. float C7 = glm::roundEven(-4.5f);
  500. Error += glm::epsilonEqual(C7, -4.0f, 0.0001f) ? 0 : 1;
  501. float C8 = glm::roundEven(4.5f);
  502. Error += glm::epsilonEqual(C8, 4.0f, 0.0001f) ? 0 : 1;
  503. float C1 = glm::roundEven(-5.5f);
  504. Error += glm::epsilonEqual(C1, -6.0f, 0.0001f) ? 0 : 1;
  505. float C2 = glm::roundEven(5.5f);
  506. Error += glm::epsilonEqual(C2, 6.0f, 0.0001f) ? 0 : 1;
  507. float C3 = glm::roundEven(-6.5f);
  508. Error += glm::epsilonEqual(C3, -6.0f, 0.0001f) ? 0 : 1;
  509. float C4 = glm::roundEven(6.5f);
  510. Error += glm::epsilonEqual(C4, 6.0f, 0.0001f) ? 0 : 1;
  511. float C5 = glm::roundEven(-7.5f);
  512. Error += glm::epsilonEqual(C5, -8.0f, 0.0001f) ? 0 : 1;
  513. float C6 = glm::roundEven(7.5f);
  514. Error += glm::epsilonEqual(C6, 8.0f, 0.0001f) ? 0 : 1;
  515. Error += 0;
  516. }
  517. {
  518. float A7 = glm::roundEven(-2.4f);
  519. Error += glm::epsilonEqual(A7, -2.0f, 0.0001f) ? 0 : 1;
  520. float A8 = glm::roundEven(2.4f);
  521. Error += glm::epsilonEqual(A8, 2.0f, 0.0001f) ? 0 : 1;
  522. float B1 = glm::roundEven(-2.6f);
  523. Error += glm::epsilonEqual(B1, -3.0f, 0.0001f) ? 0 : 1;
  524. float B2 = glm::roundEven(2.6f);
  525. Error += glm::epsilonEqual(B2, 3.0f, 0.0001f) ? 0 : 1;
  526. float B3 = glm::roundEven(-2.0f);
  527. Error += glm::epsilonEqual(B3, -2.0f, 0.0001f) ? 0 : 1;
  528. float B4 = glm::roundEven(2.0f);
  529. Error += glm::epsilonEqual(B4, 2.0f, 0.0001f) ? 0 : 1;
  530. Error += 0;
  531. }
  532. {
  533. float A = glm::roundEven(0.0f);
  534. Error += A == 0.0f ? 0 : 1;
  535. float B = glm::roundEven(0.5f);
  536. Error += B == 0.0f ? 0 : 1;
  537. float C = glm::roundEven(1.0f);
  538. Error += C == 1.0f ? 0 : 1;
  539. float D = glm::roundEven(0.1f);
  540. Error += D == 0.0f ? 0 : 1;
  541. float E = glm::roundEven(0.9f);
  542. Error += E == 1.0f ? 0 : 1;
  543. float F = glm::roundEven(1.5f);
  544. Error += F == 2.0f ? 0 : 1;
  545. float G = glm::roundEven(1.9f);
  546. Error += G == 2.0f ? 0 : 1;
  547. }
  548. {
  549. float A = glm::roundEven(-0.0f);
  550. Error += A == 0.0f ? 0 : 1;
  551. float B = glm::roundEven(-0.5f);
  552. Error += B == -0.0f ? 0 : 1;
  553. float C = glm::roundEven(-1.0f);
  554. Error += C == -1.0f ? 0 : 1;
  555. float D = glm::roundEven(-0.1f);
  556. Error += D == 0.0f ? 0 : 1;
  557. float E = glm::roundEven(-0.9f);
  558. Error += E == -1.0f ? 0 : 1;
  559. float F = glm::roundEven(-1.5f);
  560. Error += F == -2.0f ? 0 : 1;
  561. float G = glm::roundEven(-1.9f);
  562. Error += G == -2.0f ? 0 : 1;
  563. }
  564. {
  565. float A = glm::roundEven(1.5f);
  566. Error += A == 2.0f ? 0 : 1;
  567. float B = glm::roundEven(2.5f);
  568. Error += B == 2.0f ? 0 : 1;
  569. float C = glm::roundEven(3.5f);
  570. Error += C == 4.0f ? 0 : 1;
  571. float D = glm::roundEven(4.5f);
  572. Error += D == 4.0f ? 0 : 1;
  573. float E = glm::roundEven(5.5f);
  574. Error += E == 6.0f ? 0 : 1;
  575. float F = glm::roundEven(6.5f);
  576. Error += F == 6.0f ? 0 : 1;
  577. float G = glm::roundEven(7.5f);
  578. Error += G == 8.0f ? 0 : 1;
  579. }
  580. {
  581. float A = glm::roundEven(-1.5f);
  582. Error += A == -2.0f ? 0 : 1;
  583. float B = glm::roundEven(-2.5f);
  584. Error += B == -2.0f ? 0 : 1;
  585. float C = glm::roundEven(-3.5f);
  586. Error += C == -4.0f ? 0 : 1;
  587. float D = glm::roundEven(-4.5f);
  588. Error += D == -4.0f ? 0 : 1;
  589. float E = glm::roundEven(-5.5f);
  590. Error += E == -6.0f ? 0 : 1;
  591. float F = glm::roundEven(-6.5f);
  592. Error += F == -6.0f ? 0 : 1;
  593. float G = glm::roundEven(-7.5f);
  594. Error += G == -8.0f ? 0 : 1;
  595. }
  596. return Error;
  597. }
  598. }//namespace roundEven
  599. namespace isnan_
  600. {
  601. int test()
  602. {
  603. int Error = 0;
  604. float Zero_f = 0.0;
  605. double Zero_d = 0.0;
  606. {
  607. Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1;
  608. Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1;
  609. Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1;
  610. Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1;
  611. }
  612. {
  613. Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1;
  614. Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1;
  615. Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1;
  616. Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
  617. }
  618. return Error;
  619. }
  620. }//namespace isnan_
  621. namespace isinf_
  622. {
  623. int test()
  624. {
  625. int Error = 0;
  626. float Zero_f = 0.0;
  627. double Zero_d = 0.0;
  628. {
  629. Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1;
  630. Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1;
  631. Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1;
  632. Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1;
  633. Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1;
  634. Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1;
  635. Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1;
  636. Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1;
  637. }
  638. {
  639. Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1;
  640. Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1;
  641. Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1;
  642. Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1;
  643. Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1;
  644. Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1;
  645. Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1;
  646. Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1;
  647. }
  648. return Error;
  649. }
  650. }//namespace isinf_
  651. namespace sign
  652. {
  653. template <typename genFIType>
  654. GLM_FUNC_QUALIFIER genFIType sign_if(genFIType x)
  655. {
  656. GLM_STATIC_ASSERT(
  657. std::numeric_limits<genFIType>::is_iec559 ||
  658. (std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer), "'sign' only accept signed inputs");
  659. genFIType result;
  660. if(x > genFIType(0))
  661. result = genFIType(1);
  662. else if(x < genFIType(0))
  663. result = genFIType(-1);
  664. else
  665. result = genFIType(0);
  666. return result;
  667. }
  668. template <typename genFIType>
  669. GLM_FUNC_QUALIFIER genFIType sign_alu1(genFIType x)
  670. {
  671. GLM_STATIC_ASSERT(
  672. std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
  673. "'sign' only accept integer inputs");
  674. return (x >> 31) | ((unsigned)-x >> 31);
  675. }
  676. template <typename genFIType>
  677. GLM_FUNC_QUALIFIER genFIType sign_alu2(genFIType x)
  678. {
  679. GLM_STATIC_ASSERT(
  680. std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
  681. "'sign' only accept integer inputs");
  682. return -((unsigned)x >> 31) | (-(unsigned)x >> 31);
  683. }
  684. template <typename genFIType>
  685. GLM_FUNC_QUALIFIER genFIType sign_sub(genFIType x)
  686. {
  687. GLM_STATIC_ASSERT(
  688. std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
  689. "'sign' only accept integer inputs");
  690. return ((unsigned)-x >> 31) - ((unsigned)x >> 31);
  691. }
  692. template <typename genFIType>
  693. GLM_FUNC_QUALIFIER genFIType sign_cmp(genFIType x)
  694. {
  695. GLM_STATIC_ASSERT(
  696. std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
  697. "'sign' only accept integer inputs");
  698. return (x > 0) - (x < 0);
  699. }
  700. template <typename genType>
  701. struct type
  702. {
  703. genType Value;
  704. genType Return;
  705. };
  706. int test_int32()
  707. {
  708. type<glm::int32> const Data[] =
  709. {
  710. { std::numeric_limits<glm::int32>::max(), 1},
  711. { std::numeric_limits<glm::int32>::min(), -1},
  712. { 0, 0},
  713. { 1, 1},
  714. { 2, 1},
  715. { 3, 1},
  716. {-1,-1},
  717. {-2,-1},
  718. {-3,-1}
  719. };
  720. int Error = 0;
  721. for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
  722. {
  723. glm::int32 Result = glm::sign(Data[i].Value);
  724. Error += Data[i].Return == Result ? 0 : 1;
  725. }
  726. for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
  727. {
  728. glm::int32 Result = sign_cmp(Data[i].Value);
  729. Error += Data[i].Return == Result ? 0 : 1;
  730. }
  731. for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
  732. {
  733. glm::int32 Result = sign_if(Data[i].Value);
  734. Error += Data[i].Return == Result ? 0 : 1;
  735. }
  736. for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
  737. {
  738. glm::int32 Result = sign_alu1(Data[i].Value);
  739. Error += Data[i].Return == Result ? 0 : 1;
  740. }
  741. for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
  742. {
  743. glm::int32 Result = sign_alu2(Data[i].Value);
  744. Error += Data[i].Return == Result ? 0 : 1;
  745. }
  746. return Error;
  747. }
  748. int test_i32vec4()
  749. {
  750. type<glm::i32vec4> const Data[] =
  751. {
  752. {glm::i32vec4( 1), glm::i32vec4( 1)},
  753. {glm::i32vec4( 0), glm::i32vec4( 0)},
  754. {glm::i32vec4( 2), glm::i32vec4( 1)},
  755. {glm::i32vec4( 3), glm::i32vec4( 1)},
  756. {glm::i32vec4(-1), glm::i32vec4(-1)},
  757. {glm::i32vec4(-2), glm::i32vec4(-1)},
  758. {glm::i32vec4(-3), glm::i32vec4(-1)}
  759. };
  760. int Error = 0;
  761. for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::i32vec4>); ++i)
  762. {
  763. glm::i32vec4 Result = glm::sign(Data[i].Value);
  764. Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1;
  765. }
  766. return Error;
  767. }
  768. int test()
  769. {
  770. int Error = 0;
  771. Error += test_int32();
  772. Error += test_i32vec4();
  773. return Error;
  774. }
  775. int perf_rand()
  776. {
  777. int Error = 0;
  778. std::size_t const Count = 100000000;
  779. std::vector<glm::int32> Input, Output;
  780. Input.resize(Count);
  781. Output.resize(Count);
  782. for(std::size_t i = 0; i < Count; ++i)
  783. Input[i] = static_cast<glm::int32>(glm::linearRand(-65536.f, 65536.f));
  784. std::clock_t Timestamp0 = std::clock();
  785. for(std::size_t i = 0; i < Count; ++i)
  786. Output[i] = sign_cmp(Input[i]);
  787. std::clock_t Timestamp1 = std::clock();
  788. for(std::size_t i = 0; i < Count; ++i)
  789. Output[i] = sign_if(Input[i]);
  790. std::clock_t Timestamp2 = std::clock();
  791. for(std::size_t i = 0; i < Count; ++i)
  792. Output[i] = sign_alu1(Input[i]);
  793. std::clock_t Timestamp3 = std::clock();
  794. for(std::size_t i = 0; i < Count; ++i)
  795. Output[i] = sign_alu2(Input[i]);
  796. std::clock_t Timestamp4 = std::clock();
  797. for(std::size_t i = 0; i < Count; ++i)
  798. Output[i] = sign_sub(Input[i]);
  799. std::clock_t Timestamp5 = std::clock();
  800. for(std::size_t i = 0; i < Count; ++i)
  801. Output[i] = glm::sign(Input[i]);
  802. std::clock_t Timestamp6 = std::clock();
  803. std::printf("sign_cmp(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp1 - Timestamp0));
  804. std::printf("sign_if(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp2 - Timestamp1));
  805. std::printf("sign_alu1(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp3 - Timestamp2));
  806. std::printf("sign_alu2(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp4 - Timestamp3));
  807. std::printf("sign_sub(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp5 - Timestamp4));
  808. std::printf("glm::sign(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp6 - Timestamp5));
  809. return Error;
  810. }
  811. int perf_linear()
  812. {
  813. int Error = 0;
  814. std::size_t const Count = 10000000;
  815. std::vector<glm::int32> Input, Output;
  816. Input.resize(Count);
  817. Output.resize(Count);
  818. for(std::size_t i = 0; i < Count; ++i)
  819. Input[i] = static_cast<glm::int32>(i);
  820. std::clock_t Timestamp0 = std::clock();
  821. for(std::size_t i = 0; i < Count; ++i)
  822. Output[i] = sign_cmp(Input[i]);
  823. std::clock_t Timestamp1 = std::clock();
  824. for(std::size_t i = 0; i < Count; ++i)
  825. Output[i] = sign_if(Input[i]);
  826. std::clock_t Timestamp2 = std::clock();
  827. for(std::size_t i = 0; i < Count; ++i)
  828. Output[i] = sign_alu1(Input[i]);
  829. std::clock_t Timestamp3 = std::clock();
  830. for(std::size_t i = 0; i < Count; ++i)
  831. Output[i] = sign_alu2(Input[i]);
  832. std::clock_t Timestamp4 = std::clock();
  833. for(std::size_t i = 0; i < Count; ++i)
  834. Output[i] = sign_sub(Input[i]);
  835. std::clock_t Timestamp5 = std::clock();
  836. std::printf("sign_cmp(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp1 - Timestamp0));
  837. std::printf("sign_if(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp2 - Timestamp1));
  838. std::printf("sign_alu1(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp3 - Timestamp2));
  839. std::printf("sign_alu2(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp4 - Timestamp3));
  840. std::printf("sign_sub(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp5 - Timestamp4));
  841. return Error;
  842. }
  843. int perf_linear_cal()
  844. {
  845. int Error = 0;
  846. glm::uint32 const Count = 10000000;
  847. std::clock_t Timestamp0 = std::clock();
  848. glm::int32 Sum = 0;
  849. for(glm::int32 i = 1; i < Count; ++i)
  850. Sum += sign_cmp(i);
  851. std::clock_t Timestamp1 = std::clock();
  852. for(glm::int32 i = 1; i < Count; ++i)
  853. Sum += sign_if(i);
  854. std::clock_t Timestamp2 = std::clock();
  855. for(glm::int32 i = 1; i < Count; ++i)
  856. Sum += sign_alu1(i);
  857. std::clock_t Timestamp3 = std::clock();
  858. for(glm::int32 i = 1; i < Count; ++i)
  859. Sum += sign_alu2(i);
  860. std::clock_t Timestamp4 = std::clock();
  861. for(glm::int32 i = 1; i < Count; ++i)
  862. Sum += sign_sub(i);
  863. std::clock_t Timestamp5 = std::clock();
  864. std::printf("Sum %d\n", static_cast<unsigned int>(Sum));
  865. std::printf("sign_cmp(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp1 - Timestamp0));
  866. std::printf("sign_if(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp2 - Timestamp1));
  867. std::printf("sign_alu1(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp3 - Timestamp2));
  868. std::printf("sign_alu2(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp4 - Timestamp3));
  869. std::printf("sign_sub(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp5 - Timestamp4));
  870. return Error;
  871. }
  872. int perf()
  873. {
  874. int Error(0);
  875. Error += perf_linear_cal();
  876. Error += perf_linear();
  877. Error += perf_rand();
  878. return Error;
  879. }
  880. }//namespace sign
  881. int main()
  882. {
  883. int Error(0);
  884. Error += sign::test();
  885. Error += floor_::test();
  886. Error += modf_::test();
  887. Error += floatBitsToInt::test();
  888. Error += floatBitsToUint::test();
  889. Error += step_::test();
  890. Error += max_::test();
  891. Error += min_::test();
  892. Error += mix_::test();
  893. Error += round_::test();
  894. Error += roundEven::test();
  895. Error += isnan_::test();
  896. Error += isinf_::test();
  897. # ifdef GLM_TEST_ENABLE_PERF
  898. Error += sign::perf();
  899. # endif
  900. return Error;
  901. }