Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. fn matmul(comptime T: type, a: [][]T, b: [][]T, c: [][]T) void {}
  2.  
  3. fn translate(x: f64, y: f64) [3][3]f64 {
  4. return [_][_]f64{
  5. [_]f64{ 1, 0, x },
  6. [_]f64{ 0, 1, y },
  7. [_]f64{ 0, 0, 1 },
  8. };
  9. }
  10.  
  11. test "translate" {
  12. const point = [2][1]f64{
  13. [_]f64{2},
  14. [_]f64{1},
  15. };
  16.  
  17. const actual = [_][1]f64{[_]f64{0}} ** 2;
  18. const translation = translate(-3, 1);
  19. try matmul(f64, translation[0..], point, &actual);
  20.  
  21. const expected = [_][_]f64{
  22. [_]f64{-1},
  23. [_]f64{2},
  24. };
  25.  
  26. assert(std.mem.equal(f64, actual, expected));
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement