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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<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.2[0 0 0 0 4]sage: matrix_method(foo_matrix, name=’bar’)sage: matrix.bar(3)[0 0 0][0 1 0][0 0 2]sage.matrix.constructor.ncols_from_dict(d)Given a dictionary that defines a sparse matrix, return the number <strong>of</strong> columns that matrix should have.This is for internal use by the matrix function.INPUT:•d - dictOUTPUT:integerEXAMPLES:sage: sage.matrix.constructor.ncols_from_dict({})0Here the answer is 301 not 300, since there is a 0-th row.sage: sage.matrix.constructor.ncols_from_dict({(4,300):10})301sage.matrix.constructor.nrows_from_dict(d)Given a dictionary that defines a sparse matrix, return the number <strong>of</strong> rows that matrix should have.This is for internal use by the matrix function.INPUT:•d - dictOUTPUT:integerEXAMPLES:sage: sage.matrix.constructor.nrows_from_dict({})0Here the answer is 301 not 300, since there is a 0-th row.:: sage: sage.matrix.constructor.nrows_from_dict({(300,4):10}) 301sage.matrix.constructor.ones_matrix(ring, nrows=None, ncols=None, sparse=False)This function is available as ones_matrix(...) <strong>and</strong> matrix.ones(...).Return a matrix with all entries equal to 1.CALL FORMATS:In each case, the optional keyword sparse can be used.1.ones_matrix(ring, nrows, ncols)2.ones_matrix(ring, nrows)3.ones_matrix(nrows, ncols)39

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

Saved successfully!

Ooh no, something went wrong!