File: pl.array2d.html

package info (click to toggle)
lua-penlight 1.0.2%2Bhtmldoc-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,860 kB
  • sloc: makefile: 7
file content (815 lines) | stat: -rw-r--r-- 23,183 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Penlight Documentation</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Penlight</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>


<h2>Modules</h2>
<ul>
  <li><a href="../modules/pl.html">pl</a></li>
  <li><a href="../modules/pl.Date.html">pl.Date</a></li>
  <li><a href="../modules/pl.List.html">pl.List</a></li>
  <li><a href="../modules/pl.Map.html">pl.Map</a></li>
  <li><a href="../modules/pl.MultiMap.html">pl.MultiMap</a></li>
  <li><a href="../modules/pl.OrderedMap.html">pl.OrderedMap</a></li>
  <li><a href="../modules/pl.Set.html">pl.Set</a></li>
  <li><a href="../modules/pl.app.html">pl.app</a></li>
  <li><strong>pl.array2d</strong></li>
  <li><a href="../modules/pl.class.html">pl.class</a></li>
  <li><a href="../modules/pl.comprehension.html">pl.comprehension</a></li>
  <li><a href="../modules/pl.config.html">pl.config</a></li>
  <li><a href="../modules/pl.data.html">pl.data</a></li>
  <li><a href="../modules/pl.dir.html">pl.dir</a></li>
  <li><a href="../modules/pl.file.html">pl.file</a></li>
  <li><a href="../modules/pl.func.html">pl.func</a></li>
  <li><a href="../modules/pl.input.html">pl.input</a></li>
  <li><a href="../modules/pl.lapp.html">pl.lapp</a></li>
  <li><a href="../modules/pl.lexer.html">pl.lexer</a></li>
  <li><a href="../modules/pl.luabalanced.html">pl.luabalanced</a></li>
  <li><a href="../modules/pl.operator.html">pl.operator</a></li>
  <li><a href="../modules/pl.path.html">pl.path</a></li>
  <li><a href="../modules/pl.permute.html">pl.permute</a></li>
  <li><a href="../modules/pl.pretty.html">pl.pretty</a></li>
  <li><a href="../modules/pl.seq.html">pl.seq</a></li>
  <li><a href="../modules/pl.sip.html">pl.sip</a></li>
  <li><a href="../modules/pl.strict.html">pl.strict</a></li>
  <li><a href="../modules/pl.stringio.html">pl.stringio</a></li>
  <li><a href="../modules/pl.stringx.html">pl.stringx</a></li>
  <li><a href="../modules/pl.tablex.html">pl.tablex</a></li>
  <li><a href="../modules/pl.template.html">pl.template</a></li>
  <li><a href="../modules/pl.test.html">pl.test</a></li>
  <li><a href="../modules/pl.text.html">pl.text</a></li>
  <li><a href="../modules/pl.utils.html">pl.utils</a></li>
  <li><a href="../modules/pl.xml.html">pl.xml</a></li>
</ul>
<h2>Topics</h2>
<ul>
  <li><a href="../topics/01-introduction.md.html">01-introduction.md</a></li>
  <li><a href="../topics/02-arrays.md.html">02-arrays.md</a></li>
  <li><a href="../topics/03-strings.md.html">03-strings.md</a></li>
  <li><a href="../topics/04-paths.md.html">04-paths.md</a></li>
  <li><a href="../topics/05-dates.md.html">05-dates.md</a></li>
  <li><a href="../topics/06-data.md.html">06-data.md</a></li>
  <li><a href="../topics/07-functional.md.html">07-functional.md</a></li>
  <li><a href="../topics/08-additional.md.html">08-additional.md</a></li>
  <li><a href="../topics/09-discussion.md.html">09-discussion.md</a></li>
