In the context of partitioned matrices I'm trying to do the following:
$a11 = Matrix( [ 1 ] ); $a12 = Matrix( [ 2, 3, 4 ] ); $a21 = Matrix( [ 5 ], [ 6 ], [ 7 ] ); $a22 = Matrix( [ 8, 9, 10 ], [ 11, 12, 13 ], [ 14, 15, 16 ] ); $b11 = Matrix( [ 21 ] ); $b12 = Matrix( [ 22, 23, 24 ] ); $b21 = Matrix( [ 25 ], [ 26 ], [ 27 ] ); $b22 = Matrix( [ 28, 29, 30 ], [ 31, 32, 33 ], [ 34, 35, 36 ] ); $c11 = $a11 * $b11 + $a12 * $b21; $c12 = $a11 * $b12 + $a12 * $b22; $c21 = $a21 * $b11 + $a22 * $b21; $c22 = $a21 * $b12 + $a22 * $b22;
but this fails: I'm accused of trying to add or multiply matrices of different dimensions. I tried building the matrices by explicitly indicating the full structure, e.g.,
$a11 = Matrix( [ [ 1 ] ] ); $a12 = Matrix( [ [ 2, 3, 4 ] ] ); $a21 = Matrix( [ [ 5 ], [ 6 ], [ 7 ] ] ); $a22 = Matrix( [ [ 8, 9, 10 ], [ 11, 12, 13 ], [ 14, 15, 16 ] ] );
in which case the problem displays fine, but the answers solicited by $c11->ans_array()
and $c12->ans_array()
are marked wrong with the message "Matrix dimension is not correct."
Any suggestions are welcome.
Thanks,
Gavin