# qml.s_prod¶

s_prod(scalar, operator, do_queue=True, id=None)[source]

Construct an operator which is the scalar product of the given scalar and operator provided.

Parameters
• scalar (float or complex) – the scale factor being multiplied to the operator.

• operator (Operator) – the operator which will get scaled.

Keyword Arguments
• do_queue (bool) – determines if the scalar product operator will be queued. Default is True.

• id (str or None) – id for the scalar product operator. Default is None.

Returns

The operator representing the scalar product.

Return type

SProd

Example

>>> sprod_op = s_prod(2.0, qml.PauliX(0))
>>> sprod_op
2.0*(PauliX(wires=[0]))
>>> sprod_op.matrix()
array([[ 0., 2.],
[ 2., 0.]])


Using PennyLane

Development

API