</ul>
<h2>Examples</h2>
<ul>
  <li><a href="../examples/seesubst.lua.html">seesubst.lua</a></li>
  <li><a href="../examples/sipscan.lua.html">sipscan.lua</a></li>
  <li><a href="../examples/symbols.lua.html">symbols.lua</a></li>
  <li><a href="../examples/test-cmp.lua.html">test-cmp.lua</a></li>
  <li><a href="../examples/test-data.lua.html">test-data.lua</a></li>
  <li><a href="../examples/test-listcallbacks.lua.html">test-listcallbacks.lua</a></li>
  <li><a href="../examples/test-pretty.lua.html">test-pretty.lua</a></li>
  <li><a href="../examples/test-symbols.lua.html">test-symbols.lua</a></li>
  <li><a href="../examples/testapp.lua.html">testapp.lua</a></li>
  <li><a href="../examples/testclone.lua.html">testclone.lua</a></li>
  <li><a href="../examples/testconfig.lua.html">testconfig.lua</a></li>
  <li><a href="../examples/testglobal.lua.html">testglobal.lua</a></li>
  <li><a href="../examples/testinputfields.lua.html">testinputfields.lua</a></li>
  <li><a href="../examples/testinputfields2.lua.html">testinputfields2.lua</a></li>
  <li><a href="../examples/testxml.lua.html">testxml.lua</a></li>
  <li><a href="../examples/which.lua.html">which.lua</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>pl.array2d</code></h1>

<p>Operations on two-dimensional arrays.</p>
<p> See <a href="../topics/02-arrays.md.html#Operations_on_two_dimensional_tables">The Guide</a></p>

<p> Dependencies: <a href="../modules/pl.utils.html#">pl.utils</a> , <a href="../modules/pl.tablex.html#">pl.tablex</a> </p>

<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#size">size&nbsp;(t)</a></td>
	<td class="summary">return the row and column size.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#column">column&nbsp;(a, key)</a></td>
	<td class="summary">extract a column from the 2D array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#map">map&nbsp;(f, a, arg)</a></td>
	<td class="summary">map a function over a 2D array</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#reduce_rows">reduce_rows&nbsp;(f, a)</a></td>
	<td class="summary">reduce the rows using a function.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#reduce_cols">reduce_cols&nbsp;(f, a)</a></td>
	<td class="summary">reduce the columns using a function.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#reduce2">reduce2&nbsp;(opc, opr, a)</a></td>
	<td class="summary">reduce a 2D array into a scalar, using two operations.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#map2">map2&nbsp;(f, ad, bd, a, b, arg)</a></td>
	<td class="summary">map a function over two arrays.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#product">product&nbsp;(f, t1, t2)</a></td>
	<td class="summary">cartesian product of two 1d arrays.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#flatten">flatten&nbsp;(t)</a></td>
	<td class="summary">flatten a 2D array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#reshape">reshape&nbsp;(t, nrows, co)</a></td>
	<td class="summary">reshape a 2D array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#swap_rows">swap_rows&nbsp;(t, i1, i2)</a></td>
	<td class="summary">swap two rows of an array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#swap_cols">swap_cols&nbsp;(t, j1, j2)</a></td>
	<td class="summary">swap two columns of an array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#extract_rows">extract_rows&nbsp;(t, ridx)</a></td>
	<td class="summary">extract the specified rows.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#extract_cols">extract_cols&nbsp;(t, cidx)</a></td>
	<td class="summary">extract the specified columns.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#remove_row">remove_row&nbsp;(t, i)</a></td>
	<td class="summary">remove a row from an array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#remove_col">remove_col&nbsp;(t, j)</a></td>
	<td class="summary">remove a column from an array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#parse_range">parse_range&nbsp;(s)</a></td>
	<td class="summary">parse a spreadsheet range.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#range">range&nbsp;(t, rstr)</a></td>
	<td class="summary">get a slice of a 2D array using spreadsheet range notation.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#slice">slice&nbsp;(t, i1, j1, i2, j2)</a></td>
	<td class="summary">get a slice of a 2D array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#set">set&nbsp;(t, value, i1, j1, i2, j2)</a></td>
	<td class="summary">set a specified range of an array to a value.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#write">write&nbsp;(t, f, fmt, i1, j1, i2, j2)</a></td>
	<td class="summary">write a 2D array to a file.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#forall">forall&nbsp;(t, row_op, end_row_op, i1, j1, i2, j2)</a></td>
	<td class="summary">perform an operation for all values in a 2D array.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#move">move&nbsp;(dest, di, dj, src, i1, j1, i2, j2)</a></td>
	<td class="summary">move a block from the destination to the source.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#iter">iter&nbsp;(a, indices, i1, j1, i2, j2)</a></td>
	<td class="summary">iterate over all elements in a 2D array, with optional indices.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#columns">columns&nbsp;(a)</a></td>
	<td class="summary">iterate over all columns.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#new">new&nbsp;(rows, cols, val)</a></td>
	<td class="summary">new array of specified dimensions</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>
    
    <dl class="function">
    <dt>
    <a name = "size"></a>
    <strong>size&nbsp;(t)</strong>
    </dt>
    <dd>
    return the row and column size. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2d array</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        <li>number of rows</li>
        <li>number of cols</li>
    </ol>


