# TwoDimensionalArrayCategory(R, Row, Col)ΒΆ

- R: Type
- Row: IndexedAggregate(Integer, R)
- Col: IndexedAggregate(Integer, R)

TwoDimensionalArrayCategory is a general array category which allows different representations and indexing schemes. Rows and columns may be extracted with rows returned as objects of type Row and columns returned as objects of type Col. The index of the ‘first’ row may be obtained by calling the function ‘minRowIndex’. The index of the ‘first’ column may be obtained by calling the function ‘minColIndex’. The index of the first element of a ‘Row’ is the same as the index of the first column in an array and vice versa.

- #: % -> NonNegativeInteger
- from Aggregate
- =: (%, %) -> Boolean if R has BasicType
- from BasicType
- ~=: (%, %) -> Boolean if R has BasicType
- from BasicType
- any?: (R -> Boolean, %) -> Boolean
- from HomogeneousAggregate R

- blockConcat: List List % -> %
`blockConcat(ll)`

concatenates arrays row and column wise, building a array from blocks. The order is row major as in`matrix`

.

- blockSplit: (%, List NonNegativeInteger, List NonNegativeInteger) -> List List %
`blockSplit(a, [n1,...,ni], [m1,...,mi])`

splits a into multiple subarraus row and column wise, such that element at position`k`

,`l`

has`nk`

rows and`ml`

columns. Error: if number of rows of a is different than`n1`

+ ... +`ni`

or number of columns of a is different than`m1`

+ ... +`mj`

- blockSplit: (%, PositiveInteger, PositiveInteger) -> List List %
`blockSplit(a, n, m)`

splits a into`n*m`

subarrays of equal size row and column wise, dividing a into blocks. Error: if number of rows of a is not divisible by`n`

or number of columns of a is not divisible by`m`

.- coerce: % -> OutputForm if R has CoercibleTo OutputForm
- from CoercibleTo OutputForm

- colSlice: % -> Segment Integer
`colSlice(m)`

returns a segment`s`

such that for`m`

the access`m`

(`i`

,`s`

) gives the`i`

-th row.

- column: (%, Integer) -> Col
`column(m, j)`

returns the`j`

th column of`m`

error check to determine if index is in proper ranges- copy: % -> %
- from Aggregate
- count: (R -> Boolean, %) -> NonNegativeInteger
- from HomogeneousAggregate R
- count: (R, %) -> NonNegativeInteger if R has BasicType
- from HomogeneousAggregate R

- elt: (%, Integer, Integer) -> R
`elt(m, i, j)`

returns the element in the`i`

th row and`j`

th column of the array`m`

error check to determine if indices are in proper ranges

- elt: (%, Integer, Integer, R) -> R
`elt(m, i, j, r)`

returns the element in the`i`

th row and`j`

th column of the array`m`

, if`m`

has an`i`

th row and a`j`

th column, and returns`r`

otherwise

- elt: (%, Integer, List Integer) -> %
`elt(x, row, colList)`

returns an 1-by-`n`

array consisting of elements of`x`

, where`n = \# colList`

. If`colList = [j<1>, j<2>, ..., j<n>]`

, then the`(k, l)`

th entry of`elt(x, row, colList)`

is`x(row, j<l>)`

.

- elt: (%, Integer, List Segment Integer) -> %
`elt(x, row, ls2)`

is equivalent to`elt(x, row, l2)`

where`l2`

is obtained appending expansions of elements of`ls2`

, but should be more convenient and more efficient.

- elt: (%, List Integer, Integer) -> %
`elt(x, rowList, col)`

returns an`m`

-by-1 array consisting of elements of`x`

, where`m = \# rowList`

. If`rowList = [i<1>, i<2>, ..., i<m>]`

, then the`(k, l)`

th entry of`elt(x, rowList, col)`

is`x(i<k>, col)`

.

- elt: (%, List Integer, List Integer) -> %
`elt(x, rowList, colList)`

returns an`m`

-by-`n`

array consisting of elements of`x`

, where`m = \# rowList`

and`n = \# colList`

. If`rowList = [i<1>, i<2>, ..., i<m>]`

and`colList = [j<1>, j<2>, ..., j<n>]`

