ffsim.linalg.one_hot

ffsim.linalg.one_hot(shape, index, *, dtype=<class 'complex'>)[source]

Return an array of all zeros except for a one at a specified index.

Parameters:
  • shape (int | tuple[int, ...]) – The desired shape of the array.

  • index – The index at which to place a one.

Returns:

The one-hot vector.