comparison tests/test_matrix.nim @ 58:8287a91e5d56

did: refactor Matrix names
author Sam <sam@basx.dev>
date Fri, 20 Jan 2023 16:36:52 +0700
parents 547f3a374271
children 77755701bf49
comparison
equal deleted inserted replaced
57:547f3a374271 58:8287a91e5d56
31 proc randVec4I(): auto = newVec4(rand(1 .. 10), rand(1 .. 10), rand(1 .. 10), rand(1 .. 10)) 31 proc randVec4I(): auto = newVec4(rand(1 .. 10), rand(1 .. 10), rand(1 .. 10), rand(1 .. 10))
32 proc randVec4F(): auto = newVec4(rand(10'f) + 0.01, rand(10'f) + 0.01, rand(10'f) + 0.01, rand(10'f) + 0.01) 32 proc randVec4F(): auto = newVec4(rand(10'f) + 0.01, rand(10'f) + 0.01, rand(10'f) + 0.01, rand(10'f) + 0.01)
33 33
34 34
35 template withAllIntegerMats(stuff: untyped) = 35 template withAllIntegerMats(stuff: untyped) =
36 stuff(Mat22[int32]) 36 stuff(TMat22[int32])
37 stuff(Mat23[int32]) 37 stuff(TMat23[int32])
38 stuff(Mat32[int32]) 38 stuff(TMat32[int32])
39 stuff(Mat33[int32]) 39 stuff(TMat33[int32])
40 stuff(Mat34[int32]) 40 stuff(TMat34[int32])
41 stuff(Mat43[int32]) 41 stuff(TMat43[int32])
42 stuff(Mat44[int32]) 42 stuff(TMat44[int32])
43 stuff(Mat22[int64]) 43 stuff(TMat22[int64])
44 stuff(Mat23[int64]) 44 stuff(TMat23[int64])
45 stuff(Mat32[int64]) 45 stuff(TMat32[int64])
46 stuff(Mat33[int64]) 46 stuff(TMat33[int64])
47 stuff(Mat34[int64]) 47 stuff(TMat34[int64])
48 stuff(Mat43[int64]) 48 stuff(TMat43[int64])
49 stuff(Mat44[int64]) 49 stuff(TMat44[int64])
50 50
51 template withAllFloatMats(stuff: untyped) = 51 template withAllFloatMats(stuff: untyped) =
52 stuff(Mat22[float32]) 52 stuff(TMat22[float32])
53 stuff(Mat23[float32]) 53 stuff(TMat23[float32])
54 stuff(Mat32[float32]) 54 stuff(TMat32[float32])
55 stuff(Mat33[float32]) 55 stuff(TMat33[float32])
56 stuff(Mat34[float32]) 56 stuff(TMat34[float32])
57 stuff(Mat43[float32]) 57 stuff(TMat43[float32])
58 stuff(Mat44[float32]) 58 stuff(TMat44[float32])
59 stuff(Mat22[float64]) 59 stuff(TMat22[float64])
60 stuff(Mat23[float64]) 60 stuff(TMat23[float64])
61 stuff(Mat32[float64]) 61 stuff(TMat32[float64])
62 stuff(Mat33[float64]) 62 stuff(TMat33[float64])
63 stuff(Mat34[float64]) 63 stuff(TMat34[float64])
64 stuff(Mat43[float64]) 64 stuff(TMat43[float64])
65 stuff(Mat44[float64]) 65 stuff(TMat44[float64])
66 66
67 template withAllMats(stuff: untyped) = 67 template withAllMats(stuff: untyped) =
68 stuff(Mat22[int]) 68 stuff(TMat22[int])
69 stuff(Mat23[int]) 69 stuff(TMat23[int])
70 stuff(Mat32[int]) 70 stuff(TMat32[int])
71 stuff(Mat33[int]) 71 stuff(TMat33[int])
72 stuff(Mat34[int]) 72 stuff(TMat34[int])
73 stuff(Mat43[int]) 73 stuff(TMat43[int])
74 stuff(Mat44[int]) 74 stuff(TMat44[int])
75 stuff(Mat22[float]) 75 stuff(TMat22[float])
76 stuff(Mat23[float]) 76 stuff(TMat23[float])
77 stuff(Mat32[float]) 77 stuff(TMat32[float])
78 stuff(Mat33[float]) 78 stuff(TMat33[float])
79 stuff(Mat34[float]) 79 stuff(TMat34[float])
80 stuff(Mat43[float]) 80 stuff(TMat43[float])
81 stuff(Mat44[float]) 81 stuff(TMat44[float])
82 82
83 template testTranspose(t: typedesc) = 83 template testTranspose(t: typedesc) =
84 echo "testTranspose: ", t 84 echo "testTranspose: ", t
85 let m = t().randomized() 85 let m = t().randomized()
86 assert m == m.transposed().transposed() 86 assert m == m.transposed().transposed()
131 echo Unit44i8 131 echo Unit44i8
132 echo Unit44i16 132 echo Unit44i16
133 echo Unit44i32 133 echo Unit44i32
134 echo Unit44i64 134 echo Unit44i64
135 135
136 echo Mat22[float]().randomized() * One2.randomized() 136 echo TMat22[float]().randomized() * One2.randomized()
137 echo Mat33[float]().randomized() * One3.randomized() 137 echo TMat33[float]().randomized() * One3.randomized()
138 echo Mat44[float]().randomized() * One4.randomized() 138 echo TMat44[float]().randomized() * One4.randomized()
139 139
140 randomize() 140 randomize()
141 testMatrix() 141 testMatrix()