, then the`(k, l)`

th entry of`elt(x, rowList, colList)`

is`x(i<k>, j<l>)`

.

- elt: (%, List Integer, Segment Integer) -> %
`elt(x, rowList, s)`

is equivalent to`elt(x, rowList, expand(s))`

but should be more convenient and more efficient.

- elt: (%, List Segment Integer, Integer) -> %
`elt(x, ls1, col)`

is equivalent to`elt(x, l1, col)`

where`l1`

is obtained appending expansions of elements of`ls1`

, but should be more convenient and more efficient.

- elt: (%, List Segment Integer, List Segment Integer) -> %
`elt(x, ls1, ls2)`

is equivalent to`elt(x, l1, l2)`

where`li`

is obtained appending expansions of elements of lsi, but should be more convenient and more efficient.

- elt: (%, List Segment Integer, Segment Integer) -> %
`elt(x, ls1, s2)`

is equivalent to`elt(x, l1, l2)`

where`li`

is obtained appending expansions of elements of lsi, but should be more convenient and more efficient.

- elt: (%, Segment Integer, List Integer) -> %
`elt(x, s, colList)`

is equivalent to`elt(x, expand(s), colList)`

but should be more convenient and more efficient.

- elt: (%, Segment Integer, List Segment Integer) -> %
`elt(x, s1, ls2)`

is equivalent to`elt(x, l1, l2)`

where`li`

is obtained appending expansions of elements of lsi, but should be more convenient and more efficient.

- elt: (%, Segment Integer, Segment Integer) -> %
`elt(x, s1, s2)`

is equivalent to`elt(x, expand(s1), expand(s2))`

but should be more convenient and more efficient.- empty: () -> %
- from Aggregate
- empty?: % -> Boolean
- from Aggregate
- eq?: (%, %) -> Boolean
- from Aggregate
- eval: (%, Equation R) -> % if R has SetCategory and R has Evalable R
- from Evalable R
- eval: (%, List Equation R) -> % if R has SetCategory and R has Evalable R
- from Evalable R
- eval: (%, List R, List R) -> % if R has SetCategory and R has Evalable R
- from InnerEvalable(R, R)
- eval: (%, R, R) -> % if R has SetCategory and R has Evalable R
- from InnerEvalable(R, R)
- every?: (R -> Boolean, %) -> Boolean
- from HomogeneousAggregate R

- fill!: (%, R) -> %
`fill!(m, r)`

fills`m`

with`r`

`'s`

- hash: % -> SingleInteger if R has SetCategory
- from SetCategory
- hashUpdate!: (HashState, %) -> HashState if R has SetCategory
- from SetCategory

- horizConcat: (%, %) -> %
`horizConcat(x, y)`

horizontally concatenates two arrays with an equal number of rows. The entries of`y`

appear to the right of the entries of`x`

. Error: if the arrays do not have the same number of rows.

- horizConcat: List % -> %
`horizConcat(l)`

horizontally concatenates all members of`l`

Error: if the arrays do not have the same number of rows.

- horizSplit: (%, List NonNegativeInteger) -> List %
`horizSplit(a, [n1, n2, ..., ni])`

splits a into arrays having`n1`

, ...,`ni`

columns. Error: if number of columns of a is different than`n1`

+ ... +`ni`

.

- horizSplit: (%, PositiveInteger) -> List %
`horizSplit(a, n)`

splits a into`n`

arrays of equal size column wise. Error: if number of columns of a is not divisible by`n`

.- latex: % -> String if R has SetCategory
- from SetCategory
- less?: (%, NonNegativeInteger) -> Boolean
- from Aggregate

- map!: (R -> R, %) -> %
`map!(f, a)`

assign`a(i, j)`

to`f(a(i, j))`

for all`i, j`

- map: ((R, R) -> R, %, %) -> %
`map(f, a, b)`

returns`c`

, where`c(i, j) = f(a(i, j), b(i, j))`

for all`i, j`

- map: ((R, R) -> R, %, %, R) -> %
`map(f, a, b, r)`

returns`c`

, where`c(i, j) = f(a(i, j), b(i, j))`

when both`a(i, j)`

