parent) |
add_multiple_of_column,
add_multiple_of_row,
augment,
base_ring,
block_sum,
change_ring,
charpoly,
column_space,
columns,
commutator,
copy,
decompose,
decompose_subspace,
denominator,
dense_matrix,
dense_row,
det,
determinant,
dict,
echelon_form,
entries,
fcp,
get,
height,
hermite_form,
hessenberg_form,
image,
is_dense,
is_invertible,
is_matrix,
is_sparse,
is_square,
iterates,
kernel,
latex,
linalg_matrix,
linear_combination_of_rows,
list,
matrix_space,
maxspin,
ncols,
new_matrix,
nonpivots,
nonzero_positions,
nonzero_positions_in_column,
nonzero_positions_in_row,
nrows,
nullity,
parent,
pari,
pivots,
rank,
rational_decomposition,
rational_reconstruction,
rescale_row,
restrict,
row,
row_space,
rows,
set,
smith_normal_form,
sparse_columns,
sparse_matrix,
sparse_rows,
stack,
str_latex,
str_sparse_latex,
submatrix_from_columns,
submatrix_from_rows,
swap_columns,
swap_rows,
trace,
transpose,
vector_matrix_multiply,
weidemann
These methods are defined as follows:
i, j, s) |
Replace column i by s times column j.
i, j, s) |
Replace row i by s times row j.
other) |
Return the augmented matrix of the form [self | other].
) |
other) |
Return the block matrix that has self and other on the diagonal: [self | 0 ] [ 0 | other ]
ring) |
) |
Return the characteristic polynomial of this matrix.
) |
) |
Returns the list of columns of self, as vectors.
sage: A = MatrixSpace(RationalField(), 2,3) (xrange(6)) sage: A [0 1 2] [3 4 5] sage: A.columns() [(0 3), (1 4), (2 5)]
other) |
) |
[is_diagonalizable=False]) |
Returns the decomposition of the vector space under the right action of this matrix.
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
, 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)) =
.
OUTPUT: list - list of Vector Spaces
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.
) |
) |
If this matrix is sparse, return a dense matrix with the same entries. If this matrix is dense, return this matrix (not a copy).
NOTE: The definition of "dense" and "sparse" in SAGE have nothing to do with the number of nonzero entries. Sparse and dense are properties of the underlying representation of the matrix.
sage: A = MatrixSpace(QQ,2, sparse=True)([1,2,0,1]) sage: A.is_sparse() True sage: B = A.dense_matrix() sage: B.is_sparse() False sage: A*B [1 4] [0 1] sage: A.parent() Full MatrixSpace of 2 by 2 sparse matrices over Rational Field sage: B.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: (A*B).parent() Full MatrixSpace of 2 by 2 sparse matrices over Rational Field sage: (B*A).parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field
n) |
) |
) |
) |
) |
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.
sage: from sage.linalg.matrix_space import MatrixSpace sage: from sage.rings.rings import RationalField sage: MS = MatrixSpace(RationalField(),2,3) sage: C = MS.matrix([1,2,3,4,5,6]) sage: C.rank() 2 sage: C.nullity() 1 sage: C.echelon_form() [ 1 0 -1] [ 0 1 2]
) |
This must be defined in the derived class. It is the underlying representation of elements, which may be a list or dict or something else.
) |
Return the factorization of the characteristic polynomial of self.
ij) |
Entry access, but possibly without bounds checking (for efficiency). USAGE: A[i, j] - the i,j of A, and A[i] - the i-th row of A.
) |
) |
) |
Compute and return the Hessenberg form of self. ALGORITHM: See Henri Cohen's book.
) |
) |
) |
) |
) |
) |
v, n) |
Let A be this matrix. Return a list consisting of
) |
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.
) |
) |
v) |
) |
[nrows=None], [ncols=None], [sparse=None]) |
v) |
Computes the largest integer n such that the list of vectors
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.
) |
[nrows=True], [ncols=True], [entries=0], [coerce_entries=None], [copy=None]) |
Create a matrix in the parent of this space with the given number of rows, columns, etc.
WARNING: This function called with no arguments returns the 0 matrix by default, not the matrix 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
) |
Returns the set of pairs (i,j) such that self[i,j] != 0.
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.
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.
) |
) |
) |
) |
) |
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
) |
) |
) |
i, s) |
Replace i-th row of self by s times i-th row of 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.
i) |
) |
) |
ij, x) |
) |
) |
) |
If this matrix is dense, return a sparse matrix with the same entries. If this matrix is sparse, return this matrix (not a copy).
NOTE: The definition of "dense" and "sparse" in SAGE have nothing to do with the number of nonzero entries. Sparse and dense are properties of the underlying representation of the matrix.
sage: A = MatrixSpace(QQ,2, sparse=False)([1,2,0,1]) sage: A.is_sparse() False sage: B = A.sparse_matrix() sage: B.is_sparse() True sage: A [1 2] [0 1] sage: B [1 2] [0 1] sage: A*B [1 4] [0 1] sage: A.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: B.parent() Full MatrixSpace of 2 by 2 sparse matrices over Rational Field sage: (A*B).parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: (B*A).parent() Full MatrixSpace of 2 by 2 sparse matrices over Rational Field
) |
other) |
Return the augmented matrix self on top of other: [ self ] [ other ]
[hfill=False]) |
Print a latex matrix representation of self. For example, if self is [1,2;3,4], the following latex is generated:
\left(\begin{array}1\&2\\3\&4 \end{array}\right)
[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.
columns) |
Return the submatrix of self of columns col[i] for i in the list of columns.
rows) |
Return the submatrix of self of rows row[i] for i in the list of rows.
c1, c2) |
Swap columns c1 and c2 of self.
r1, r2) |
Swap rows r1 and r2 of 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
) |
Returns the transpose of self, without changing self.
We create a matrix, compute its transpose, and note that the original matrix is not changed.
sage: M = MatrixSpace(RationalField(), 2) sage: A = M([1,2,3,4]) sage: B = A.transpose() sage: print B [1 3] [2 4] sage: print A [1 2] [3 4]
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.
sage: MS = MatrixSpace(RationalField(), 2,2) sage: B = MS.matrix([1,2,1,2]) sage: V = VectorSpace(RationalField(), 2) sage: v = V.vector([1,2]) sage: B.vector_matrix_multiply(v) # computes v*B (3 6) sage: Bt = B.transpose() sage: Bt.vector_matrix_multiply(v) # computes B*v (5 5)
i, [t=0]) |
Application of Weiedemann's algorithm to the i-th standard basis vector.
If the optimal parameter t is nonzero, use only the first t linear recurrence relations.
Instances of class Matrix also have the following special methods:
) |
right) |
right) |
right) |
ij) |
USAGE: A[i, j] - the i,j of A, and A[i] - the i-th row of A.
) |
p) |
right) |
) |
) |
n) |
sage: MS = MatrixSpace(RationalField(), 3, 3) sage: A = MS([0, 0, 1, 1, 0, '-2/11', 0, 1, '-3/11']) sage: A * A**(-1) == 1 True sage: A**4 [ -3/11 -13/121 1436/1331] [ 127/121 -337/1331 -4445/14641] [ -13/121 1436/1331 -8015/14641]
right) |
left) |
ij, x) |
USAGE: A[i, j] = value - set the (i,j) entry of A A[i] = value - set the ith row of A
) |
right) |
See About this document... for information on suggesting changes.