fifth-postulate/gaussian-elimination/1.0.0

Algebra.Vector

This module provides a Vector type.

Type

type Vector a

The Vector type

This type is parameterized over its elements.

Construction

fromList : List a -> Vector a

Create a Vector from a list of elements

zero : Field a -> Int -> Vector a

Create the zero Vector in a certain dimension.

It uses the zero element of the field.

Inspection

dimension : Vector a -> Int

Returns the number of coordinates in the given Vector.

index : Int -> Vector a -> Maybe a

Return the i-th component of a Vector, if it exists.

Nohting otherwise.

Operation

add : Field a -> Vector a -> Vector a -> Vector a

Add two vectors component-wise.

dot : Field a -> Vector a -> Vector a -> a

The inner-product of two vectors.

The dimension of the result is equal to the smallest dimension of the arguments.

scale : Field a -> a -> Vector a -> Vector a

Scalar multilication

subtract : Field a -> Vector a -> Vector a -> Vector a

Subtract two vectors.

This is a convenience method. It could be implemented with field negation and the add function.

Deconstruction

toList : Vector a -> List a

Return the coordinates of the vector.