</dd>
    <dt>
    <a name = "column"></a>
    <strong>column&nbsp;(a, key)</strong>
    </dt>
    <dd>
    extract a column from the 2D array. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>a</em></code>:  2d array</li>
       <li><code><em>key</em></code>:  an index or key</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        1d array
    </ol>


</dd>
    <dt>
    <a name = "map"></a>
    <strong>map&nbsp;(f, a, arg)</strong>
    </dt>
    <dd>
    map a function over a 2D array 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>f</em></code>:  a function of at least one argument</li>
       <li><code><em>a</em></code>:  2d array</li>
       <li><code><em>arg</em></code>:  an optional extra argument to be passed to the function.</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        2d array
    </ol>


</dd>
    <dt>
    <a name = "reduce_rows"></a>
    <strong>reduce_rows&nbsp;(f, a)</strong>
    </dt>
    <dd>
    reduce the rows using a function. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>f</em></code>:  a binary function</li>
       <li><code><em>a</em></code>:  2d array</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        1d array
    </ol>


    <h3>see also:</h3>
    <ul>
         <a href="../modules/pl.tablex.html#reduce">pl.tablex.reduce</a>
    </ul>
</dd>
    <dt>
    <a name = "reduce_cols"></a>
    <strong>reduce_cols&nbsp;(f, a)</strong>
    </dt>
    <dd>
    reduce the columns using a function. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>f</em></code>:  a binary function</li>
       <li><code><em>a</em></code>:  2d array</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        1d array
    </ol>


    <h3>see also:</h3>
    <ul>
         <a href="../modules/pl.tablex.html#reduce">pl.tablex.reduce</a>
    </ul>
</dd>
    <dt>
    <a name = "reduce2"></a>
    <strong>reduce2&nbsp;(opc, opr, a)</strong>
    </dt>
    <dd>
    reduce a 2D array into a scalar, using two operations. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>opc</em></code>:  operation to reduce the final result</li>
       <li><code><em>opr</em></code>:  operation to reduce the rows</li>
       <li><code><em>a</em></code>:  2D array</li>
    </ul>




</dd>
    <dt>
    <a name = "map2"></a>
    <strong>map2&nbsp;(f, ad, bd, a, b, arg)</strong>
    </dt>
    <dd>
    map a function over two arrays. 
 They can be both or either 2D arrays

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>f</em></code>:  function of at least two arguments</li>
       <li><code><em>ad</em></code>:  order of first array</li>
       <li><code><em>bd</em></code>:  order of second array</li>
       <li><code><em>a</em></code>:  1d or 2d array</li>
       <li><code><em>b</em></code>:  1d or 2d array</li>
       <li><code><em>arg</em></code>:  optional extra argument to pass to function</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        2D array, unless both arrays are 1D
    </ol>


</dd>
    <dt>
    <a name = "product"></a>
    <strong>product&nbsp;(f, t1, t2)</strong>
    </dt>
    <dd>
    cartesian product of two 1d arrays. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>f</em></code>:  a function of 2 arguments</li>
       <li><code><em>t1</em></code>:  a 1d table</li>
       <li><code><em>t2</em></code>:  a 1d table</li>
    </ul>

    <h3>Usage:</h3>
    <ul>
        <pre class="example">product('..',{1,2},{'a','b'}) == {{'1a','2a'},{'1b','2b'}}</pre>
    </ul>

    <h3>Returns:</h3>
    <ol>
        2d table
    </ol>


</dd>
    <dt>
    <a name = "flatten"></a>
    <strong>flatten&nbsp;(t)</strong>
    </dt>
    <dd>
    flatten a 2D array. 
 (this goes over columns first.)

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  2d table</li>
    </ul>

    <h3>Usage:</h3>
    <ul>
        <pre class="example">flatten {{1,2},{3,4},{5,6}} == {1,2,3,4,5,6}</pre>
    </ul>

    <h3>Returns:</h3>
    <ol>
        a 1d table
    </ol>


