elixir_linear_algebra v1.0.0 ELA.Vector

Contains operations for working with vectors.

Summary

Functions

Performs elementwise addition

Calculates the cross product. Is only defined for vectors with size three

Calculates the dot product. Multiplying empty vectors return 0

Performs elementwise multiplication between two vectors. This is the Hadmard product, but for vectors

Returns a vector with zeroes with provided dimension

Calculates the euclidian norm of a vector

Elementwise multiplication with a scalar

Performs elementwise subtraction

Transponates the vector. Column vectors are two-dimensional

Functions

add(u, v)
add([number], [number]) :: [number]

Performs elementwise addition.

Examples

iex> Vector.add([1, 2, 1], [2, 2, 2])
[3, 4, 3]
cross(u, v)
cross([number], [number]) :: [number]

Calculates the cross product. Is only defined for vectors with size three.

Examples

iex> Vector.cross([1, 2, 1], [2, 2, 2])
[2, 0, -2]
dot(u, v)
dot([number], [number]) :: number

Calculates the dot product. Multiplying empty vectors return 0.

Examples

iex> Vector.dot([1, 2, 1], [2, 2, 2])
8
hadmard(u, v)
hadmard([number], [number]) :: [number]

Performs elementwise multiplication between two vectors. This is the Hadmard product, but for vectors.

Examples

iax> Vector.hadmard([1, 2], [2, 2])
[2, 4]
new(n)
new(number) :: [number]

Returns a vector with zeroes with provided dimension.

Examples

iex> Vector.new(3)
[0, 0, 0]
norm(v)
norm([number]) :: number

Calculates the euclidian norm of a vector.

Examples

iex> Vector.norm([3, 4])
0.5
scalar(v, s)
scalar([number], number) :: [number]

Elementwise multiplication with a scalar.

Examples

iex> Vector.scalar([2, 2, 2], 2)
[4, 4, 4]
sub(u, v)
sub([number], [number]) :: [number]
sub([number], [number]) :: [number]

Performs elementwise subtraction.

Examples

iex> Vector.sub([1, 2, 1], [2, 2, 2])
[-1, 0, -1]
transp(v)

Transponates the vector. Column vectors are two-dimensional.

Examples

iex> Vector.transp([1, 1, 1])
[[1],
[1],
[1]]