By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,171 Members | 809 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,171 IT Pros & Developers. It's quick & easy.

matrix in python

P: 1
scalar matrix means what?how can use it?
Oct 7 '11 #1
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
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).
Expand|Select|Wrap|Line Numbers
  1. >>> m = Matrix(3,3)
  2. >>> m
  3. Matrix(3, 3)
  4. >>> m.show()
  5. 0 0 0
  6. 0 0 0
  7. 0 0 0
  8. >>> for i in range(3):
  9. ...     m[(i,i)]=1
  10. ...     
  11. >>> m.show()
  12. 1 0 0
  13. 0 1 0
  14. 0 0 1
  15. >>> 
Oct 7 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.