</dd>
    <dt>
    <a name = "reshape"></a>
    <strong>reshape&nbsp;(t, nrows, co)</strong>
    </dt>
    <dd>
    reshape a 2D array. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  2d array</li>
       <li><code><em>nrows</em></code>:  new number of rows</li>
       <li><code><em>co</em></code>:  column-order (Fortran-style) (default false)</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        a new 2d array
    </ol>


</dd>
    <dt>
    <a name = "swap_rows"></a>
    <strong>swap_rows&nbsp;(t, i1, i2)</strong>
    </dt>
    <dd>
    swap two rows of an array. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2d array</li>
       <li><code><em>i1</em></code>:  a row index</li>
       <li><code><em>i2</em></code>:  a row index</li>
    </ul>




</dd>
    <dt>
    <a name = "swap_cols"></a>
    <strong>swap_cols&nbsp;(t, j1, j2)</strong>
    </dt>
    <dd>
    swap two columns of an array. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2d array</li>
       <li><code><em>j1</em></code>:  a column index</li>
       <li><code><em>j2</em></code>:  a column index</li>
    </ul>




</dd>
    <dt>
    <a name = "extract_rows"></a>
    <strong>extract_rows&nbsp;(t, ridx)</strong>
    </dt>
    <dd>
    extract the specified rows. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  2d array</li>
       <li><code><em>ridx</em></code>:  a table of row indices</li>
    </ul>




</dd>
    <dt>
    <a name = "extract_cols"></a>
    <strong>extract_cols&nbsp;(t, cidx)</strong>
    </dt>
    <dd>
    extract the specified columns. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  2d array</li>
       <li><code><em>cidx</em></code>:  a table of column indices</li>
    </ul>




</dd>
    <dt>
    <a name = "remove_row"></a>
    <strong>remove_row&nbsp;(t, i)</strong>
    </dt>
    <dd>
    remove a row from an array. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2d array</li>
       <li><code><em>i</em></code>:  a row index</li>
    </ul>




</dd>
    <dt>
    <a name = "remove_col"></a>
    <strong>remove_col&nbsp;(t, j)</strong>
    </dt>
    <dd>
    remove a column from an array. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2d array</li>
       <li><code><em>j</em></code>:  a column index</li>
    </ul>




</dd>
    <dt>
    <a name = "parse_range"></a>
    <strong>parse_range&nbsp;(s)</strong>
    </dt>
    <dd>
    parse a spreadsheet range. 
 The range can be specified either as &lsquo;A1:B2&rsquo; or &lsquo;R1C1:R2C2&rsquo;;
 a special case is a single element (e.g &lsquo;A1&rsquo; or &lsquo;R1C1&rsquo;)

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>s</em></code>:  a range.</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        <li>start col</li>
        <li>start row</li>
        <li>end col</li>
        <li>end row</li>
    </ol>


</dd>
    <dt>
    <a name = "range"></a>
    <strong>range&nbsp;(t, rstr)</strong>
    </dt>
    <dd>
    get a slice of a 2D array using spreadsheet range notation.  @see parse_range

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2D array</li>
       <li><code><em>rstr</em></code>:  range expression</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        a slice
    </ol>


    <h3>see also:</h3>
    <ul>
         <li><a href="../modules/pl.array2d.html#parse_range">array2d.parse_range</a></li>
         <li><a href="../modules/pl.array2d.html#slice">array2d.slice</a></li>
    </ul>
</dd>
    <dt>
    <a name = "slice"></a>
    <strong>slice&nbsp;(t, i1, j1, i2, j2)</strong>
    </dt>
    <dd>
    get a slice of a 2D array.  Note that if the specified range has
 a 1D result, the rank of the result will be 1.

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2D array</li>
       <li><code><em>i1</em></code>:  start row (default 1)</li>
       <li><code><em>j1</em></code>:  start col (default 1)</li>
       <li><code><em>i2</em></code>:  end row   (default N)</li>
       <li><code><em>j2</em></code>:  end col   (default M)</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        an array, 2D in general but 1D in special cases.
    </ol>


