Skip to content

A jit puzzle on how to tell that the size of arrays are actually known in the context of a set diff and union problem #6901

Answered by jakevdp
shailesh1729 asked this question in Q&A
Discussion options

You must be logged in to vote

Here's a version that might work for you, given the assumptions about the inputs

def extend_A_by_k_from_B(A, B, k):
  ind = jnp.argsort(jnp.in1d(B, A))[:k]
  return jnp.hstack((A, B[ind]))

It chooses the first k inputs of B that do not appear in A, and concatenates them to A

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shailesh1729
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants