/** * @dataProvider dataProviderForOuterProduct */ public function testOuterProduct(array $A, array $B, array $R) { $A = new Vector($A); $B = new Vector($B); $R = new Matrix($R); $this->assertEquals($R, $A->outerProduct($B)); }
/** * Axiom: A⨂B = ABᵀ * Outer product is the same as matrix multiplication of A and transpose of B * @dataProvider dataProviderForOuterProduct */ public function testOuterProductIsMatrixMultiplicationOfAAndBTranspose(array $A, array $B) { // Vector A⨂B $Av = new Vector($A); $Bv = new Vector($B); $A⨂B = $Av->outerProduct($Bv); // Matrix multiplication ABᵀ $Am = $Av->asColumnMatrix(); $Bᵀ = new Matrix([$Bv->getVector()]); $ABᵀ = $Am->multiply($Bᵀ); $this->assertEquals($A⨂B, $ABᵀ); }