@@ -33,7 +33,6 @@ public function toArray(): array
3333 }
3434
3535 /**
36- * Get item count
3736 * @return int number of items
3837 */
3938 public function getSize (): int
@@ -42,36 +41,30 @@ public function getSize(): int
4241 }
4342
4443 /**
45- * Sum of all elements
46- *
47- * @return number
44+ * @return float
4845 */
49- public function sum ()
46+ public function sum (): float
5047 {
5148 return array_sum ($ this ->toArray ());
5249 }
5350
5451 /**
55- * Vector length (magnitude)
56- * Same as l2-norm
57- *
58- * @return number
52+ * @return float
5953 */
60- public function length ()
54+ public function length (): float
6155 {
6256 return $ this ->l2norm ();
6357 }
6458
6559 /**
66- *
6760 * Dot product (inner product) (A⋅B)
6861 * https://en.wikipedia.org/wiki/Dot_product
6962 *
7063 * @param self $other
71- * @return number
64+ * @return float
7265 * @throws VectorException
7366 */
74- public function dotProduct (self $ other )
67+ public function dotProduct (self $ other ): float
7568 {
7669 if ($ other ->getSize () !== $ this ->getSize ()) {
7770 throw new VectorException ('Vectors have to have same size ' );
@@ -90,10 +83,9 @@ function ($a, $b) {
9083 * Inner product (convience method for dot product) (A⋅B)
9184 *
9285 * @param Vector $other
93- *
94- * @return number
86+ * @return float
9587 */
96- public function innerProduct (Vector $ other )
88+ public function innerProduct (Vector $ other ): float
9789 {
9890 return $ this ->dotProduct ($ other );
9991 }
@@ -111,7 +103,6 @@ public function innerProduct(Vector $other)
111103 *
112104 *
113105 * @param Vector $other
114- *
115106 * @return Matrix
116107 */
117108 public function outerProduct (Vector $ other ): Matrix
@@ -196,9 +187,9 @@ public function projection(self $other): self
196187 *
197188 * |x|₁ = ∑|xᵢ|
198189 *
199- * @return number
190+ * @return float
200191 */
201- public function l1Norm ()
192+ public function l1Norm (): float
202193 {
203194 $ sum = 0 ;
204195
0 commit comments