dot -package:blas-ffi

Lexeme parser dot parses the character '.' and skips any trailing white space. Returns the string ".".
>>> dot

Compose two strategies sequentially. This is the analogue to function composition on strategies. For any strategies strat1, strat2, and strat3,
(strat1 `dot` strat2) `dot` strat3 == strat1 `dot` (strat2 `dot` strat3)
strat1 `dot` strat1 = strat1
strat1 `dot` r0 == strat1
strat2 `dot` strat1 == strat2 . withStrategy strat1
Compute the inner product of two vectors or (equivalently) convert a vector f a into a covector f a -> a.
>>> V2 1 2 `dot` V2 3 4
11
Token parser dot parses the character '.' and skips any trailing white space. Returns the string ".".
The document dot contains a single dot, ".".
Synonym for anyChar
The document dot contains a single dot, ".".
Add a dot accent above a symbol, as used to denote a derivative, like <math>.
The document dot consists of a period, ".".
forVector2 number_ $ \xs ys ->
Vector.dot xs ys
==
Matrix.multiply (Matrix.singleRow xs) (Matrix.singleColumn ys) ! ((),())
QC.forAll (QC.choose (1,100)) $ \dim ->
QC.forAll (QC.choose (0, dim-1)) $ \i ->
QC.forAll (QC.choose (0, dim-1)) $ \j ->
Vector.dot
(Vector.unit (shapeInt dim) i)
(Vector.unit (shapeInt dim) j)
==
(fromIntegral (fromEnum (i==j)) :: Number_)
Dot product (also known as scalar or inner product). For two vectors, mathematically represented as a = a1,a2,...,an and b = b1,b2,...,bn, the dot product is a . b = a1*b1 + a2*b2 + ... + an*bn. Some properties are derived from this. The dot product of a vector with itself is the square of its magnitude (norm), and the dot product of two orthogonal vectors is zero.
Dot product of two points 'dot (x :+ y) (a :+ b) == x * a + y * b' 'dot z w == magnitude z * magnitude w * cos (phase z - phase w)'
The document dot contains a single dot, ".".
Print a dot
A generalisation of a dot operation, which is a multiplicative expansion of two arrays and sum contraction along the middle two dimensions. matrix multiplication
>>> pretty $ dot sum (*) m (transpose m)
[[5,14],
[14,50]]
inner product
>>> pretty $ dot sum (*) v v
5
matrix-vector multiplication Note that an Array with shape [3] is neither a row vector nor column vector.
>>> pretty $ dot sum (*) v (transpose m)
[5,14]
>>> pretty $ dot sum (*) m v
[5,14]
A generalisation of a dot operation, which is a multiplicative expansion of two arrays and sum contraction along the middle two dimensions. matrix multiplication
>>> pretty $ dot sum (*) m (transpose m)
[[5,14],
[14,50]]
inner product
>>> pretty $ dot sum (*) v v
5
matrix-vector multiplication Note that an Array with shape [3] is neither a row vector nor column vector.
>>> pretty $ dot sum (*) v (transpose m)
[5,14]
>>> pretty $ dot sum (*) m v
[5,14]
A generalisation of a dot operation, which is a multiplicative expansion of two arrays and sum contraction along the middle two dimensions. matrix multiplication
>>> let b = fromFlatList [2,3] [1..6] :: Array Int

>>> dot sum (*) b (transpose b)
[[14, 32],
[32, 77]]
inner product
>>> let v = fromFlatList [3] [1..3] :: Array Int

>>> dot sum (*) v v
14
matrix-vector multiplication Note that an `Array Int` with shape [3] is neither a row vector nor column vector. dot is not turning the vector into a matrix and then using matrix multiplication.
>>> dot sum (*) v b
[9, 12, 15]
>>> dot sum (*) b v
[14, 32]
A generalisation of a dot operation, which is a multiplicative expansion of two arrays and sum contraction along the middle two dimensions. matrix multiplication
>>> let b = [1..6] :: Array '[2,3] Int

>>> dot sum (*) b (transpose b)
[[14, 32],
[32, 77]]
inner product
>>> let v = [1..3] :: Array '[3] Int

>>> :t dot sum (*) v v
dot sum (*) v v :: Array '[] Int
>>> dot sum (*) v v
14
matrix-vector multiplication (Note how the vector doesn't need to be converted to a row or column vector)
>>> dot sum (*) v b
[9, 12, 15]
>>> dot sum (*) b v
[14, 32]
Array elements don't have to be numbers:
>>> x1 = (show <$> [1..4]) :: Array '[2,2] String

>>> x2 = (show <$> [5..8]) :: Array '[2,2] String

>>> x1
[["1", "2"],
["3", "4"]]
>>> x2
[["5", "6"],
["7", "8"]]
>>> import Data.List (intercalate)

>>> dot (intercalate "+" . toList) (\a b -> a <> "*" <> b) x1 x2
[["1*5+2*7", "1*6+2*8"],
["3*5+4*7", "3*6+4*8"]]
dot allows operation on mis-shaped matrices. The algorithm ignores excess positions within the contracting dimension(s):
>>> let m23 = [1..6] :: Array '[2,3] Int

>>> let m12 = [1,2] :: Array '[1,2] Int

>>> shape $ dot sum (*) m23 m12
[2,2]
Find instances of a vector in a matrix
>>> let cs = fromList ("abacbaab" :: [Char]) :: Array '[4,2] Char

>>> let v = fromList ("ab" :: [Char]) :: Vector 2 Char

>>> dot (all id) (==) cs v
[True, False, False, True]