parent) |
add_multiple_of_column,
add_multiple_of_row,
augment,
base_ring,
block_sum,
change_ring,
charpoly,
column_space,
columns,
commutator,
copy,
decomposition,
decomposition_of_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,
kernel_on,
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,
restrict_domain,
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
Further documentation:
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 ]
) |
Return the characteristic polynomial of this matrix.
) |
Return the vector space spanned by the columns 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) |
Return the commutator self*other - other*self.
) |
Return a copy of this matrix. Changing the entries of the copy will not change the entries of this matrix.
[is_diagonalizable=False], [dual=False]) |
Returns the decomposition of the vector space under the right action of this matrix, along with whether this matrix acts irreducibly on each factor. The factors are guaranteed to be sorted in the same way as the corresponding factors of the characteristic polynomial.
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)) =
.
If dual is True, also returns the corresponding decomposition of V under the action of the transpose of A. The factors are guarenteed to correspond.
OUTPUT: list - list of pairs (V,t), where V is a vector spaces and t is a bool, and t is True exactly when the charpoly of self on V is irreducible.
(optional) list - list of pairs (W,t), where W is a vector space and t is a bool, and t is True exactly when the charpoly of the transpose of self on W is irreducible.
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
) |
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
) |
Return the kernel of this matrix, as a vector space.
If the base ring is Z, returns an LLL-reduced basis for the kernel. The reason we return a basis instead of a Z module is that we haven't implemented Z-modules yet. When Z-modules have been implemented, this function will return a Z-module.
ALGORITHM: Elementary row ops don't change kernel, since they are just right multiplication by an invertible matrix, so we instead compute kernel of the column echelon form. More precisely, there is a basis vector of the kernel that corresponds to each non-pivot row. That vector has a 1 at the non-pivot row, 0's at all other non-pivot rows, and for each pivot row, the negative of the entry at the non-pivot row in the column with that pivot element.
Note: Since we view matrices as acting on the right, but have functions for reduced *row* echelon forms, we instea compute the reduced row echelon form of the transpose of this matrix, which is the reduced column echelon form.
We compute the 2-dimensional kernel of a matrix over a cyclotomic field:
sage: K = CyclotomicField(12); a=K.gen() sage: M = MatrixSpace(K,4,2)([1,-1, 0,-2, 0,-a**2-1, 0,a**2-1]) sage: M [ 1 -1] [ 0 -2] [ 0 -zeta_12^2 - 1] [ 0 zeta_12^2 - 1] sage: M.kernel() Vector space of degree 4, dimension 2 over Cyclotomic Field of order 12 and degree 4 Basis matrix: [ 0 1 0 -2*zeta_12^2] [ 0 0 1 -2*zeta_12^2 + 1]
We compute an LLL reduced basis for the kernel.
sage: M = MatrixSpace(ZZ,4,2)(range(8)) sage: M.kernel() [(1, -1, -1, 1), (0, -1, 2, -1)]
V, [poly=False], [check=None]) |
Return the kernel of self restricted to the invariant subspace V. The result is a vector subspace of V, which is also a subspace of the ambient space.
INPUT: V -- vector subspace check -- (optional) default: False poly -- (optional) default: None; if not None, compute instead the kernel of poly(self) on V. OUTPUT: a subspace
WARNING: This function does not check that V is in fact invariant under self, unless check is True (not the default).
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. If V is the ambient space, returns self (not a copy of self).
INPUT: V -- vector subspace check -- (optional) default: False; if True but V is not invariant, raise an ArithmeticError exception. OUTPUT: a matrix
WARNING: This function returns an nxn matrix, where V has dimension n. It does not check that V is in fact invariant under self, unless check is True (not the default).
sage: V = VectorSpace(QQ,3) sage: M = MatrixSpace(QQ,3) sage: A = M([1,2,0, 3,4,0, 0,0,0]) sage: W = V.subspace([[1,0,0], [0,1,0]]) sage: A.restrict(W) [1 2] [3 4] sage: A.restrict(W, check=True) [1 2] [3 4]
We illustrate the warning about invariance not being checked by default, by giving a non-invariant subspace. With the default check=False this function returns the 'restriction' matrix, which is meaningless as check=True reveals.
sage: W2 = V.subspace([[1,0,0], [0,1,1]]) sage: A.restrict(W2) [1 2] [3 4] sage: A.restrict(W2, check=True) Traceback (most recent call last): ... ArithmeticError: subspace is not invariant under matrix
V) |
Compute the matrix relative to the basis for V on the domain obtained by restricting self to V, but not changing the codomain of the matrix. This is the matrix whose rows are the images of the basis for V.
INPUT: V -- vector space (subspace of ambient space on which self acts)
SEE ALSO: restrict()
sage: V = VectorSpace(QQ,3) sage: M = MatrixSpace(QQ,3) sage: A = M([1,2,0, 3,4,0, 0,0,0]) sage: W = V.subspace([[1,0,0], [1,2,3]]) sage: A.restrict_domain(W) [1 2 0] [3 4 0] sage: W2 = V.subspace_with_basis([[1,0,0], [1,2,3]]) sage: A.restrict_domain(W2) [ 1 2 0] [ 7 10 0]
) |
Return the space spanned by the rows of self.
) |
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 functions:
__abs__,
__add__,
__cmp__,
__div__,
__getitem__,
__invert__,
__mod__,
__mul__,
__neg__,
__pos__,
__pow__,
__radd__,
__rmul__,
__setitem__,
__str__,
__sub__
Further documentation:
ij) |
USAGE: A[i, j] - the i,j of A, and A[i] - the i-th row of A.
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]
ij, x) |
USAGE: A[i, j] = value - set the (i,j) entry of A A[i] = value - set the ith row of A
See About this document... for information on suggesting changes.