qml.math.set_index

set_index(array, idx, val, like=None)[source]

Set the value at a specified index in an array. Calls array[idx]=val and returns the updated array unless JAX or Tensorflow.

Parameters:
  • array (tensor_like) – array to be modified

  • idx (int, tuple) – index to modify

  • val (int, float) – value to set

Returns:

a new copy of the array with the specified index updated to val.

Whether the original array is modified is interface-dependent.