I have a tensor, u, of rank one, meaning that I have a matrix whose elements are themselves matrices. I would like to select, and make a list of, only those sub-matrices whose indices comply with the condition j < k
, i.e. the row index is always smaller than the column index.
This effectively corresponds to strictly upper-triangularising the tensor. Once I select the correct sub-matrices, I would like them to appear in a list sorted row by row. I.e., if each sub-matrix is called aXX
, where XX
are the row and column indices, and the tensor has dimensions NxN
, then I want the list to look like this:
a12, a13, a14 ..., a1N, a23, a24, ..., a2N, a34, ..., a3N, ..., a(N-1)N.
I have tried using UpperTriangularize[]
to no avail. I suspect the answer must be using Select[]
or Pick[]
, but I am unsure of how to implement the condition based on testing the indices of the tensor. Any ideas would be much appreciated.
Here is my code which generates u. NLevel
is the same as N
that I mentioned above, and can be varied with each run of the programme.
P = Table[SparseArray[{{j, k} -> 1}, {NLevel, NLevel}], {j, NLevel}, {k, NLevel}]
u = Table[P[[1, j, k]] + P[[1, k, j]], {j, NLevel}, {k, NLevel}]