Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Fundamental operations of dense matrices. The dense matrix is stored as a list of lists
"""
""" Returns the trace of a matrix.
Examples ========
>>> from sympy.matrices.densetools import trace, eye >>> from sympy import ZZ >>> a = [ ... [ZZ(3), ZZ(7), ZZ(4)], ... [ZZ(2), ZZ(4), ZZ(5)], ... [ZZ(6), ZZ(2), ZZ(3)]] >>> b = eye(4, ZZ) >>> trace(a, ZZ) 10 >>> trace(b, ZZ) 4
"""
""" Returns the transpose of a matrix
Examples ========
>>> from sympy.matrices.densetools import transpose >>> from sympy import ZZ >>> a = [ ... [ZZ(3), ZZ(7), ZZ(4)], ... [ZZ(2), ZZ(4), ZZ(5)], ... [ZZ(6), ZZ(2), ZZ(3)]] >>> transpose(a, ZZ) [[3, 2, 6], [7, 4, 2], [4, 5, 3]]
"""
""" Returns the conjugate of a matrix row-wise.
Examples ========
>>> from sympy.matrices.densetools import conjugate >>> from sympy import ZZ >>> a = [ ... [ZZ(3), ZZ(2), ZZ(6)], ... [ZZ(7), ZZ(4), ZZ(2)], ... [ZZ(4), ZZ(5), ZZ(3)]] >>> conjugate(a, ZZ) [[3, 2, 6], [7, 4, 2], [4, 5, 3]]
See Also ========
conjugate_row """
""" Returns the conjugate of a row element-wise
Examples ========
>>> from sympy.matrices.densetools import conjugate_row >>> from sympy import ZZ >>> a = [ZZ(3), ZZ(2), ZZ(6)] >>> conjugate_row(a, ZZ) [3, 2, 6] """
""" Returns the conjugate-transpose of a matrix
Examples ========
>>> from sympy import ZZ >>> from sympy.matrices.densetools import conjugate_transpose >>> a = [ ... [ZZ(3), ZZ(7), ZZ(4)], ... [ZZ(2), ZZ(4), ZZ(5)], ... [ZZ(6), ZZ(2), ZZ(3)]] >>> conjugate_transpose(a, ZZ) [[3, 2, 6], [7, 4, 2], [4, 5, 3]] """
""" Augments a matrix and a column.
Examples ========
>>> from sympy.matrices.densetools import augment >>> from sympy import ZZ >>> a = [ ... [ZZ(3), ZZ(7), ZZ(4)], ... [ZZ(2), ZZ(4), ZZ(5)], ... [ZZ(6), ZZ(2), ZZ(3)]] >>> b = [ ... [ZZ(4)], ... [ZZ(5)], ... [ZZ(6)]] >>> augment(a, b, ZZ) [[3, 7, 4, 4], [2, 4, 5, 5], [6, 2, 3, 6]] """
""" Returns an identity matrix of size n.
Examples ========
>>> from sympy.matrices.densetools import eye >>> from sympy import ZZ >>> eye(3, ZZ) [[1, 0, 0], [0, 1, 0], [0, 0, 1]] """ else:
""" Returns the ith row of a matrix
Examples ========
>>> from sympy.matrices.densetools import row >>> from sympy import ZZ >>> a = [ ... [ZZ(3), ZZ(7), ZZ(4)], ... [ZZ(2), ZZ(4), ZZ(5)], ... [ZZ(6), ZZ(2), ZZ(3)]] >>> row(a, 2) [6, 2, 3] """ return matlist[i]
""" Returns the ith column of a matrix Note: Currently very expensive
Examples ========
>>> from sympy.matrices.densetools import col >>> from sympy import ZZ >>> a = [ ... [ZZ(3), ZZ(7), ZZ(4)], ... [ZZ(2), ZZ(4), ZZ(5)], ... [ZZ(6), ZZ(2), ZZ(3)]] >>> col(a, 1) [[7], [4], [2]] """
""" Returns the matrix with index1 row and index2 row swapped """ matlist[index1], matlist[index2] = matlist[index2], matlist[index1] return matlist
""" Multiplies index row with k """
""" Adds the index1 row with index2 row which in turn is multiplied by k """
""" Checks whether matrix is hermitian
Examples ========
>>> from sympy.matrices.densetools import isHermitian >>> from sympy import QQ >>> a = [ ... [QQ(2,1), QQ(-1,1), QQ(-1,1)], ... [QQ(0,1), QQ(4,1), QQ(-1,1)], ... [QQ(0,1), QQ(0,1), QQ(3,1)]] >>> isHermitian(a, QQ) False """ return conjugate_transpose(matlist, K) == matlist |