PHP Class MathPHP\LinearAlgebra\VectorAxiomsTest

If all the Vector math is implemented properly, these tests should all work out according to the axioms. Axioms tested: - Norms - |x|₂ ≤ |x|₁ ≤ √n |x|₂ - |x|∞ ≤ |x|₂ ≤ √n |x|∞ - |x|∞ ≤ |x|₁ ≤ √n |x|∞ - Dot product - A⋅B = B⋅A - 0⋅A = A⋅0 = 0 - Cross product - A x B = -(B x A) - A x 0 = 0 - A x (B + C) = (A x B) + (A x C) - Cross product / dot product - (A x B) ⋅ A = 0 - (A x B) ⋅ B = 0 - A ⋅ (B x C) = (A x B) ⋅ C - A x (B x C) = (A ⋅ C)B - (A ⋅ B)C - Outer product - A⨂B = ABᵀ - Scalar multiplication - (c + d)A = cA + dA - c(A + B) = cA + cB - 1A = A - 0A = 0 - -1A = -A - Perpendicular / Perp dot product - A⋅A⊥ = 0 - A⊥⋅A = 0 - A⋅A⊥ = -A⊥⋅A - Projections / Perps - projᵇA + perpᵇA = A - |projᵇA|² + |perpᵇA|² = |A|² - projᵇA ⋅ perpᵇA = 0 - |projᵇA⊥ ⋅ perpᵇA| = |projᵇA| |perpᵇA|
Inheritance: extends PHPUnit_Framework_TestCase
Show file Open project: markrogoyski/math-php

Public Methods

Method Description
dataProviderForAdditiveInverse ( )
dataProviderForCrossProduct ( )
dataProviderForCrossProductThreeVectors ( )
dataProviderForDotProductZero ( )
dataProviderForOuterProduct ( )
dataProviderForPerpendicularIdentity ( )
dataProviderForProjPerp ( )
dataProviderForSingleVector ( )
dataProviderForTwoVectors ( )
testAdditivityInTheScalarForScalarMultiplication ( array $A ) Axiom: (c + d)A = cA + dA Additivity in the scalar
testAdditivityInTheVectorForScalarMultiplication ( array $A, array $B ) Axiom: c(A + B) = cA + cB Additivity in the vector
testCrossProductDistributivity ( array $A, array $B, array $C ) Axiom: A x (B + C) = (A x B) + (A x C) Cross product distributivity
testCrossProductInnerProductWithEitherVectorIsZero ( array $A, array $B ) Axiom: (A x B) ⋅ A = 0 Axiom: (A x B) ⋅ B = 0 Dot product of either vector with the cross product is always zero.
testCrossProductLagrangeFormula ( array $A, array $B, array $C ) Axiom: A x (B x C) = (A ⋅ C)B - (A ⋅ B)C Lagrange's formula
testCrossProductPropertyOfZero ( array $A, array $_ ) Axiom: A x 0 = 0 Cross product property of 0
testCrossProductVolumeProperty ( array $A, array $B, array $C ) Axiom: A ⋅ (B x C) = (A x B) ⋅ C Cross product volumn property
testDotProductCommutative ( array $A, array $B ) Axiom: A⋅B = B⋅A Dot product is commutative
testDotProductZero ( array $A, array $zero ) Axiom: 0⋅A = A⋅0 = 0 Dot product of a vector and zero is zero.
testL2NormLessThanL1NormLessThanSqrtNL2Norm ( array $V ) Axiom: |x|₂ ≤ |x|₁ ≤ √n |x|₂ l²-norm is less than equal to l₁-norm which is less than equal to sqrt n * l²-norm.
testMaxNormLessThanEqualL1NormLessThanEqualSqrtNMaxNorm ( array $V ) Axiom: |x|∞ ≤ |x|₁ ≤ √n |x|∞ Max norm is less than equal to l₁-norm which is less than equal to sqrt n * max norm.
testMaxNormLessThtanEQualL2NormLessThanEqualSqrtNMaxNorm ( array $V ) Axiom: |x|∞ ≤ |x|₂ ≤ √n |x|∞ Max norm is less than equal to l₂-norm which is less than equal to sqrt n * max norm.
testOuterProductIsMatrixMultiplicationOfAAndBTranspose ( array $A, array $B ) Axiom: A⨂B = ABᵀ Outer product is the same as matrix multiplication of A and transpose of B
testPerpDotProdcutSwapOperandsChangeSign ( array $A ) Axiom: A⋅A⊥ = -A⊥⋅A Swapping operands changes the sign of the perp dot product
testPerpDotProductZero ( array $A ) Axiom: A⊥⋅A = 0 Perp dot product with itself will be zero.
testPerpendicularDotProduct ( array $A ) Axiom: A⋅A⊥ = 0 Vector dot product with a vector perpendicular to it will be zero.
testProjPerpDotProductEqualsZero ( array $A, array $B ) Axiom: projᵇA ⋅ perpᵇA = 0 Dot product of proj and perp of A on B is 0
testProjPerpPerpDotProductEqualsProductOfLengths ( array $A, array $B ) Axiom: |projᵇA⊥ ⋅ perpᵇA| = |projᵇA| |perpᵇA| Absolute value of proj and perp dot product equals product of their lengths.
testProjPerpSumEqualsA ( array $A, array $B ) Axiom: projᵇA + perpᵇA = A Sum of the proj and perp of A on B equals A
testProjPerpSumOfSquares ( array $A, array $B ) Axiom: |projᵇA|² + |perpᵇA|² = |A|² Sum of squared lengths of proj and perp equals squared length of A
testReverseCrossProduct ( array $A, array $B ) Axiom: A x B = -(B x A) Anticommutivity: Reverse order cross product results in a negative cross product
testScalarMultiplyNegativeOneIdentity ( array $A, array $R ) Axiom: -1A = -A Additive inverse
testScalarMultiplyOneIdentity ( array $A ) Axiom: 1A = A Multiplying (scaling) by 1 does not change the vector
testScalarMultiplyZeroIdentity ( array $A ) Axiom: 0A = 0 Multiplying (scaling) by 0 gives the zero vector