</dd>
    <dt>
    <a name = "set"></a>
    <strong>set&nbsp;(t, value, i1, j1, i2, j2)</strong>
    </dt>
    <dd>
    set a specified range of an array to a value. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2D array</li>
       <li><code><em>value</em></code>:  the value (may be a function)</li>
       <li><code><em>i1</em></code>:  start row (default 1)</li>
       <li><code><em>j1</em></code>:  start col (default 1)</li>
       <li><code><em>i2</em></code>:  end row   (default N)</li>
       <li><code><em>j2</em></code>:  end col   (default M)</li>
    </ul>




    <h3>see also:</h3>
    <ul>
         <a href="../modules/pl.tablex.html#set">tablex.set</a>
    </ul>
</dd>
    <dt>
    <a name = "write"></a>
    <strong>write&nbsp;(t, f, fmt, i1, j1, i2, j2)</strong>
    </dt>
    <dd>
    write a 2D array to a file. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  a 2D array</li>
       <li><code><em>f</em></code>:  a file object (default stdout)</li>
       <li><code><em>fmt</em></code>:  a format string (default is just to use tostring)</li>
       <li><code><em>i1</em></code>:  start row (default 1)</li>
       <li><code><em>j1</em></code>:  start col (default 1)</li>
       <li><code><em>i2</em></code>:  end row   (default N)</li>
       <li><code><em>j2</em></code>:  end col   (default M)</li>
    </ul>




</dd>
    <dt>
    <a name = "forall"></a>
    <strong>forall&nbsp;(t, row_op, end_row_op, i1, j1, i2, j2)</strong>
    </dt>
    <dd>
    perform an operation for all values in a 2D array. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>t</em></code>:  2D array</li>
       <li><code><em>row_op</em></code>:  function to call on each value</li>
       <li><code><em>end_row_op</em></code>:  function to call at end of each row</li>
       <li><code><em>i1</em></code>:  start row (default 1)</li>
       <li><code><em>j1</em></code>:  start col (default 1)</li>
       <li><code><em>i2</em></code>:  end row   (default N)</li>
       <li><code><em>j2</em></code>:  end col   (default M)</li>
    </ul>




</dd>
    <dt>
    <a name = "move"></a>
    <strong>move&nbsp;(dest, di, dj, src, i1, j1, i2, j2)</strong>
    </dt>
    <dd>
    move a block from the destination to the source. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>dest</em></code>:  a 2D array</li>
       <li><code><em>di</em></code>:  start row in dest</li>
       <li><code><em>dj</em></code>:  start col in dest</li>
       <li><code><em>src</em></code>:  a 2D array</li>
       <li><code><em>i1</em></code>:  start row (default 1)</li>
       <li><code><em>j1</em></code>:  start col (default 1)</li>
       <li><code><em>i2</em></code>:  end row   (default N)</li>
       <li><code><em>j2</em></code>:  end col   (default M)</li>
    </ul>




</dd>
    <dt>
    <a name = "iter"></a>
    <strong>iter&nbsp;(a, indices, i1, j1, i2, j2)</strong>
    </dt>
    <dd>
    iterate over all elements in a 2D array, with optional indices. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>a</em></code>:  2D array</li>
       <li><code><em>indices</em></code>:  with indices (default false)</li>
       <li><code><em>i1</em></code>:  start row (default 1)</li>
       <li><code><em>j1</em></code>:  start col (default 1)</li>
       <li><code><em>i2</em></code>:  end row   (default N)</li>
       <li><code><em>j2</em></code>:  end col   (default M)</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        either value or i,j,value depending on indices
    </ol>


</dd>
    <dt>
    <a name = "columns"></a>
    <strong>columns&nbsp;(a)</strong>
    </dt>
    <dd>
    iterate over all columns. 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>a</em></code>:  a 2D array</li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        each column in turn
    </ol>


</dd>
    <dt>
    <a name = "new"></a>
    <strong>new&nbsp;(rows, cols, val)</strong>
    </dt>
    <dd>
    new array of specified dimensions 

    <h3>Parameters:</h3>
    <ul>
       <li><code><em>rows</em></code>:  number of rows</li>
       <li><code><em>cols</em></code>:  number of cols</li>
       <li><code><em>val</em></code>:  initial value; if it&rsquo;s a function then use <code>val(i,j)</code></li>
    </ul>


    <h3>Returns:</h3>
    <ol>
        new 2d array
    </ol>


</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.2</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>