Dense matrices over the Real Double Field using NumPy#

EXAMPLES:

sage: b = Mat(RDF,2,3).basis()
sage: b[0,0]
[1.0 0.0 0.0]
[0.0 0.0 0.0]

We deal with the case of zero rows or zero columns:

sage: m = MatrixSpace(RDF,0,3)
sage: m.zero_matrix()
[]

AUTHORS:

  • Jason Grout (2008-09): switch to NumPy backend, factored out the Matrix_double_dense class

  • Josh Kantor

  • William Stein: many bug fixes and touch ups.

class sage.matrix.matrix_real_double_dense.Matrix_real_double_dense#

Bases: Matrix_double_dense

Class that implements matrices over the real double field. These are supposed to be fast matrix operations using C doubles. Most operations are implemented using numpy which will call the underlying BLAS on the system.

EXAMPLES:

sage: m = Matrix(RDF, [[1,2],[3,4]])
sage: m**2
[ 7.0 10.0]
[15.0 22.0]
sage: n = m^(-1); n     # rel tol 1e-15
[-1.9999999999999996  0.9999999999999998]
[ 1.4999999999999998 -0.4999999999999999]

To compute eigenvalues, use the method left_eigenvectors() or right_eigenvectors().

sage: p,e = m.right_eigenvectors()

The result is a pair (p,e), where p is a diagonal matrix of eigenvalues and e is a matrix whose columns are the eigenvectors.

To solve a linear system \(Ax = b\) where A = [[1,2],[3,4]] and \(b = [5,6]\):

sage: b = vector(RDF,[5,6])
sage: m.solve_right(b)  # rel tol 1e-15
(-3.9999999999999987, 4.499999999999999)

See the methods QR(), LU(), and SVD() for QR, LU, and singular value decomposition.