Function initStateFromAmps

Source
pub unsafe extern "C" fn initStateFromAmps(
    qureg: Qureg,
    reals: *mut f64,
    imags: *mut f64,
)
Expand description

Initialise \p qureg by specifying all amplitudes. For density matrices, it is assumed the amplitudes have been flattened column-wise into the given arrays.

The real and imaginary components of the amplitudes are passed in separate arrays, \p reals and \p imags, each of which must have length qureg.numAmpsTotal. There is no automatic checking that the passed arrays are L2 normalised, so this can be used to prepare \p qureg in a non-physical state.

In distributed mode, this would require the complete state to fit in every node. To manually prepare a state for which all amplitudes cannot fit into a single node, use setAmps()

@see

  • setAmps()

@ingroup init @param[in,out] qureg the ::Qureg to overwrite @param[in] reals array of the real components of the new amplitudes @param[in] imags array of the imaginary components of the new amplitudes @throws segmentation-fault

  • if either \p reals or \p imags have fewer than qureg.numAmpsTotal elements @author Tyson Jones