| 
									
										
										
										
											2012-11-15 01:42:45 -05:00
										 |  |  | ! Copyright (C) 2012 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2017-07-22 19:49:04 -04:00
										 |  |  | USING: accessors arrays.shaped kernel math sequences tools.test ;
 | 
					
						
							| 
									
										
										
										
											2012-11-15 01:42:45 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { t } [ | 
					
						
							| 
									
										
										
										
											2012-11-15 01:42:45 -05:00
										 |  |  |     { 5 5 } increasing | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         { 0 1 2 3 4 } | 
					
						
							|  |  |  |         { 5 6 7 8 9 } | 
					
						
							|  |  |  |         { 10 11 12 13 14 } | 
					
						
							|  |  |  |         { 15 16 17 18 19 } | 
					
						
							|  |  |  |         { 20 21 22 23 24 } | 
					
						
							|  |  |  |     } >shaped-array =
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { { 5 5 } } [ | 
					
						
							| 
									
										
										
										
											2012-11-15 01:42:45 -05:00
										 |  |  |     { | 
					
						
							|  |  |  |         { 0 1 2 3 4 } | 
					
						
							|  |  |  |         { 5 6 7 8 9 } | 
					
						
							|  |  |  |         { 10 11 12 13 14 } | 
					
						
							|  |  |  |         { 15 16 17 18 19 } | 
					
						
							|  |  |  |         { 20 21 22 23 24 } | 
					
						
							|  |  |  |     } >shaped-array shape>> | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { { 5 5 } } [ | 
					
						
							| 
									
										
										
										
											2012-11-15 01:42:45 -05:00
										 |  |  |     { | 
					
						
							|  |  |  |         { 0 1 2 3 4 } | 
					
						
							|  |  |  |         { 5 6 7 8 9 } | 
					
						
							|  |  |  |         { 10 11 12 13 14 } | 
					
						
							|  |  |  |         { 15 16 17 18 19 } | 
					
						
							|  |  |  |         { 20 21 22 23 24 } | 
					
						
							|  |  |  |     } >shaped-array shape | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2013-04-11 18:29:09 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | { sa{ 1 } } [ { } ones ] unit-test | 
					
						
							|  |  |  | { sa{ 1 } } [ { 1 } ones ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { sa{ 0 } } [ { } zeros ] unit-test | 
					
						
							|  |  |  | { sa{ 0 } } [ { 1 } zeros ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Error on 0, negative shapes | 
					
						
							| 
									
										
										
										
											2013-07-24 13:03:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-07-24 13:03:06 -04:00
										 |  |  |     sa{ { 1 3 3 } { 4 1 3 } { 4 4 1 } } | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | } [ | 
					
						
							| 
									
										
										
										
											2013-07-24 13:03:06 -04:00
										 |  |  |     { 3 3 } 2 strict-lower | 
					
						
							|  |  |  |     [ drop 3 ] map-strict-upper | 
					
						
							|  |  |  |     [ drop 1 ] map-diagonal | 
					
						
							|  |  |  |     [ sq ] map-strict-lower | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2017-07-22 19:49:04 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-05 21:41:19 -04:00
										 |  |  | { } [ 15 <iota> { 3 5 1 } reshape drop ] unit-test |