File tree Expand file tree Collapse file tree 1 file changed +23
-22
lines changed
Expand file tree Collapse file tree 1 file changed +23
-22
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,29 @@ public function get($row, $column)
187187 return $ this ->internal [$ row ][$ column ];
188188 }
189189
190+ /**
191+ * identity
192+ *
193+ * Creates a new identity matrix of the specified size.
194+ *
195+ * @param int $size How many rows and columns the identity matrix should have
196+ * @return self
197+ */
198+ public static function identity ($ size )
199+ {
200+ $ literal = array ();
201+
202+ for ($ i = 0 ; $ i < $ size ; ++$ i ) {
203+ $ literal [] = array ();
204+
205+ for ($ j = 0 ; $ j < $ size ; ++$ j ) {
206+ $ literal [$ i ][] = ($ i == $ j ) ? 1 : 0 ;
207+ }
208+ }
209+
210+ return new static ($ literal );
211+ }
212+
190213 /**
191214 * inverse
192215 *
@@ -252,28 +275,6 @@ public function isSymmetric()
252275
253276 return true ;
254277 }
255-
256- /**
257- * identity
258- *
259- * @param int $size How many rows and columns the identity matrix should have
260- * @return self
261- * @static
262- */
263- public static function identity ($ size )
264- {
265- $ literal = array ();
266-
267- for ($ i = 0 ; $ i < $ size ; ++$ i ) {
268- $ literal [] = array ();
269-
270- for ($ j = 0 ; $ j < $ size ; ++$ j ) {
271- $ literal [$ i ][] = ($ i == $ j ) ? 1 : 0 ;
272- }
273- }
274-
275- return new static ($ literal );
276- }
277278
278279 /**
279280 * map
You can’t perform that action at this time.
0 commit comments