Method |
Description |
|
__construct ( array $A ) |
Constructor |
|
__toString ( ) : string |
Print the vector as a string
Ex:
[1, 2, 3] |
|
add ( Vector $B ) : Vector |
Add (A + B) |
|
asColumnMatrix ( ) : Matrix |
Get the vector as an nx1 column matrix |
|
asRowMatrix ( ) : Matrix |
Get the vector as a 1xn row matrix |
|
count ( ) : integer |
************************************************************************
Countable INTERFACE
************************************************************************ |
|
crossProduct ( Vector $B ) : Vector |
Cross product (AxB)
https://en.wikipedia.org/wiki/Cross_product |
|
directProduct ( Vector $B ) : Matrix |
Direct product (dyadic) |
|
dotProduct ( Vector $B ) : number |
Dot product (inner product) (A⋅B)
https://en.wikipedia.org/wiki/Dot_product |
|
get ( integer $i ) : number |
Get a specific value at position i |
|
getN ( ) : integer |
Get item count (n) |
|
getVector ( ) : array |
Get matrix |
|
innerProduct ( Vector $B ) : number |
Inner product (convience method for dot product) (A⋅B) |
|
jsonSerialize ( ) |
************************************************************************
JsonSerializable INTERFACE
************************************************************************ |
|
l1Norm ( ) : number |
l₁-norm (|x|₁)
Also known as Taxicab norm or Manhattan norm |
|
l2Norm ( ) : number |
l²-norm (|x|₂)
Also known as Euclidean norm, Euclidean length, L² distance, ℓ² distance
Used to normalize a vector. |
|
length ( ) : number |
Vector length (magnitude)
Same as l2-norm |
|
maxNorm ( ) : number |
Max norm (infinity norm) (|x|∞) |
|
normalize ( ) : Vector |
Normalize (Â)
The normalized vector  is a vector in the same direction of A
but with a norm (length) of 1. It is a unit vector. |
|
offsetExists ( $i ) : boolean |
************************************************************************
ArrayAccess INTERFACE
************************************************************************ |
|
offsetGet ( $i ) |
|
|
offsetSet ( $i, $value ) |
|
|
offsetUnset ( $i ) |
|
|
outerProduct ( Vector $B ) : Matrix |
Outer product (A⨂B)
https://en.wikipedia.org/wiki/Outer_product |
|
pNorm ( $p ) : number |
p-norm (|x|p)
Also known as lp norm |
|
perp ( Vector $B ) : Vector |
Perpendicular of A on B
https://en.wikipedia.org/wiki/Vector_projection#Vector_projection |
|
perpDotProduct ( Vector $B ) : number |
Perp dot product (A⊥⋅B)
A modification of the two-dimensional dot product in which A is
replaced by the perpendicular vector rotated 90º degrees. |
|
perpendicular ( ) : Vector |
Perpendicular (A⊥)
A vector perpendicular to A (A-perp) with the length that is rotated 90º
counter clockwise. |
|
projection ( Vector $B ) : Vector |
Projection of A onto B
https://en.wikipedia.org/wiki/Vector_projection#Vector_projection |
|
scalarDivide ( number $k ) : Vector |
Scalar divide
kA = [k / a₁, k / a₂, k / a₃ . |
|
scalarMultiply ( number $k ) : Vector |
Scalar multiplication (scale)
kA = [k * a₁, k * a₂, k * a₃ . |
|
subtract ( Vector $B ) : Vector |
Subtract (A - B) |
|
sum ( ) : number |
Sum of all elements |
|