@@ -1068,6 +1068,39 @@ mod blas_tests
10681068 }
10691069}
10701070
1071+ /// Dot product for dynamic-dimensional arrays (`ArrayD`).
1072+ ///
1073+ /// For one-dimensional arrays, computes the vector dot product, which is the sum
1074+ /// of the elementwise products (no conjugation of complex operands).
1075+ /// Both arrays must have the same length.
1076+ ///
1077+ /// For two-dimensional arrays, performs matrix multiplication. The array shapes
1078+ /// must be compatible in the following ways:
1079+ /// - If `self` is *M* × *N*, then `rhs` must be *N* × *K* for matrix-matrix multiplication
1080+ /// - If `self` is *M* × *N* and `rhs` is *N*, returns a vector of length *M*
1081+ /// - If `self` is *M* and `rhs` is *M* × *N*, returns a vector of length *N*
1082+ /// - If both arrays are one-dimensional of length *N*, returns a scalar
1083+ ///
1084+ /// **Panics** if:
1085+ /// - The arrays have dimensions other than 1 or 2
1086+ /// - The array shapes are incompatible for the operation
1087+ /// - For vector dot product: the vectors have different lengths
1088+ ///
1089+ /// # Examples
1090+ ///
1091+ /// ```
1092+ /// use ndarray::{ArrayD, Array2, Array1};
1093+ ///
1094+ /// // Matrix multiplication
1095+ /// let a = ArrayD::from_shape_vec(vec![2, 3], vec![1., 2., 3., 4., 5., 6.]).unwrap();
1096+ /// let b = ArrayD::from_shape_vec(vec![3, 2], vec![1., 2., 3., 4., 5., 6.]).unwrap();
1097+ /// let c = a.dot(&b);
1098+ ///
1099+ /// // Vector dot product
1100+ /// let v1 = ArrayD::from_shape_vec(vec![3], vec![1., 2., 3.]).unwrap();
1101+ /// let v2 = ArrayD::from_shape_vec(vec![3], vec![4., 5., 6.]).unwrap();
1102+ /// let scalar = v1.dot(&v2);
1103+ /// ```
10711104impl < A , S , S2 > Dot < ArrayBase < S2 , IxDyn > > for ArrayBase < S , IxDyn >
10721105where
10731106 S : Data < Elem = A > ,
0 commit comments