github.com/primecitizens/pcz/std@v0.2.1/math/matrix/mat4_test.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package matrix 5 6 import ( 7 "testing" 8 ) 9 10 func TestMat4_Mul(t *testing.T) { 11 x := Mat4[uint8]{ 12 1, 1, 1, 1, 13 1, 1, 1, 1, 14 1, 1, 1, 1, 15 1, 1, 1, 1, 16 } 17 18 expcted := Mat4[uint8]{ 19 10, 10, 10, 10, 20 26, 26, 26, 26, 21 42, 42, 42, 42, 22 58, 58, 58, 58, 23 } 24 25 if *x.Mul(Mat4[uint8]{ 26 1, 2, 3, 4, 27 5, 6, 7, 8, 28 9, 10, 11, 12, 29 13, 14, 15, 16, 30 }) != expcted { 31 t.Error(x) 32 } 33 } 34 35 func BenchmarkMat4_Mul(b *testing.B) { 36 b.Run("Mul", func(b *testing.B) { 37 var x Mat4[uint8] 38 for i := 0; i < b.N; i++ { 39 _ = x.Mul(x) 40 } 41 }) 42 43 b.Run("MulV", func(b *testing.B) { 44 var x Mat4[uint8] 45 for i := 0; i < b.N; i++ { 46 _ = x.MulV(x) 47 } 48 }) 49 }