testReciprocal.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. this.WScript.LoadScriptFile("..\\UnitTestFramework\\SimdJsHelpers.js");
  6. function testreciprocalApproximation() {
  7. var a = SIMD.Float32x4(8.0, 4.0, 2.0, -2.0);
  8. var c = SIMD.Float32x4.reciprocalApproximation(a);
  9. equal(0.125, SIMD.Float32x4.extractLane(c, 0));
  10. equal(0.250, SIMD.Float32x4.extractLane(c, 1));
  11. equal(0.5, SIMD.Float32x4.extractLane(c, 2));
  12. equal(-0.5, SIMD.Float32x4.extractLane(c, 3));
  13. }
  14. function testreciprocalSqrtApproximation() {
  15. var a = SIMD.Float32x4(1.0, 0.25, 0.111111, 0.0625);
  16. var c = SIMD.Float32x4.reciprocalSqrtApproximation(a);
  17. equal(1.0, SIMD.Float32x4.extractLane(c, 0));
  18. equal(2.0, SIMD.Float32x4.extractLane(c, 1));
  19. equal(3.0, SIMD.Float32x4.extractLane(c, 2));
  20. equal(4.0, SIMD.Float32x4.extractLane(c, 3));
  21. }
  22. testreciprocalApproximation();
  23. testreciprocalApproximation();
  24. testreciprocalApproximation();
  25. testreciprocalApproximation();
  26. testreciprocalApproximation();
  27. testreciprocalApproximation();
  28. testreciprocalApproximation();
  29. testreciprocalSqrtApproximation();
  30. testreciprocalSqrtApproximation();
  31. testreciprocalSqrtApproximation();
  32. testreciprocalSqrtApproximation();
  33. testreciprocalSqrtApproximation();
  34. testreciprocalSqrtApproximation();
  35. testreciprocalSqrtApproximation();
  36. testreciprocalSqrtApproximation();
  37. print("PASS");