Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
diagonal matix
#1
Hi all, I want to create a 400x400 diagonal matrix with upper and lower cases. I can do it manually but it would take hours. The matix should look like this one:

[[ 4.1 -2.5 0. 0. 0. 0. 0. 0. 0. 0. ]
[-0.3 2.8 -2.5 0. 0. 0. 0. 0. 0. 0. ]
[ 0. -1.5 4. -2.5 0. 0. 0. 0. 0. 0. ]
[ 0. 0. -2.7 5.2 -2.5 0. 0. 0. 0. 0. ]
[ 0. 0. 0. -3.9 6.4 -2.5 0. 0. 0. 0. ]
[ 0. 0. 0. 0. -5.1 7.6 -2.5 0. 0. 0. ]
[ 0. 0. 0. 0. 0. -6.3 8.8 -2.5 0. 0. ]
[ 0. 0. 0. 0. 0. 0. -7.5 10. -2.5 0. ]
[ 0. 0. 0. 0. 0. 0. 0. -8.7 11.2 -2.5]
[ 0. 0. 0. 0. 0. 0. 0. 0. -9.9 12.4]]
Thank you in advance
Reply
#2
I'm not sure what you mean by "cases" here. Where do the values come from, as in what governs what the diagonal and off-diagonal elements of this matrix are? Can you use NumPy's facilities for array creation to help? Why do you need to create such a large matrix by hand anyway?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Ho can I make it so the dirt goes up instad of diagonal izmamonke 3 2,215 Jul-12-2021, 12:51 PM
Last Post: izmamonke
  4D array with only elements on one side of the diagonal schniefen 0 1,701 Dec-24-2020, 11:32 AM
Last Post: schniefen
  Numpy Play with Rows and Columns of a Matix quest 6 2,952 Nov-05-2020, 09:08 PM
Last Post: quest

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020