Dense matrices over the Real Double Field using NumPy

EXAMPLES:

sage: b=Mat(RDF,2,3).basis()
sage: b[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()
[]

TESTS:

sage: a = matrix(RDF,2,range(4), sparse=False)
sage: loads(dumps(a)) == a
True
sage: MatrixSpace(RDF,0,0).zero_matrix().inverse()
[]

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

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
[-2.0  1.0]
[ 1.5 -0.5]

To compute eigenvalues the use the functions left_eigenvectors or right_eigenvectors

sage: p,e = m.right_eigenvectors()

the result of eigen is a pair (p,e), where p is a list of eigenvalues and the 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_left(b)
(-4.0, 4.5)

See the commands qr, lu, and svd for QR, LU, and singular value decomposition.

static __new__()
T.__new__(S, ...) -> a new object with type S, a subtype of T
_cholesky_decomposition_()

Return the Cholesky factorization of this matrix.

The input matrix must be symmetric and positive definite or ValueError exception will be raised.

EXAMPLES:

sage: M = MatrixSpace(RDF,5) sage: r = matrix(RDF,[[ 0., 0., 0., 0., 1.],[ 1., 1., 1., 1., 1.],[ 16., 8., 4., 2., 1.],[ 81., 27., 9., 3., 1.],[ 256., 64., 16., 4., 1.]])

sage: m = r*M.identity_matrix()*r.transpose() sage: L = m.cholesky_decomposition() # indirect doctest sage: L*L.transpose() [ 1.0 1.0 1.0 1.0 1.0] [ 1.0 5.0 31.0 121.0 341.0] [ 1.0 31.0 341.0 1555.0 4681.0] [ 1.0 121.0 1555.0 7381.0 22621.0] [ 1.0 341.0 4681.0 22621.0 69905.0]

Previous topic

Dense matrices over the rational field.

Next topic

Dense matrices over the Complex Double Field using NumPy

This Page