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
Afficher le fichier Open project: markrogoyski/math-php

Méthodes publiques

Méthode 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 méthode

dataProviderForCrossProduct() public méthode

dataProviderForCrossProductThreeVectors() public méthode

dataProviderForDotProductZero() public méthode

dataProviderForOuterProduct() public méthode

dataProviderForPerpendicularIdentity() public méthode

dataProviderForProjPerp() public méthode

dataProviderForSingleVector() public méthode

dataProviderForTwoVectors() public méthode

testAdditivityInTheScalarForScalarMultiplication() public méthode

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

testAdditivityInTheVectorForScalarMultiplication() public méthode

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

testCrossProductDistributivity() public méthode

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

testCrossProductInnerProductWithEitherVectorIsZero() public méthode

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 méthode

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

testCrossProductPropertyOfZero() public méthode

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

testCrossProductVolumeProperty() public méthode

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

testDotProductCommutative() public méthode

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

testDotProductZero() public méthode

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 méthode

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 méthode

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 méthode

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 méthode

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

testPerpDotProdcutSwapOperandsChangeSign() public méthode

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

testPerpDotProductZero() public méthode

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

testPerpendicularDotProduct() public méthode

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

testProjPerpDotProductEqualsZero() public méthode

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

testProjPerpPerpDotProductEqualsProductOfLengths() public méthode

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

testProjPerpSumEqualsA() public méthode

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 méthode

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 méthode

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 méthode

Axiom: -1A = -A Additive inverse

testScalarMultiplyOneIdentity() public méthode

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

testScalarMultiplyZeroIdentity() public méthode

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