1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/// Trait for the dot product operation.
///
/// The [dot product](https://en.wikipedia.org/wiki/Dot_product) is the sum of the element-wise products of two vectors.
///
/// The `dot` method is only defined for [`Vector`](crate::vector::Vector) and [`RowVector`](crate::row_vector::RowVector).
/// However, the `dot` method accepts as an argument a [`Matrix`](crate::matrix::Matrix) or any of its views,
/// as long it represents a column or row vector respectively. That is, to `dot` with a [`Vector`](crate::vector::Vector)
/// of length `n`, the rhs must be a [`Matrix`](crate::matrix::Matrix) of shape `(n, 1)`.
/// Similarly for [`RowVector`](crate::row_vector::RowVector).
///
/// # Example
///
/// This example shows some of the possible dot product combinations.
///
/// ```
/// use ferrix::DotProduct;
/// use ferrix::{Vector, RowVector, Matrix};
///
/// // Dot product of two vectors
/// let a = Vector::from([1, 2, 3]);
/// let b = Vector::from([4, 5, 6]);
/// assert_eq!(a.dot(b), 32);
///
/// // Alternatively
/// let a = Vector::from([1, 2, 3]);
/// let b = Matrix::from([[4], [5], [6]]);
/// assert_eq!(a.dot(b), 32);
///
/// // Dot product of two row vectors
/// let a = RowVector::from([1, 2, 3]);
/// let b = RowVector::from([4, 5, 6]);
/// assert_eq!(a.dot(b), 32);
///
/// // Similarly
/// let a = RowVector::from([1, 2, 3]);
/// let b = Matrix::from([[4, 5, 6]]);
/// assert_eq!(a.dot(b), 32);
/// ```
/// Trait for integer random number generation.
///
/// Generates a [`Vector`](crate::vector::Vector), [`RowVector`](crate::row_vector::RowVector), or [`Matrix`](crate::matrix::Matrix)
/// filled with random integers uniformly across all values of the integer type.
///
/// # Example
///
/// ```
/// use ferrix::IntRandom;
/// use ferrix::Vector;
///
/// let a = Vector::<i32, 3>::random();
/// ```
/// Trait for floating-point random number generation.
///
/// Generates a [`Vector`](crate::vector::Vector), [`RowVector`](crate::row_vector::RowVector), or [`Matrix`](crate::matrix::Matrix)
/// filled with random floating-point numbers uniformly in the range `[-1, 1]`.
///
/// # Example
///
/// ```
/// use ferrix::FloatRandom;
/// use ferrix::Vector;
///
/// let a = Vector::<f32, 3>::random();
/// ```