matrix in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seetha
    New Member
    • Oct 2011
    • 1

    matrix in python

    scalar matrix means what?how can use it?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    A matrix is a rectangular array of elements arranged in rows and columns. A scalar matrix is "a diagonal matrix in which all of the diagonal elements are equal" per http://www.thefreedictionary.com. A diagonal matrix is "a square matrix with all elements not on the main diagonal equal to zero". Its effect on a vector is scalar multiplication (from Wikipedia).
    Code:
    >>> m = Matrix(3,3)
    >>> m
    Matrix(3, 3)
    >>> m.show()
    0 0 0
    0 0 0
    0 0 0
    >>> for i in range(3):
    ... 	m[(i,i)]=1
    ... 	
    >>> m.show()
    1 0 0
    0 1 0
    0 0 1
    >>>

    Comment

    Working...