m^n binary exponentiation of matrices
							parent
							
								
									b73716d8cb
								
							
						
					
					
						commit
						1c89045f0e
					
				|  | @ -1,7 +1,7 @@ | ||||||
| ! Copyright (C) 2005, 2009 Slava Pestov. | ! Copyright (C) 2005, 2009 Slava Pestov. | ||||||
| ! See http://factorcode.org/license.txt for BSD license. | ! See http://factorcode.org/license.txt for BSD license. | ||||||
| USING: arrays kernel math math.order math.vectors | USING: accessors arrays columns kernel math math.bits | ||||||
| sequences sequences.private accessors columns ; | math.order math.vectors sequences sequences.private ; | ||||||
| IN: math.matrices | IN: math.matrices | ||||||
| 
 | 
 | ||||||
| ! Matrices | ! Matrices | ||||||
|  | @ -61,3 +61,8 @@ PRIVATE> | ||||||
| 
 | 
 | ||||||
| : cross-zip ( seq1 seq2 -- seq1xseq2 ) | : cross-zip ( seq1 seq2 -- seq1xseq2 ) | ||||||
|     [ [ 2array ] with map ] curry map ; |     [ [ 2array ] with map ] curry map ; | ||||||
|  |      | ||||||
|  | : m^n ( m n -- n )  | ||||||
|  |     make-bits over first length identity-matrix | ||||||
|  |     [ [ dupd m. ] when [ dup m. ] dip ] reduce nip ; | ||||||
|  | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue