Home | Trees | Index | Help |
|
---|
Package sage :: Package linalg :: Module matrix :: Class Matrix |
|
Matrix_generic_dense
,
Matrix_generic_sparse
,
Matrix_rational_dense
Method Summary | |
---|---|
__init__(self,
parent)
| |
__abs__(self)
| |
__add__(self,
right)
| |
__cmp__(self,
right)
| |
__div__(self,
right)
| |
__getitem__(self,
ij)
| |
__invert__(self)
| |
__mod__(self,
p)
| |
__mul__(self,
right)
| |
__neg__(self)
| |
__pos__(self)
| |
EXAMPLES: | |
__radd__(self,
right)
| |
__repr__(self)
| |
__rmul__(self,
left)
| |
__setitem__(self,
ij,
x)
| |
__str__(self)
| |
__sub__(self,
right)
| |
Replace column i by s times column j. | |
Replace row i by s times row j. | |
Return the augmented matrix of the form [self | other]. | |
base_ring(self)
| |
Return the block matrix that has self and other on the diagonal: [self | 0 ] [ 0 | other ] | |
change_ring(self,
ring)
| |
charpoly(self)
| |
column_space(self)
| |
Returns the list of columns of self, as vectors. | |
commutator(self,
other)
| |
copy(self)
| |
Returns the decomposition of the vector space under the right action of self. | |
Suppose A is a matrix acting on a vector space V, and W is a vector subspace of V. | |
denominator(self)
| |
dense_row(self,
n)
| |
det(self)
| |
determinant(self)
| |
Returns the reduced row echelon form INPUT: matrix -- an element A of a MatrixSpace OUTPUT: matrix -- The reduced row echelon form of A. | |
entries(self)
| |
Return the factorization of the characteristic polynomial of self. | |
get(self,
ij)
| |
height(self)
| |
hermite_normal_form(self)
| |
Compute and return the Hessenberg form of self. | |
image(self)
| |
is_dense(self)
| |
is_invertible(self)
| |
is_matrix(self)
| |
is_sparse(self)
| |
is_square(self)
| |
ALGORITHM: Elementary row ops don't change kernel, since they are just left multiplication by an invertible matrix, so we instead compute kernel of echelon form, which is easy. | |
linalg_matrix(self)
| |
linear_combination_of_rows(self,
v)
| |
list(self)
| |
matrix(self,
nrows,
ncols,
entries,
coerce_entries,
copy)
| |
matrix_space(self,
nrows,
ncols)
| |
Computes the largest integer n such that the list of vectors S=[v, A(v), ..., A^n(v)] are linearly independent, and returns that list. | |
ncols(self)
| |
Return the list of i such that the i-th column of self is NOT a pivot column of the reduced row echelon form of self. | |
Returns the set of pairs (i,j) such that self[i,j] != 0. | |
Return the integers j such that self[j,i] is nonzero, i.e., such that the j-th position of the i-th column is nonzero. | |
Return the integers j such that self[i,j] is nonzero, i.e., such that the j-th position of the i-th row is nonzero. | |
nrows(self)
| |
nullity(self)
| |
parent(self)
| |
pari(self)
| |
Return the i such that the i-th column of self is a pivot column of the reduced row echelon form of self. | |
rank(self)
| |
rational_decomposition(self)
| |
rational_reconstruction(self)
| |
Returns the reduced row echelon form INPUT: matrix -- an element A of a MatrixSpace OUTPUT: matrix -- The reduced row echelon form of A. | |
Replace i-th row of self by s times i-th row of self. | |
Returns the matrix that defines the action of self on the invariant subspace V. | |
row(self,
i)
| |
row_space(self)
| |
rows(self)
| |
set(self,
ij,
x)
| |
smith_normal_form(self)
| |
sparse_columns(self)
| |
sparse_rows(self)
| |
Return the augmented matrix self on top of other:... | |
Print a latex matrix representation of self. | |
Return a latex string that represents this matrix as a sparse matrix. | |
Return the submatrix of self of columns col[i] for i in the list of columns. | |
Return the submatrix of self of rows row[i] for i in the list of rows. | |
Swap columns c1 and c2 of self. | |
Swap rows r1 and r2 of self. | |
Return the trace of self, which is the sum of the diagonal entries of self. | |
Returns the transpose of self, without changing self. | |
Returns the vector times matrix product. |
Method Details |
---|
__pow__(self, n)EXAMPLES:>>> from matrix_space import MatrixSpace >>> from sage.rings.rings import RationalField >>> A = MatrixSpace(RationalField(), 3, 3)( [0, 0, 1, 1, 0, '-2/11', 0, 1, '-3/11']) >>> A * A**(-1) == 1 True >>> A**4 [ -3/11 -13/121 1436/1331] [ 127/121 -337/1331 -4445/14641] [ -13/121 1436/1331 -8015/14641] |
add_multiple_of_column(self, i, j, s)Replace column i by s times column j. |
add_multiple_of_row(self, i, j, s)Replace row i by s times row j. |
augment(self, other)Return the augmented matrix of the form [self | other]. |
block_sum(self, other)Return the block matrix that has self and other on the diagonal: [self | 0 ] [ 0 | other ] |
columns(self)Returns the list of columns of self, as vectors. EXAMPLES:>>> from sage.all import * >>> A = MatrixSpace(QQ, 2,3) (xrange(6)) >>> A [0 1 2] [3 4 5] >>> A.columns() [(0 3), (1 4), (2 5)] |
decompose(self, is_diagonalizable=False)Returns the decomposition of the vector space under the right action of self. Let A be the matrix acting from the on the vector space V of column vectors. Assume that A is square. This function computes maximal subspaces W_1, ..., W_n corresponding to Galois conjugacy classes of eigenvalues of A. More precisely, let f(X) be the characteristic polynomial of A. this function computes the subspace W_i = ker(g_(A)^n), where g_i(X) is an irreducible factor of f(X) and g_i(X) exactly divides f(X). If the optional parameter is_diagonalizable is True, then we let W_i = ker(g(A)), since then we know that ker(g(A)) = ker(g(A)^n). OUTPUT: list -- list of Vector Spaces |
decompose_subspace(self, V, is_diagonalizable=False)Suppose A is a matrix acting on a vector space V, and W is a vector subspace of V. Return decomposition of subspace as a list of pairs (W, is_irred) where is_irred is True if the charpoly of A acting on W is irreducible. |
echelon_form(self, *args)Returns the reduced row echelon form INPUT: matrix -- an element A of a MatrixSpace OUTPUT: matrix -- The reduced row echelon form of A. Note that self is *not* changed by this command. EXAMPLES: >>> from sage.linalg.matrix_space import MatrixSpace >>> from sage.rings.rings import RationalField >>> MS = MatrixSpace(RationalField(),2,3) >>> C = MS.matrix([1,2,3,4,5,6]) >>> C.rank() 2 >>> C.nullity() 1 >>> C.reduced_row_echelon_form() [ 1 0 -1] [ 0 1 2] |
fcp(self)Return the factorization of the characteristic polynomial of self. |
hessenberg_normal_form(self)Compute and return the Hessenberg form of self. ALGORITHM: See Henri Cohen's book. |
kernel(self)ALGORITHM: Elementary row ops don't change kernel, since they are just left multiplication by an invertible matrix, so we instead compute kernel of echelon form, which is easy. More precisely, there is a basis vector of the kernel that corresponds to each non-pivot column. That vector has a 1 at the non-pivot column, 0's at all other non-pivot columns, and for each pivot column, the negative of the entry at the non-pivot column in the row with that pivot element. Since we view matrices as acting on the right, we compute the echelon form of the transpose. |
maxspin(self, v)Computes the largest integer n such that the list of vectors S=[v, A(v), ..., A^n(v)] are linearly independent, and returns that list. INPUT: self -- Matrix v -- Vector OUTPUT: list -- list of Vectors ALGORITHM: The current implementation just adds vectors to a vector space until the dimension doesn't grow. This could be optimized by directly using matrices and doing an efficient Echelon form. Also, when the base is Q, maybe we could simultaneously keep track of what is going on in the reduction modulo p, which might make things much faster. |
nonpivots(self)Return the list of i such that the i-th column of self is NOT a pivot column of the reduced row echelon form of self. OUTPUT: list -- sorted list of integers |
nonzero_positions(self)Returns the set of pairs (i,j) such that self[i,j] != 0. |
nonzero_positions_in_column(self, i)Return the integers j such that self[j,i] is nonzero, i.e., such that the j-th position of the i-th column is nonzero. |
nonzero_positions_in_row(self, i)Return the integers j such that self[i,j] is nonzero, i.e., such that the j-th position of the i-th row is nonzero. |
pivots(self)Return the i such that the i-th column of self is a pivot column of the reduced row echelon form of self. OUTPUT: list -- sorted list of integers |
reduced_row_echelon_form(self, *args)Returns the reduced row echelon form INPUT: matrix -- an element A of a MatrixSpace OUTPUT: matrix -- The reduced row echelon form of A. Note that self is *not* changed by this command. EXAMPLES: >>> from sage.linalg.matrix_space import MatrixSpace >>> from sage.rings.rings import RationalField >>> MS = MatrixSpace(RationalField(),2,3) >>> C = MS.matrix([1,2,3,4,5,6]) >>> C.rank() 2 >>> C.nullity() 1 >>> C.reduced_row_echelon_form() [ 1 0 -1] [ 0 1 2] |
rescale_row(self, i, s)Replace i-th row of self by s times i-th row of self. |
restrict(self, V, check=False)Returns the matrix that defines the action of self on the invariant subspace V. This function returns an nxn matrix, where V has dimension n. It does *not* check that V is in fact invariant under self. |
stack(self, other)Return the augmented matrix self on top of other: [ self ] [ other ] |
str_latex(self, hfill=False)Print a latex matrix representation of self. For example, if self is [1,2;3,4], the following latex is generated: \left(egin{array}1&2\3&4 \end{array} ight) |
str_sparse_latex(self, variable='x')Return a latex string that represents this matrix as a sparse matrix. The rows are printed as sums sum a_i x_i, where x is the variable. |
submatrix_from_columns(self, columns)Return the submatrix of self of columns col[i] for i in the list of columns. |
submatrix_from_rows(self, rows)Return the submatrix of self of rows row[i] for i in the list of rows. |
swap_columns(self, c1, c2)Swap columns c1 and c2 of self. |
swap_rows(self, r1, r2)Swap rows r1 and r2 of self. |
trace(self)Return the trace of self, which is the sum of the diagonal entries of self. INPUT: self -- a square matrix OUTPUT: element of the base ring of self |
transpose(self)Returns the transpose of self, without changing self. EXAMPLES: We create a matrix, compute its transpose, and note that the original matrix is not changed.>>> from matrix_space import MatrixSpace >>> from sage.rings.rings import RationalField >>> M = MatrixSpace(RationalField(), 2) >>> A = M([1,2,3,4]) >>> B = A.transpose() >>> print B [1 3] [2 4] >>> print A [1 2] [3 4] |
vector_matrix_multiply(self, v)Returns the vector times matrix product. INPUT: matrix -- an element A of a MatrixSpace vector -- an element v of a VectorSpace OUTPUT: The the vector times matrix product v*A. EXAMPLES: >>> from matrix_space import MatrixSpace >>> from vector_space import VectorSpace >>> from sage.rings.rings import RationalField >>> MS = MatrixSpace(RationalField(), 2,2) >>> B = MS.matrix([1,2,1,2]) >>> V = VectorSpace(RationalField(), 2) >>> v = V.vector([1,2]) >>> B.vector_matrix_multiply(v) # computes v*B (3 6) >>> Bt = B.transpose() >>> Bt.vector_matrix_multiply(v) # computes B*v (5 5) |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Jun 20 15:43:22 2005 | http://epydoc.sf.net |