Hi. I have the following problem. Suppose I have a tensor M of shape (N, 5) and a vector v of size (N).
I am looking for a vectorized solution that would tell me if the nth row of M contains the nth element of v. Example:
M = torch.tensor([
[0, 1, 2, 3, 4],
[7, 5, 3, 4, 8],
[0, 1, 9, 7, 5],
[1, 4, 7, 2, 5],
])
v = torch.tensor([0, 3, 2, 6])
then the function I am looking for should output something like the following
does_intersect(M, v) == torch.tensor([1, 1, 0, 0]) # or boolean indicators
I know that I can just iterate over the rows and check if v[n] in M[n]
but I want a vectorized solution.
One additional note, each row of M contains unique elements