text: Kronecker Product of two matrices | rowa and cola are no of rows and columns of matrix A rowb and colb are no of rows and columns of matrix B ; Function to computes the Kronecker Product of two matrices ; i loops till rowa ; k loops till rowb ; j loops till cola ; l loops till colb ; Each element of matrix A is multiplied by whole Matrix B resp and stored as Matrix C ; Driver Code
code: < ? php $ cola = 2 ; $ rowa = 3 ; $ colb = 3 ; $ rowb = 2 ; function Kroneckerproduct ( $ A , $ B ) { global $ cola ; global $ rowa ; global $ colb ; global $ rowb ; $ C ; for ( $ i = 0 ; $ i < $ rowa ; $ i ++ ) { for ( $ k = 0 ; $ k < $ rowb ; $ k ++ ) { for ( $ j = 0 ; $ j < $ cola ; $ j ++ ) { for ( $ l = 0 ; $ l < $ colb ; $ l ++ ) { $ C [ $ i + $ l + 1 ] [ $ j + $ k + 1 ] = $ A [ $ i ] [ $ j ] * $ B [ $ k ] [ $ l ] ; echo ( $ C [ $ i + $ l + 1 ] [ $ j + $ k + 1 ] ) , " TABSYMBOL " ; } } echo " STRNEWLINE " ; } } } $ A = array ( array ( 1 , 2 ) , array ( 3 , 4 ) , array ( 1 , 0 ) ) ; $ B = array ( array ( 0 , 5 , 2 ) , array ( 6 , 7 , 3 ) ) ; Kroneckerproduct ( $ A , $ B ) ; ? >