Go to the previous, next section.
The following functions create, resize, reshape, permute and compose
matrices.
In this list of functions, symbols A, B and C are
of the class integer_matrix; a and c are a single
row of the matrix (class integer_row) and m, n,
i and j are integers.
integer_matrix A();
A.init();
integer_matrix A(i, j);
A.init(i, j);
integer_matrix A(B);
integer_matrix A(&B);
A.init(B);
A.init(&B);
integer_matrix A(B, m);
integer_matrix A(&B, m);
A.init(B, m);
A.init(&B, m);
immed_list ilist;
j = A.init(ilist);
j = A.init(ilist, i);
immed is a class abstraction used
by SUIF compiler to store values of different types. Matrix A
is initialized from a specially created list of immeds (starting
from position i). The integer variable j gets the next
position of the list after reading in the matrix.
immed_list * il = A.cvt_immed_list();
immed_list from the matrix A. These functions
are used when matrices are stored as annotations.
A = Compose(row, col, int, int, int, ...)
A = Compose(2, 3, i11, i12, i13, i21, i22, i23);will create a 2x3 matrix initialized to the integers given. Thus A is:
[ i11, i12, i13 ] [ i21, i22, i23 ]
nim_op O;
A = Compose(row, col, O.NIM(...) or NULL, O.NIM(...) or NULL, ...)
nim_op O; A = Compose(2, 3, O.NIM(B11), O.NIM(B12), NULL, NULL, O.NIM(B22), O.NIM(i,j));will create the matrix:
[ [B11] [B12] 0 ] [ 0 [B21] [ixj] ]
where all the matrices contributing to a row have the same number of
rows and matrices contributing to a column have the same number of
columns -- except when an entry is NULL. Then, that space is stuffed
with zeros according to the size dictated by other elements in its row
and column. Thus, each row and column should have at least one entry
that is not NULL. The function NIM is used as a wrap-around for
all the input matrices. NIM(i, j) creates an ixj
matrix and NIM(x) creates a single element with the value
x. The wrappers created by the calls to O.NIM(...) will be
deleted when the nim_op object O is deleted.
The following example further illustrates the use ofCompose.lin_ineq A = Compose(2, 2, 1 2 3 4); lin_ineq B(1, 3); B = 2; nim_op O; lin_ineq C = Compose(2, 2, O.NIM(A), 0, O.NIM(1,2), 0, 0, O.NIM(B));The matrices are:
A = [ 1 2 ] [ 1 2 0 0 0 ] [ 3 4 ] C = [ 3 4 0 0 0 ] [ 0 0 0 0 0 ] B = [ 2 2 2 ] [ 0 0 2 2 2 ]
A = Ident(i);
A.del_row(i);
A.del_row(i, j);
A.del_col(i);
A.del_col(i, j);
B = A.del_columns(a);
A.insert_col(i);
B = A.swap(i, j);
A[i] ^= A[j];
^=, the current
matrix A is updated.
B = A.swap_col(i, j);
B = A%a;
B = A.resize(il, iu, jl, ju);
B = A.resize(il, iu, jl, ju, fill);
For example:B = A.resize(1, 3, 2, 7);where
[ 0 1 2 3 4 ] [ 12 13 14 0 0 0 ] [ 10 11 12 13 14 ] B = [ 22 23 24 0 0 0 ] A = [ 20 21 22 23 24 ] [ 32 33 34 0 0 0 ] [ 30 31 32 33 34 ] [ 40 41 42 43 44 ]
B = A.resize_offset(il, iu, jl, ju);
B = A.resize_offset(il, iu, jl, ju, fill);
For example:B = A.resize_offset(1, -1, 2, 3);where
[ 0 1 2 3 4 ] [ 12 13 14 0 0 0 ] [ 10 11 12 13 14 ] B = [ 22 23 24 0 0 0 ] A = [ 20 21 22 23 24 ] [ 32 33 34 0 0 0 ] [ 30 31 32 33 34 ] [ 40 41 42 43 44 ]
C = A & B;
C = r_merge(A, B);
[ A ]
[ B ]
This is same as C = Compose(2, 1, O.NIM(A), O.NIM(B));.
C = A | B;
C = c_merge(A, B);
[ A B ]
The matrix library also can create permutation matrices and row-column switch and add matrices.
B = rowswitch(A, i, j);
B = colswitch(A, i, j);
B = rowadd(A, i, j, x);
B = coladd(A, i, j, x);
Go to the previous, next section.