pub unsafe extern "C" fn setDiagonalOpElems(
op: DiagonalOp,
startInd: c_longlong,
real: *mut f64,
imag: *mut f64,
numElems: c_longlong,
)Expand description
Modifies a subset (starting at index \p startInd, and ending at index \p startInd + \p numElems) of the elements in ::DiagonalOp \p op with the given complex numbers (passed as \p real and \p imag components).
In GPU mode, this updates both the RAM (\p op.real and \p op.imag), and the persistent GPU memory.
In distributed mode, this function assumes the subset \p real and \p imag exist (at least) on the node containing the ultimately updated elements.\n For example, below is the correct way to modify the full 8 elements of \p op when split between 2 nodes.
DiagonalOp op = createDiagonalOp(3, env);
int numElems = 4;
qreal re[] = {1,2,3,4};
qreal im[] = {1,2,3,4};
setDiagonalOpElems(op, 0, re, im, numElems);
// modify re and im to the next set of elements
for (int i=0; i<4; i++) {
re[i] += 4;
im[i] += 4;
}
setDiagonalOpElems(op, 4, re, im, numElems);In this way, one can avoid a single node containing all new elements which might not fit. If more elements are passed than exist on an individual node, each node merely ignores the additional elements.
@ingroup type @param[in,out] op the ::DiagonalOp to modify @param[in] startInd the starting index (globally) of the subset of elements to modify @param[in] real the real components of the new elements @param[in] imag the imaginary components of the new elements @param[in] numElems the number of new elements (the length of \p real and \p imag) @throws invalidQuESTInputError()
- if \p op was not created
- if \p startInd is an invalid index (<0 or >=pow(2,
op.numQubits)) - if \p numElems is an invalid number of elements (<=0 or >pow(2,
op.numQubits)) - if there are fewer than \p numElems elements in \p op after \p startInd @throws segmentation-fault
- if either \p real or \p imag have fewer elements than \p numElems @author Tyson Jones