Categories
Misc

Self cross a tensor and apply a mapping on each cell

Let’s say I have a tensor t=[1, 3, 1] I want to self-cross it to produce a 3×3 matrix but each element of the matrix should be:

  • 1 if t[row] > t[col]
  • -1 if t[row] < t[col]
  • 0 otherwise.

In this case the output should be

[0 -1 0

1 0 1

0 -1 0]

submitted by /u/Jolly_Bus349
[visit reddit] [comments]

Leave a Reply

Your email address will not be published. Required fields are marked *