1(*
2    Title:      Standard Basis Library: Array2 signature.
3    Author:     David Matthews
4    Copyright   David Matthews 2000, 2005, 2016
5
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License version 2.1 as published by the Free Software Foundation.
9    
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14    
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18*)
19
20signature ARRAY2 =
21sig
22    eqtype 'a array
23    type 'a region =
24    {
25        base : 'a array,
26        row : int,
27        col : int,
28        nrows : int option,
29        ncols : int option
30    }
31    datatype traversal = RowMajor | ColMajor
32    val array: int * int * 'a -> 'a array
33    val fromList: 'a list list -> 'a array
34    val tabulate: traversal -> int * int * (int * int -> 'a) -> 'a array
35    val sub: 'a array * int * int -> 'a
36    val update: 'a array * int * int * 'a -> unit
37    val dimensions: 'a array -> int * int
38    val nCols: 'a array -> int
39    val nRows: 'a array -> int
40    val row: 'a array * int -> 'a Vector.vector
41    val column: 'a array * int -> 'a Vector.vector
42    val copy:
43     {src : 'a region, dst : 'a array, dst_row : int, dst_col : int} -> unit
44    val appi: traversal -> (int * int * 'a -> unit) -> 'a region -> unit
45    val app: traversal -> ('a -> unit) -> 'a array -> unit
46    val modifyi: traversal -> (int * int * 'a -> 'a) -> 'a region -> unit
47    val modify: traversal -> ('a -> 'a) -> 'a array -> unit
48    val foldi:
49        traversal -> (int * int * 'a * 'b -> 'b) -> 'b -> 'a region -> 'b
50    val fold: traversal -> ('a * 'b -> 'b) -> 'b -> 'a array -> 'b
51end;
52