Guest User

Untitled

a guest
Nov 17th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. test "matmul" {
  2. const T = i64;
  3. const M = 3;
  4. const N = 4;
  5. const P = 2;
  6.  
  7. const A = [M][N]T{
  8. [_]T{ 1, 2, 1, -2 },
  9. [_]T{ -1, 3, 2, 4 },
  10. [_]T{ 0, 1, -1, 0 },
  11. };
  12.  
  13. const B = [N][P]T{
  14. [_]T{ 1, 2 },
  15. [_]T{ -2, 1 },
  16. [_]T{ 3, 0 },
  17. [_]T{ 0, 1 },
  18. };
  19.  
  20. const actual = matmul(A, B);
  21.  
  22. const expected = [M][P]T{
  23. [_]T{ 0, 2 },
  24. [_]T{ -1, 5 },
  25. [_]T{ -5, 1 },
  26. };
  27.  
  28. var m: u64 = 0;
  29. while (m < M) : (m += 1) {
  30. std.debug.assert(std.mem.eql(T, actual[m], expected[m]));
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment