scalar matrix means what?how can use it?
matrix in python
Collapse
X
-
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