array2.spad line 1 [edit on github]
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.
array2(ll)
constructs a 2-dimensional array, the inner list being the rows.
blockConcat(ll)
concatenates arrays row and column wise, building a array from blocks. The order is row major as in matrix
.
blockSplit(a, [n1,...,
splits a into multiple subarraus row and column wise, such that element at position ni
], [m1,...,mi
])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(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
.
colSlice(m)
returns a segment s
such that for m
the access m
(i
, s
) gives the i
-th row.
column(m, j)
returns the j
th column of m
error check to determine if index is in proper ranges
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(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(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(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(x, rowList, s)
is equivalent to elt(x, rowList, expand(s))
but should be more convenient and more efficient.
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(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(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(x, s, colList)
is equivalent to elt(x, expand(s), colList)
but should be more convenient and more efficient.
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(x, s1, s2)
is equivalent to elt(x, expand(s1), expand(s2))
but should be more convenient and more efficient.
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(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
fill!(m, r)
fills m
with r
's
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(l)
horizontally concatenates all members of l
Error: if the arrays do not have the same number of rows.
horizSplit(a, [n1, n2, ...,
splits a into arrays having ni
])n1
, ..., ni
columns. Error: if number of columns of a is different than n1
+ ... + ni
.
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
.
listOfLists(m)
returns the rows of the array m
as a list of lists.
map(f, a)
returns b
, where b(i, j) = f(a(i, j))
for all i, j
map(f, a, b)
returns c
, where c(i, j) = f(a(i, j), b(i, j))
for all i, j
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!(f, a)
assign a(i, j)
to f(a(i, j))
for all i, j
maxColIndex(m)
returns the index of the 'last' column of the array m
maxRowIndex(m)
returns the index of the 'last' row of the array m
minColIndex(m)
returns the index of the 'first' column of the array m
minRowIndex(m)
returns the index of the 'first' row of the array m
ncols(m)
returns the number of columns in the array m
new(m, n, r)
is an m
-by-n
array all of whose entries are r
nrows(m)
returns the number of rows in the array m
parts(m)
returns a list of the elements of m
in row major order
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(m, n)
is is an m
-by-n
uninitilized array
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(m, i)
returns the i
th row of m
error check to determine if index is in proper ranges
rowSlice(m)
returns a segment s
such that for m
the access m
(s
, j
) gives the j
-th column.
setColumn!(m, j, v)
sets to j
th column of m
to v
setRow!(m, i, v)
sets to i
th row of m
to v
setelt!(x, row, colList)
assigns to an 1-by-n
selection of the array, where n = # colList
.
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!(x, rowList, col)
assigns to an m
-by-1 selection of the array, where m = # rowList
.
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!(x, l1, s2)
is equivalent to setelt!(x, l1, expand(s2))
but should be more convenient and more efficient.
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!(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!(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!(x, s1, l2)
is equivalent to setelt!(x, expand(s1), l2)
but should be more convenient and more efficient.
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!(x, s1, s2)
is equivalent to setelt!(x, expand(s1), expand(s2))
but should be more convenient and more efficient.
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
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
.
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(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!(m, i, j)
interchanges the i
th and j
th columns of m
. This destructively alters the array.
swapRows!(m, i, j)
interchanges the i
th and j
th rows of m
. This destructively alters the array.
transpose(m)
returns the transpose of the array m
.
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(l)
vertically concatenates all members of l
Error: if the arrays do not have the same number of columns.
vertSplit(a, [n1, ...,
splits a into arrays having ni
])n1
, ..., ni
rows. Error: if number of rows of a is different than n1+
... + ni
.
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
.
InnerEvalable(R, R)
Evalable(R)