12.07.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.2Full MatrixSpace <strong>of</strong> 3 by 3 dense matrices over Real Double Fieldsage: n=numpy.array([[1,2,3],[4,5,6],[7,8,9]],’complex64’)sage: m=matrix(n); m; m.parent()[1.0 2.0 3.0][4.0 5.0 6.0][7.0 8.0 9.0]Full MatrixSpace <strong>of</strong> 3 by 3 dense matrices over Complex Double Fieldsage: n=numpy.array([[1,2,3],[4,5,6],[7,8,9]],’complex128’)sage: m=matrix(n); m; m.parent()[1.0 2.0 3.0][4.0 5.0 6.0][7.0 8.0 9.0]Full MatrixSpace <strong>of</strong> 3 by 3 dense matrices over Complex Double Fieldsage: a = matrix([[1,2],[3,4]])sage: b = matrix(a.numpy()); b[1 2][3 4]sage: a == bTruesage: c = matrix(a.numpy(’float32’)); c[1.0 2.0][3.0 4.0]sage: matrix(numpy.array([[5]]))[5]sage: v = vector(ZZ, [1, 10, 100])sage: m=matrix(ZZ[’x’], v); m; m.parent()[ 1 10 100]Full MatrixSpace <strong>of</strong> 1 by 3 dense matrices over Univariate Polynomial Ring in x over Integer Ringsage: matrix(ZZ, 10, 10, range(100)).parent()Full MatrixSpace <strong>of</strong> 10 by 10 dense matrices over Integer Ringsage: m = matrix(GF(7), [[1/3,2/3,1/2], [3/4,4/5,7]]); m; m.parent()[5 3 4][6 5 0]Full MatrixSpace <strong>of</strong> 2 by 3 dense matrices over Finite Field <strong>of</strong> size 7sage: m = matrix([[1,2,3], [RDF(2), CDF(1,2), 3]]); m; m.parent()[ 1.0 2.0 3.0][ 2.0 1.0 + 2.0*I 3.0]Full MatrixSpace <strong>of</strong> 2 by 3 dense matrices over Complex Double Fieldsage: m=matrix(3,3,1/2); m; m.parent()[1/2 0 0][ 0 1/2 0][ 0 0 1/2]Full MatrixSpace <strong>of</strong> 3 by 3 dense matrices over Rational Fieldsage: matrix([[1],[2,3]])Traceback (most recent call last):...ValueError: List <strong>of</strong> rows is not valid (rows are wrong types or lengths)sage: matrix([[1],2])Traceback (most recent call last):...ValueError: List <strong>of</strong> rows is not valid (rows are wrong types or lengths)sage: matrix(vector(RR,[1,2,3])).parent()Full MatrixSpace <strong>of</strong> 1 by 3 dense matrices over Real Field with 53 bits <strong>of</strong> precisionsage: matrix(ZZ, [[0] for i in range(10^5)]).is_zero() # see #10158TrueAUTHORS:•??: Initial implementation21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!