HMath.Linear¶
Module index · Numerical conventions
On this page¶
| API | Purpose |
|---|---|
| dot | Inner product. |
| dotChecked | Inner product, or VectorLengthMismatch with the left and right lengths. |
| magnitude | Euclidean magnitude. |
| normalize | Normalize by Euclidean magnitude. |
| add | Elementwise addition. |
| addChecked | Elementwise addition, requiring equal lengths. |
| subtractChecked | Elementwise left-minus-right subtraction, requiring equal lengths. |
| scale | Multiply every component by a scalar, preserving length. |
Documentation
dot
dot :: Num a => [a] -> [a] -> a Source #
Inner product. Empty vectors have inner product zero.
Unequal lengths raise an exception; use dotChecked to handle that input.
dotChecked
dotChecked :: Num a => [a] -> [a] -> Either MathError a Source #
Inner product, or VectorLengthMismatch with the left and right lengths.
magnitude
magnitude :: Floating a => [a] -> a Source #
Euclidean magnitude. The empty vector has magnitude zero.
normalize
normalize :: (Eq a, Floating a) => [a] -> [a] Source #
Normalize by Euclidean magnitude. A vector whose computed magnitude is zero is returned unchanged, including the empty vector. Floating-point overflow and non-finite values retain the underlying type's behavior.
add
add :: Num a => [a] -> [a] -> [a] Source #
Elementwise addition. Unequal lengths raise an exception; use addChecked
to handle that input.
addChecked
addChecked :: Num a => [a] -> [a] -> Either MathError [a] Source #
Elementwise addition, requiring equal lengths. Two empty lists succeed.