コード例 #1
0
 /**
  * @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));
 }
コード例 #2
0
 /**
  * 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ᵀ);
 }