TwoDimensionalArrayCategory(R, Row, Col)¶
array2.spad line 1 [edit on github]
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
- 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 inmatrix
.
- 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 positionk
,l
hasnk
rows andml
columns. Error: if number of rows of a is different thann1
+ … +ni
or number of columns of a is different thanm1
+ … +mj
- blockSplit: (%, PositiveInteger, PositiveInteger) -> List List %
blockSplit(a, n, m)
splits a inton*m
subarrays of equal size row and column wise, dividing a into blocks. Error: if number of rows of a is not divisible byn
or number of columns of a is not divisible bym
.
- coerce: % -> OutputForm if R has CoercibleTo OutputForm
from CoercibleTo OutputForm
- colSlice: % -> Segment Integer
colSlice(m)
returns a segments
such that form
the accessm
(i
,s
) gives thei
-th row.
- column: (%, Integer) -> Col
column(m, j)
returns thej
th column ofm
error check to determine if index is in proper ranges
- 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 thei
th row andj
th column of the arraym
error check to determine if indices are in proper ranges
- elt: (%, Integer, Integer, R) -> R
elt(m, i, j, r)
returns the element in thei
th row andj
th column of the arraym
, ifm
has ani
th row and aj
th column, and returnsr
otherwise
- elt: (%, Integer, List Integer) -> %
elt(x, row, colList)
returns an 1-by-n
array consisting of elements ofx
, wheren = \# colList
. IfcolList = [j<1>, j<2>, ..., j<n>]
, then the(k, l)
th entry ofelt(x, row, colList)
isx(row, j<l>)
.
- elt: (%, Integer, List Segment Integer) -> %
elt(x, row, ls2)
is equivalent toelt(x, row, l2)
wherel2
is obtained appending expansions of elements ofls2
, but should be more convenient and more efficient.
- elt: (%, List Integer, Integer) -> %
elt(x, rowList, col)
returns anm
-by-1 array consisting of elements ofx
, wherem = \# rowList
. IfrowList = [i<1>, i<2>, ..., i<m>]
, then the(k, l)
th entry ofelt(x, rowList, col)
isx(i<k>, col)
.
- elt: (%, List Integer, List Integer) -> %
elt(x, rowList, colList)
returns anm
-by-n
array consisting of elements ofx
, wherem = \# rowList
andn = \# colList
. IfrowList = [i<1>, i<2>, ..., i<m>]
andcolList = [j<1>, j<2>, ..., j<n>]
, then the(k, l)
th entry ofelt(x, rowList, colList)
isx(i<k>, j<l>)
.
- elt: (%, List Integer, Segment Integer) -> %
elt(x, rowList, s)
is equivalent toelt(x, rowList, expand(s))
but should be more convenient and more efficient.
- elt: (%, List Segment Integer, Integer) -> %
elt(x, ls1, col)
is equivalent toelt(x, l1, col)
wherel1
is obtained appending expansions of elements ofls1
, but should be more convenient and more efficient.
- elt: (%, List Segment Integer, List Segment Integer) -> %
elt(x, ls1, ls2)
is equivalent toelt(x, l1, l2)
whereli
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 toelt(x, l1, l2)
whereli
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 toelt(x, expand(s), colList)
but should be more convenient and more efficient.
- elt: (%, Segment Integer, List Segment Integer) -> %
elt(x, s1, ls2)
is equivalent toelt(x, l1, l2)
whereli
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 toelt(x, expand(s1), expand(s2))
but should be more convenient and more efficient.
- eval: (%, Equation R) -> % if R has Evalable R and R has SetCategory
from Evalable R
- eval: (%, List Equation R) -> % if R has Evalable R and R has SetCategory
from Evalable R
- eval: (%, List R, List R) -> % if R has Evalable R and R has SetCategory
from InnerEvalable(R, R)
- eval: (%, R, R) -> % if R has Evalable R and R has SetCategory
from InnerEvalable(R, R)
- every?: (R -> Boolean, %) -> Boolean
from HomogeneousAggregate R
- fill!: (%, R) -> %
fill!(m, r)
fillsm
withr
's
- hash: % -> SingleInteger if R has Hashable
from Hashable
- hashUpdate!: (HashState, %) -> HashState if R has Hashable
from Hashable
- horizConcat: (%, %) -> %
horizConcat(x, y)
horizontally concatenates two arrays with an equal number of rows. The entries ofy
appear to the right of the entries ofx
. Error: if the arrays do not have the same number of rows.
- horizConcat: List % -> %
horizConcat(l)
horizontally concatenates all members ofl
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 havingn1
, …,ni
columns. Error: if number of columns of a is different thann1
+ … +ni
.
- horizSplit: (%, PositiveInteger) -> List %
horizSplit(a, n)
splits a inton
arrays of equal size column wise. Error: if number of columns of a is not divisible byn
.
- latex: % -> String if R has SetCategory
from SetCategory
- less?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- map!: (R -> R, %) -> %
map!(f, a)
assigna(i, j)
tof(a(i, j))
for alli, j
- map: ((R, R) -> R, %, %) -> %
map(f, a, b)
returnsc
, wherec(i, j) = f(a(i, j), b(i, j))
for alli, j
- map: ((R, R) -> R, %, %, R) -> %
map(f, a, b, r)
returnsc
, wherec(i, j) = f(a(i, j), b(i, j))
when botha(i, j)
andb(i, j)
exist; elsec(i, j) = f(r, b(i, j))
whena(i, j)
does not exist; elsec(i, j) = f(a(i, j), r)
whenb(i, j)
does not exist; otherwisec(i, j) = f(r, r)
.
- map: (R -> R, %) -> %
map(f, a)
returnsb
, whereb(i, j) = f(a(i, j))
for alli, j
- max: % -> R if R has OrderedSet
from HomogeneousAggregate R
- max: ((R, R) -> Boolean, %) -> R
from HomogeneousAggregate R
- maxColIndex: % -> Integer
maxColIndex(m)
returns the index of the ‘last’ column of the arraym
- maxRowIndex: % -> Integer
maxRowIndex(m)
returns the index of the ‘last’ row of the arraym
- member?: (R, %) -> Boolean if R has BasicType
from HomogeneousAggregate R
- members: % -> List R
from HomogeneousAggregate R
- min: % -> R if R has OrderedSet
from HomogeneousAggregate R
- minColIndex: % -> Integer
minColIndex(m)
returns the index of the ‘first’ column of the arraym
- minRowIndex: % -> Integer
minRowIndex(m)
returns the index of the ‘first’ row of the arraym
- more?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- ncols: % -> NonNegativeInteger
ncols(m)
returns the number of columns in the arraym
- new: (NonNegativeInteger, NonNegativeInteger, R) -> %
new(m, n, r)
is anm
-by-n
array all of whose entries arer
- nrows: % -> NonNegativeInteger
nrows(m)
returns the number of rows in the arraym
- parts: % -> List R
parts(m)
returns a list of the elements ofm
in row major order
- qelt: (%, Integer, Integer) -> R
qelt(m, i, j)
returns the element in thei
th row andj
th column of the arraym
NO error check to determine if indices are in proper ranges
- qnew: (NonNegativeInteger, NonNegativeInteger) -> %
qnew(m, n)
is is anm
-by-n
uninitilized array
- qsetelt!: (%, Integer, Integer, R) -> R
qsetelt!(m, i, j, r)
sets the element in thei
th row andj
th column ofm
tor
NO error check to determine if indices are in proper ranges
- row: (%, Integer) -> Row
row(m, i)
returns thei
th row ofm
error check to determine if index is in proper ranges
- rowSlice: % -> Segment Integer
rowSlice(m)
returns a segments
such that form
the accessm
(s
,j
) gives thej
-th column.
- setColumn!: (%, Integer, Col) -> %
setColumn!(m, j, v)
sets toj
th column ofm
tov
- setelt!: (%, Integer, Integer, R) -> R
setelt!(m, i, j, r)
sets the element in thei
th row andj
th column ofm
tor
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, wheren = \# colList
.
- setelt!: (%, Integer, List Segment Integer, %) -> %
setelt!(x, row, ls2)
is equivalent tosetelt!(x, row, l2)
wherel2
is obtained appending expansions of elements ofls2
, but should be more convenient and more efficient.
- setelt!: (%, List Integer, Integer, %) -> %
setelt!(x, rowList, col)
assigns to anm
-by-1 selection of the array, wherem = \# rowList
.
- setelt!: (%, List Integer, List Integer, %) -> %
setelt!(x, rowList, colList, y)
destructively alters the arrayx
. Ify
ism
-by-n
,rowList = [i<1>, i<2>, ..., i<m>]
andcolList = [j<1>, j<2>, ..., j<n>]
, thenx(i<k>, j<l>)
is set toy(k, l)
fork = 1, ..., m
andl = 1, ..., n
.
- setelt!: (%, List Integer, Segment Integer, %) -> %
setelt!(x, l1, s2)
is equivalent tosetelt!(x, l1, expand(s2))
but should be more convenient and more efficient.
- setelt!: (%, List Segment Integer, Integer, %) -> %
setelt!(x, ls1, col)
is equivalent tosetelt!(x, l1, col)
wherel1
is obtained appending expansions of elements ofls1
, but should be more convenient and more efficient.
- setelt!: (%, List Segment Integer, List Segment Integer, %) -> %
setelt!(x, ls1, ls1)
is equivalent tosetelt!(x, l1, l2)
whereli
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 tosetelt!(x, l1, l2)
whereli
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 tosetelt!(x, expand(s1), l2)
but should be more convenient and more efficient.
- setelt!: (%, Segment Integer, List Segment Integer, %) -> %
setelt!(x, s1, ls2)
is equivalent tosetelt!(x, l1, l2)
whereli
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 tosetelt!(x, expand(s1), expand(s2))
but should be more convenient and more efficient.
- setRow!: (%, Integer, Row) -> %
setRow!(m, i, v)
sets toi
th row ofm
tov
- setsubMatrix!: (%, Integer, Integer, %) -> %
setsubMatrix(x, i1, j1, y)
destructively alters the arrayx
. Herex(i, j)
is set toy(i-i1+1, j-j1+1)
fori = i1, ..., i1-1+nrows y
andj = j1, ..., j1-1+ncols y
.
- size?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- smaller?: (%, %) -> Boolean if R has Comparable
from Comparable
- squareTop: % -> %
squareTop(m)
returns ann
-by-n
array consisting of the firstn
rows of them
-by-n
arraym
. Error: ifm < n
.
- subMatrix: (%, Integer, Integer, Integer, Integer) -> %
subMatrix(x, i1, i2, j1, j2)
extracts the submatrix[x(i, j)]
where the indexi
ranges fromi1
toi2
and the indexj
ranges fromj1
toj2
.
- swapColumns!: (%, Integer, Integer) -> %
swapColumns!(m, i, j)
interchanges thei
th andj
th columns ofm
. This destructively alters the array.
- swapRows!: (%, Integer, Integer) -> %
swapRows!(m, i, j)
interchanges thei
th andj
th rows ofm
. This destructively alters the array.
- transpose: % -> %
transpose(m)
returns the transpose of the arraym
.
- vertConcat: (%, %) -> %
vertConcat(x, y)
vertically concatenates two arrays with an equal number of columns. The entries ofy
appear below of the entries ofx
. Error: if the arrays do not have the same number of columns.
- vertConcat: List % -> %
vertConcat(l)
vertically concatenates all members ofl
Error: if the arrays do not have the same number of columns.
- vertSplit: (%, List NonNegativeInteger) -> List %
vertSplit(a, [n1, ..., ni])
splits a into arrays havingn1
, …,ni
rows. Error: if number of rows of a is different thann1+
… +ni
.
- vertSplit: (%, PositiveInteger) -> List %
vertSplit(a, n)
splits a inton
arrays of equal size row wise. Error: if number of rows of a is not divisible byn
.
CoercibleTo OutputForm if R has CoercibleTo OutputForm
Comparable if R has Comparable
Evalable R if R has Evalable R and R has SetCategory
InnerEvalable(R, R) if R has Evalable R and R has SetCategory
SetCategory if R has SetCategory