@@ -11,6 +11,26 @@ function testExpected (testObj) {
1111 return { ...testObj , expect : refMultiply ( ...testObj . args ) } ;
1212}
1313
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+
1434function expectThrows ( testObj ) {
1535 let refResult ;
1636 try {
@@ -66,6 +86,39 @@ export default {
6686 name : "3x3 matrix with other 3x3 matrix" ,
6787 args : [ M_XYZ_to_lin_sRGB , M_lin_sRGB_to_XYZ ] ,
6888 } ,
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+ } ,
69122 ] . map ( testExpected ) ,
70123 } ,
71124 {
@@ -95,23 +148,13 @@ export default {
95148 ] . map ( expectThrows ) ,
96149 } ,
97150 {
98- name : "Transform " ,
151+ name : "Specialized Matrix 3x3 and Vector 3 Multiplication " ,
99152 run : multiply_v3_m3x3 ,
100153 tests : [
101154 {
102155 name : "3x3 matrix with vector" ,
103156 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 ( ) ,
114157 } ,
115- ] ,
158+ ] . map ( reverseExpectedArgs ) . flatMap ( ( test ) => [ test , testInPlace ( test ) ] ) ,
116159 } ] ,
117160} ;
0 commit comments