Method Details

dataProviderForAdditiveInverse() public method

dataProviderForCrossProduct() public method

dataProviderForCrossProductThreeVectors() public method

dataProviderForDotProductZero() public method

dataProviderForOuterProduct() public method

dataProviderForPerpendicularIdentity() public method

dataProviderForProjPerp() public method

dataProviderForSingleVector() public method

dataProviderForTwoVectors() public method

testAdditivityInTheScalarForScalarMultiplication() public method

Axiom: (c + d)A = cA + dA Additivity in the scalar

testAdditivityInTheVectorForScalarMultiplication() public method

Axiom: c(A + B) = cA + cB Additivity in the vector

testCrossProductDistributivity() public method

Axiom: A x (B + C) = (A x B) + (A x C) Cross product distributivity

testCrossProductInnerProductWithEitherVectorIsZero() public method

Axiom: (A x B) ⋅ A = 0 Axiom: (A x B) ⋅ B = 0 Dot product of either vector with the cross product is always zero.

testCrossProductLagrangeFormula() public method

Axiom: A x (B x C) = (A ⋅ C)B - (A ⋅ B)C Lagrange's formula

testCrossProductPropertyOfZero() public method

Axiom: A x 0 = 0 Cross product property of 0

testCrossProductVolumeProperty() public method

Axiom: A ⋅ (B x C) = (A x B) ⋅ C Cross product volumn property

testDotProductCommutative() public method

Axiom: A⋅B = B⋅A Dot product is commutative
public testDotProductCommutative ( array $A, array $B )
$A array
$B array

testDotProductZero() public method

Axiom: 0⋅A = A⋅0 = 0 Dot product of a vector and zero is zero.
public testDotProductZero ( array $A, array $zero )
$A array
$zero array

testL2NormLessThanL1NormLessThanSqrtNL2Norm() public method

Axiom: |x|₂ ≤ |x|₁ ≤ √n |x|₂ l²-norm is less than equal to l₁-norm which is less than equal to sqrt n * l²-norm.

testMaxNormLessThanEqualL1NormLessThanEqualSqrtNMaxNorm() public method

Axiom: |x|∞ ≤ |x|₁ ≤ √n |x|∞ Max norm is less than equal to l₁-norm which is less than equal to sqrt n * max norm.

testMaxNormLessThtanEQualL2NormLessThanEqualSqrtNMaxNorm() public method

Axiom: |x|∞ ≤ |x|₂ ≤ √n |x|∞ Max norm is less than equal to l₂-norm which is less than equal to sqrt n * max norm.

testOuterProductIsMatrixMultiplicationOfAAndBTranspose() public method

Axiom: A⨂B = ABᵀ Outer product is the same as matrix multiplication of A and transpose of B

testPerpDotProdcutSwapOperandsChangeSign() public method

Axiom: A⋅A⊥ = -A⊥⋅A Swapping operands changes the sign of the perp dot product

testPerpDotProductZero() public method

Axiom: A⊥⋅A = 0 Perp dot product with itself will be zero.

testPerpendicularDotProduct() public method

Axiom: A⋅A⊥ = 0 Vector dot product with a vector perpendicular to it will be zero.

testProjPerpDotProductEqualsZero() public method

Axiom: projᵇA ⋅ perpᵇA = 0 Dot product of proj and perp of A on B is 0

testProjPerpPerpDotProductEqualsProductOfLengths() public method

Axiom: |projᵇA⊥ ⋅ perpᵇA| = |projᵇA| |perpᵇA| Absolute value of proj and perp dot product equals product of their lengths.

testProjPerpSumEqualsA() public method

Axiom: projᵇA + perpᵇA = A Sum of the proj and perp of A on B equals A
public testProjPerpSumEqualsA ( array $A, array $B )
$A array
$B array

testProjPerpSumOfSquares() public method

Axiom: |projᵇA|² + |perpᵇA|² = |A|² Sum of squared lengths of proj and perp equals squared length of A
public testProjPerpSumOfSquares ( array $A, array $B )
$A array
$B array

testReverseCrossProduct() public method

Axiom: A x B = -(B x A) Anticommutivity: Reverse order cross product results in a negative cross product
public testReverseCrossProduct ( array $A, array $B )
$A array
$B array

testScalarMultiplyNegativeOneIdentity() public method

Axiom: -1A = -A Additive inverse

testScalarMultiplyOneIdentity() public method

Axiom: 1A = A Multiplying (scaling) by 1 does not change the vector

testScalarMultiplyZeroIdentity() public method

Axiom: 0A = 0 Multiplying (scaling) by 0 gives the zero vector