@@ -33,7 +33,7 @@ public function toArray(): array
3333 }
3434
3535 /**
36- * @return int number of items
36+ * @return int
3737 */
3838 public function getSize (): int
3939 {
@@ -57,12 +57,10 @@ public function length(): float
5757 }
5858
5959 /**
60- * Dot product (inner product) (A⋅B)
61- * https://en.wikipedia.org/wiki/Dot_product
62- *
6360 * @param self $other
6461 * @return float
6562 * @throws VectorException
63+ * @link https://en.wikipedia.org/wiki/Dot_product
6664 */
6765 public function dotProduct (self $ other ): float
6866 {
@@ -80,8 +78,6 @@ function (float $a, float $b) {
8078 }
8179
8280 /**
83- * Inner product (convience method for dot product) (A⋅B)
84- *
8581 * @param Vector $other
8682 * @return float
8783 */
@@ -91,19 +87,14 @@ public function innerProduct(Vector $other): float
9187 }
9288
9389 /**
94- * Outer product (A⨂B)
95- * https://en.wikipedia.org/wiki/Outer_product
96- * Same as direct product.
97- *
98- *
99- *
10090 * | a₀ | | a₀b₀ a₀b₁ a₀b₂ |
10191 * A ⨂ B = | a₁ | ⨂ |b₀ b₁b₂| = | a₁b₀ a₁b₁ a₁b₂|
10292 * | a₂ | | a₂b₀ a₂b₁ a₂b₂|
10393 *
10494 *
10595 * @param Vector $other
10696 * @return Matrix
97+ * @link https://en.wikipedia.org/wiki/Outer_product
10798 */
10899 public function outerProduct (Vector $ other ): Matrix
109100 {
@@ -118,16 +109,10 @@ public function outerProduct(Vector $other): Matrix
118109 }
119110
120111 /**
121- *
122- * Cross product (AxB)
123- * https://en.wikipedia.org/wiki/Cross_product
124- *
125- *
126- * A X B = (a₁b₂ - b₁a₂) - (a₀b₂ - b₀a₂) + (a₀b₁ - b₀a₁)
127- *
128112 * @param Vector $other
129113 * @return self
130114 * @throws VectorException
115+ * @link https://en.wikipedia.org/wiki/Cross_product
131116 */
132117 public function crossProduct (Vector $ other ): self
133118 {
@@ -143,49 +128,41 @@ public function crossProduct(Vector $other): self
143128 }
144129
145130 /**
146- * Normalize (Â)
147131 * The normalized vector  is a vector in the same direction of A
148132 * but with a norm (length) of 1. It is a unit vector.
149- * http://mathworld.wolfram.com/NormalizedVector.html
150133 *
151134 * A
152135 * Â ≡ ---
153136 * |A|
154137 *
155138 * where |A| is the l²-norm (|A|₂)
156139 *
140+ * @link http://mathworld.wolfram.com/NormalizedVector.html
157141 */
158142 public function normalize (): self
159143 {
160144 return self ::fromMatrix ($ this ->divideScalar ($ this ->l2norm ()));
161145 }
162146
163147 /**
164- * Projection of A onto B
165- * https://en.wikipedia.org/wiki/Vector_projection#Vector_projection
166- *
167148 * A⋅B
168149 * projᵇA = --- B
169150 * |B|²
170151 *
171152 * @param self $other
172- *
173153 * @return self
154+ * @link https://en.wikipedia.org/wiki/Vector_projection#Vector_projection
174155 */
175156 public function projection (self $ other ): self
176157 {
177158 return self ::fromMatrix ($ other ->multiplyScalar ($ this ->dotProduct ($ other ) / ($ other ->l2norm () ** 2 )));
178159 }
179160
180161 /**
181- * l₁-norm (|x|₁)
182- * Also known as Taxicab norm or Manhattan norm
183- *
184- * https://en.wikipedia.org/wiki/Norm_(mathematics)#Taxicab_norm_or_Manhattan_norm
185- *
186162 * |x|₁ = ∑|xᵢ|
187163 *
188164 * @return float
165+ * @link https://en.wikipedia.org/wiki/Norm_(mathematics)#Taxicab_norm_or_Manhattan_norm
189166 */
190167 public function l1Norm (): float
191168 {
@@ -195,16 +172,15 @@ public function l1Norm(): float
195172 }
196173
197174 /**
198- * l²-norm (|x|₂)
199- * Also known as Euclidean norm, Euclidean length, L² distance, ℓ² distance
200- * Used to normalize a vector.
201- *
202- * http://mathworld.wolfram.com/L2-Norm.html
203- * https://en.wikipedia.org/wiki/Norm_(mathematics)#Euclidean_norm
204175 * ______
205176 * |x|₂ = √∑|xᵢ|²
206177 *
178+ * Also known as Euclidean norm, Euclidean length, L² distance, ℓ² distance
179+ * Used to normalize a vector.
180+ *
207181 * @return float
182+ * @link http://mathworld.wolfram.com/L2-Norm.html
183+ * @link https://en.wikipedia.org/wiki/Norm_(mathematics)#Euclidean_norm
208184 */
209185 public function l2Norm (): float
210186 {
@@ -214,10 +190,10 @@ public function l2Norm(): float
214190 }
215191
216192 /**
217- * Max norm (infinity norm) (|x|∞)
218- *
219193 * |x|∞ = max |x|
220194 *
195+ * Max norm (infinity norm) (|x|∞)
196+ *
221197 * @return float
222198 */
223199 public function maxNorm (): float
0 commit comments