- #1
schniefen
- 178
- 4
- TL;DR Summary
- Is it possible to initialize a 4D array with only elements on one side of the diagonal?
Given the parameters ##n## and ##m##, I'd like to initialize a ##n \times n ## 4D array where each entry is an ##m \times m ## matrix, and where each column of the matrix is an array of type numpy.linspace(0,1,m). Furthermore, I'd only like to have entries on the diagonal and above it, or only on the diagonal and below it. Is there a possible one-liner for this? The reason for this peculiarly shaped array is that I only need half of the matrices in the full array, but at the same time I’d like to keep the structure the array gives, i.e. the matrices on the second row belong to a “group” and this “group” consists of exactly as many matrices there are in the row of the array made up of only matrices on the diagonal and above or below it. The same goes for the columns.