@@ -11,6 +11,26 @@ function testExpected (testObj) {
11
11
return { ...testObj , expect : refMultiply ( ...testObj . args ) } ;
12
12
}
13
13
14
+ /**
15
+ * Converts row-major ordered & pre-multiplication arguments
16
+ * into column-major ordered & post-multiplication equivalent
17
+ */
18
+ function reverseExpectedArgs ( testObj ) {
19
+ return { ...testObj , expect : refMultiply ( testObj . args [ 1 ] , testObj . args [ 0 ] ) } ;
20
+ }
21
+
22
+ /** Creates in place multiplication tests for `multiply_v3_m3x3` */
23
+ function testInPlace ( testObj ) {
24
+ return {
25
+ ...testObj ,
26
+ name : `${ testObj . name } in place` ,
27
+ run ( A , B ) {
28
+ multiply_v3_m3x3 ( A , B , A ) ;
29
+ return A ;
30
+ } ,
31
+ } ;
32
+ }
33
+
14
34
function expectThrows ( testObj ) {
15
35
let refResult ;
16
36
try {
@@ -66,6 +86,39 @@ export default {
66
86
name : "3x3 matrix with other 3x3 matrix" ,
67
87
args : [ M_XYZ_to_lin_sRGB , M_lin_sRGB_to_XYZ ] ,
68
88
} ,
89
+ {
90
+ name : "Vector with 3x3 matrix" ,
91
+ skip : true , // multiplyMatrices doesn't properly reduce dimensions for vector and matrix multiplication
92
+ args : [ [ 1 , 0.5 , 0 ] , M_lin_sRGB_to_XYZ ] ,
93
+ } ,
94
+ {
95
+ name : "Vector with other 3x3 matrix" ,
96
+ skip : true , // multiplyMatrices doesn't properly reduce dimensions for vector and matrix multiplication
97
+ args : [ [ 1 , 0.5 , 0 ] , M_XYZ_to_lin_sRGB ] ,
98
+ } ,
99
+ ] . map ( testExpected ) ,
100
+ } ,
101
+ {
102
+ name : "1x1 Edge Cases" ,
103
+ skip : true , // 1x1 Boundary Cases are not handled
104
+ description : "Test boundary case for m x n × n x p, where m = n = p = 1." ,
105
+ tests : [
106
+ {
107
+ name : "1x1 vectors" ,
108
+ args : [ [ 1 ] , [ 2 ] ] ,
109
+ } ,
110
+ {
111
+ name : "1x1 matrices" ,
112
+ args : [ [ [ 3 ] ] , [ [ 4 ] ] ] ,
113
+ } ,
114
+ {
115
+ name : "1x1 vector × 1x1 matrix" ,
116
+ args : [ [ 5 ] , [ [ 6 ] ] ] ,
117
+ } ,
118
+ {
119
+ name : "1x1 matrix × 1x1 vector" ,
120
+ args : [ [ [ 7 ] ] , [ 8 ] ] ,
121
+ } ,
69
122
] . map ( testExpected ) ,
70
123
} ,
71
124
{
@@ -95,23 +148,13 @@ export default {
95
148
] . map ( expectThrows ) ,
96
149
} ,
97
150
{
98
- name : "Transform " ,
151
+ name : "Specialized Matrix 3x3 and Vector 3 Multiplication " ,
99
152
run : multiply_v3_m3x3 ,
100
153
tests : [
101
154
{
102
155
name : "3x3 matrix with vector" ,
103
156
args : [ [ 1 , .5 , 0 ] , M_lin_sRGB_to_XYZ ] ,
104
- expect : math . multiply ( math . matrix ( M_lin_sRGB_to_XYZ ) , math . matrix ( [ 1 , .5 , 0 ] ) ) . valueOf ( ) ,
105
- } ,
106
- {
107
- name : "3x3 matrix with vector in place" ,
108
- run ( A , B ) {
109
- multiply_v3_m3x3 ( A , B , A ) ;
110
- return A ;
111
- } ,
112
- args : [ [ 1 , .5 , 0 ] , M_lin_sRGB_to_XYZ ] ,
113
- expect : math . multiply ( math . matrix ( M_lin_sRGB_to_XYZ ) , math . matrix ( [ 1 , .5 , 0 ] ) ) . valueOf ( ) ,
114
157
} ,
115
- ] ,
158
+ ] . map ( reverseExpectedArgs ) . flatMap ( ( test ) => [ test , testInPlace ( test ) ] ) ,
116
159
} ] ,
117
160
} ;
0 commit comments