and`b(i, j)`

exist; else`c(i, j) = f(r, b(i, j))`

when`a(i, j)`

does not exist; else`c(i, j) = f(a(i, j), r)`

when`b(i, j)`

does not exist; otherwise`c(i, j) = f(r, r)`

.

- map: (R -> R, %) -> %
`map(f, a)`

returns`b`

, where`b(i, j) = f(a(i, j))`

for all`i, j`

- maxColIndex: % -> Integer
`maxColIndex(m)`

returns the index of the ‘last’ column of the array`m`

- maxRowIndex: % -> Integer
`maxRowIndex(m)`

returns the index of the ‘last’ row of the array`m`

- member?: (R, %) -> Boolean if R has BasicType
- from HomogeneousAggregate R
- members: % -> List R
- from HomogeneousAggregate R

- minColIndex: % -> Integer
`minColIndex(m)`

returns the index of the ‘first’ column of the array`m`

- minRowIndex: % -> Integer
`minRowIndex(m)`

returns the index of the ‘first’ row of the array`m`

- more?: (%, NonNegativeInteger) -> Boolean
- from Aggregate

- ncols: % -> NonNegativeInteger
`ncols(m)`

returns the number of columns in the array`m`

- new: (NonNegativeInteger, NonNegativeInteger, R) -> %
`new(m, n, r)`

is an`m`

-by-`n`

array all of whose entries are`r`

- nrows: % -> NonNegativeInteger
`nrows(m)`

returns the number of rows in the array`m`

- parts: % -> List R
`parts(m)`

returns a list of the elements of`m`

in row major order

- qelt: (%, Integer, Integer) -> R
`qelt(m, i, j)`

returns the element in the`i`

th row and`j`

th column of the array`m`

NO error check to determine if indices are in proper ranges

- qnew: (NonNegativeInteger, NonNegativeInteger) -> %
`qnew(m, n)`

is is an`m`

-by-`n`

uninitilized array

- qsetelt!: (%, Integer, Integer, R) -> R
`qsetelt!(m, i, j, r)`

sets the element in the`i`

th row and`j`

th column of`m`

to`r`

NO error check to determine if indices are in proper ranges

- row: (%, Integer) -> Row
`row(m, i)`

returns the`i`

th row of`m`

error check to determine if index is in proper ranges

- rowSlice: % -> Segment Integer
`rowSlice(m)`

returns a segment`s`

such that for`m`

the access`m`

(`s`

,`j`

) gives the`j`

-th column.- sample: %
- from Aggregate

- setColumn!: (%, Integer, Col) -> %
`setColumn!(m, j, v)`

sets to`j`

th column of`m`

to`v`

- setelt!: (%, Integer, Integer, R) -> R
`setelt!(m, i, j, r)`

sets the element in the`i`

th row and`j`

th column of`m`

to`r`

error check to determine if indices are in proper ranges

- setelt!: (%, Integer, List Integer, %) -> %
`setelt!(x, row, colList)`

assigns to an 1-by-`n`

selection of the array, where`n = \# colList`

.

- setelt!: (%, Integer, List Segment Integer, %) -> %
`setelt!(x, row, ls2)`

is equivalent to`setelt!(x, row, l2)`

where`l2`

is obtained appending expansions of elements of`ls2`

, but should be more convenient and more efficient.

- setelt!: (%, List Integer, Integer, %) -> %
`setelt!(x, rowList, col)`

assigns to an`m`

-by-1 selection of the array, where`m = \# rowList`

.

- setelt!: (%, List Integer, List Integer, %) -> %
`setelt!(x, rowList, colList, y)`

destructively alters the array`x`

. If`y`

is`m`

-by-`n`

,`rowList = [i<1>, i<2>, ..., i<m>]`

and`colList = [j<1>, j<2>, ..., j<n>]`

, then`x(i<k>, j<l>)`

is set to`y(k, l)`

for`k = 1, ..., m`

and`l = 1, ..., n`

.

- setelt!: (%, List Integer, Segment Integer, %) -> %
`setelt!(x, l1, s2)`

is equivalent to`setelt!(x, l1, expand(s2))`

but should be more convenient and more efficient.

