2424 * - A(B + C) = AB + BC
2525 * - (A + B)C = AC + BC
2626 * - r(AB) = (rA)B = A(rB)
27+ * - (λ + ψ)A = λA + ψA
2728 * - Identity
2829 * - AI = A = IA
2930 * - I is involutory
@@ -272,7 +273,7 @@ public function dataProviderForScalarMultiplicationOrderAddition(): array
272273
273274 /**
274275 * @test Axiom: A + (−A) = 0
275- * Adding the negate of a matrix is a zero matrix.
276+ * Adding the negation of a matrix is a zero matrix.
276277 *
277278 * @dataProvider dataProviderForNegateAdditionZeroMatrix
278279 * @param array $A
@@ -543,7 +544,7 @@ public function dataProviderForMultiplicationIsDistributive(): array
543544 * @param int $r
544545 * @throws \Exception
545546 */
546- public function testScalarMultiplcationOrder (array $ A , array $ B , int $ r )
547+ public function testScalarMultiplicationOrder (array $ A , array $ B , int $ r )
547548 {
548549 // Given
549550 $ A = MatrixFactory::create ($ A );
@@ -567,6 +568,35 @@ public function testScalarMultiplcationOrder(array $A, array $B, int $r)
567568 $ this ->assertEquals ($ r⟮AB⟯ ->getMatrix (), $ A⟮rB⟯ ->getMatrix ());
568569 }
569570
571+ /**
572+ * @test Axiom: (λ + ψ)A = λA + ψA
573+ * Scalar multiplication is distributive
574+ *
575+ * @dataProvider dataProviderForSingleMatrix
576+ * @param array $A
577+ * @throws \Exception
578+ */
579+ public function testScalarDistributivity (array $ A )
580+ {
581+ // Given
582+ $ A = MatrixFactory::create ($ A );
583+
584+ // And
585+ $ λ = 5 ;
586+ $ ψ = 3 ;
587+
588+ // When (λ + ψ)A
589+ $ ⟮λ+ψ⟯A = $ A ->scalarMultiply ($ λ + $ ψ );
590+
591+ // And λA + ψA
592+ $ λA = $ A ->scalarMultiply ($ λ );
593+ $ ψA = $ A ->scalarMultiply ($ ψ );
594+ $ ⟮λA+ψA⟯ = $ λA ->add ($ ψA );
595+
596+ // Then (λ + ψ)A = λA + ψA
597+ $ this ->assertEquals ($ ⟮λ+ψ⟯A ->getMatrix (), $ ⟮λA+ψA⟯ ->getMatrix ());
598+ }
599+
570600 /**
571601 * @return array
572602 */
0 commit comments