testSqrt.js 935 B

123456789101112131415161718192021222324252627282930
  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. function equal(a, b) {
  6. if (a == b) {
  7. print("Correct");
  8. } else {
  9. print(">> Fail!");
  10. }
  11. }
  12. function testSqrt() {
  13. print("Float32x4 Sqrt");
  14. var a = SIMD.Float32x4(16.0, 9.0, 4.0, 1.0);
  15. var c = SIMD.Float32x4.sqrt(a);
  16. equal(4.0, SIMD.Float32x4.extractLane(c, 0));
  17. equal(3.0, SIMD.Float32x4.extractLane(c, 1));
  18. equal(2.0, SIMD.Float32x4.extractLane(c, 2));
  19. equal(1.0, SIMD.Float32x4.extractLane(c, 3));
  20. }
  21. testSqrt();
  22. testSqrt();
  23. testSqrt();
  24. testSqrt();
  25. testSqrt();
  26. testSqrt();
  27. testSqrt();