- setelt!: (%, List Segment Integer, Integer, %) -> %
`setelt!(x, ls1, col)`

is equivalent to`setelt!(x, l1, col)`

where`l1`

is obtained appending expansions of elements of`ls1`

, but should be more convenient and more efficient.

- setelt!: (%, List Segment Integer, List Segment Integer, %) -> %
`setelt!(x, ls1, ls1)`

is equivalent to`setelt!(x, l1, l2)`

where`li`

is obtained appending expansions of elements of lsi, but should be more convenient and more efficient.

- setelt!: (%, List Segment Integer, Segment Integer, %) -> %
`setelt!(x, ls1, s2)`

is equivalent to`setelt!(x, l1, l2)`

where`li`

is obtained appending expansions of elements of lsi, but should be more convenient and more efficient.

- setelt!: (%, Segment Integer, List Integer, %) -> %
`setelt!(x, s1, l2)`

is equivalent to`setelt!(x, expand(s1), l2)`

but should be more convenient and more efficient.

- setelt!: (%, Segment Integer, List Segment Integer, %) -> %
`setelt!(x, s1, ls2)`

is equivalent to`setelt!(x, l1, l2)`

where`li`

is obtained appending expansions of elements of lsi, but should be more convenient and more efficient.

- setelt!: (%, Segment Integer, Segment Integer, %) -> %
`setelt!(x, s1, s2)`

is equivalent to`setelt!(x, expand(s1), expand(s2))`

but should be more convenient and more efficient.

- setRow!: (%, Integer, Row) -> %
`setRow!(m, i, v)`

sets to`i`

th row of`m`

to`v`

- setsubMatrix!: (%, Integer, Integer, %) -> %
`setsubMatrix(x, i1, j1, y)`

destructively alters the array`x`

. Here`x(i, j)`

is set to`y(i-i1+1, j-j1+1)`

for`i = i1, ..., i1-1+nrows y`

and`j = j1, ..., j1-1+ncols y`

.- size?: (%, NonNegativeInteger) -> Boolean
- from Aggregate
- smaller?: (%, %) -> Boolean if R has Comparable
- from Comparable

- squareTop: % -> %
`squareTop(m)`

returns an`n`

-by-`n`

array consisting of the first`n`

rows of the`m`

-by-`n`

array`m`

. Error: if`m < n`

.

- subMatrix: (%, Integer, Integer, Integer, Integer) -> %
`subMatrix(x, i1, i2, j1, j2)`

extracts the submatrix`[x(i, j)]`

where the index`i`

ranges from`i1`

to`i2`

and the index`j`

ranges from`j1`

to`j2`

.

- swapColumns!: (%, Integer, Integer) -> %
`swapColumns!(m, i, j)`

interchanges the`i`

th and`j`

th columns of`m`

. This destructively alters the array.

- swapRows!: (%, Integer, Integer) -> %
`swapRows!(m, i, j)`

interchanges the`i`

th and`j`

th rows of`m`

. This destructively alters the array.

- transpose: % -> %
`transpose(m)`

returns the transpose of the array`m`

.

- vertConcat: (%, %) -> %
`vertConcat(x, y)`

vertically concatenates two arrays with an equal number of columns. The entries of`y`

appear below of the entries of`x`

. Error: if the arrays do not have the same number of columns.

- vertConcat: List % -> %
`vertConcat(l)`

vertically concatenates all members of`l`

Error: if the arrays do not have the same number of columns.

- vertSplit: (%, List NonNegativeInteger) -> List %
`vertSplit(a, [n1, ..., ni])`

splits a into arrays having`n1`

, ...,`ni`

rows. Error: if number of rows of a is different than`n1+`

... +`ni`

.

- vertSplit: (%, PositiveInteger) -> List %
`vertSplit(a, n)`

splits a into`n`

arrays of equal size row wise. Error: if number of rows of a is not divisible by`n`

.

CoercibleTo OutputForm if R has CoercibleTo OutputForm

Comparable if R has Comparable

Evalable R if R has SetCategory and R has Evalable R

InnerEvalable(R, R) if R has SetCategory and R has Evalable R

SetCategory if R has SetCategory