Shortcuts

# qiskit.quantum_info.ScalarOp¶

class ScalarOp(dims, coeff=1)[소스]

Scalar identity operator class.

This is a symbolic representation of an scalar identity operator on multiple subsystems. It may be used to initialize a symbolic scalar multiplication of an identity and then be implicitly converted to other kinds of operator subclasses by using the compose(), dot(), tensor(), expand() methods.

Initialize an operator object.

매개변수
• dims (int or tuple) – subsystem dimensions.

• coeff (Number) – scalar coefficient for the identity operator (Default: 1).

예외

QiskitError – If the optional coefficient is invalid.

__init__(dims, coeff=1)[소스]

Initialize an operator object.

매개변수
• dims (int or tuple) – subsystem dimensions.

• coeff (Number) – scalar coefficient for the identity operator (Default: 1).

예외

QiskitError – If the optional coefficient is invalid.

Methods

 __init__(dims[, coeff]) Initialize an operator object. add(other) Return the linear operator self + other. Return the adjoint of the operator. compose(other[, qargs, front]) Return the composed operator. Return the conjugate of the operator. Make a deep copy of current operator. dot(other[, qargs]) Return the right multiplied operator self * other. expand(other) Return the tensor product operator other ⊗ self. input_dims([qargs]) Return tuple of input dimension for specified subsystems. is_unitary([atol, rtol]) Return True if operator is a unitary matrix. multiply(other) Return the linear operator other * self. output_dims([qargs]) Return tuple of output dimension for specified subsystems. Return the power of the ScalarOp. reshape([input_dims, output_dims]) Return a shallow copy with reshaped input and output subsystem dimensions. set_atol(value) Set the class default absolute tolerance parameter for float comparisons. set_rtol(value) Set the class default relative tolerance parameter for float comparisons. subtract(other) Return the linear operator self - other. tensor(other) Return the tensor product operator self ⊗ other. Convert to a Numpy matrix. Convert to an Operator object. Return the transpose of the operator.

Attributes

 atol The default absolute tolerance parameter for float comparisons. coeff Return the coefficient dim Return tuple (input_shape, output_shape). num_qubits Return the number of qubits if a N-qubit operator or None otherwise. qargs Return the qargs for the operator. rtol The relative tolerance parameter for float comparisons.
add(other)

Return the linear operator self + other.

DEPRECATED: use operator + other instead.

매개변수

other (BaseOperator) – an operator object.

반환값

the operator self + other.

반환 형식

BaseOperator

adjoint()

Return the adjoint of the operator.

property atol

The default absolute tolerance parameter for float comparisons.

property coeff

Return the coefficient

compose(other, qargs=None, front=False)[소스]

Return the composed operator.

매개변수
• other (BaseOperator) – an operator object.

• qargs (list or None) – a list of subsystem positions to apply other on. If None apply on all subsystems [default: None].

• front (bool) – If True compose using right operator multiplication, instead of left multiplication [default: False].

반환값

The operator self @ other.

반환 형식

BaseOperator

예외

QiskitError – if other has incompatible dimensions for specified subsystems.

Composition (@) is defined as left matrix multiplication for matrix operators. That is that A @ B is equal to B * A. Setting front=True returns right matrix multiplication A * B and is equivalent to the dot() method.

conjugate()[소스]

Return the conjugate of the operator.

copy()

Make a deep copy of current operator.

property dim

Return tuple (input_shape, output_shape).

dot(other, qargs=None)

Return the right multiplied operator self * other.

매개변수
• other (BaseOperator) – an operator object.

• qargs (list or None) – a list of subsystem positions to apply other on. If None apply on all subsystems [default: None].

반환값

The operator self * other.

반환 형식

BaseOperator

예외

QiskitError – if other cannot be converted to an operator, or has incompatible dimensions for specified subsystems.

expand(other)[소스]

Return the tensor product operator other ⊗ self.

매개변수

other (BaseOperator) – an operator object.

반환값

if other is an ScalarOp. BaseOperator: if other is not an ScalarOp.

반환 형식

ScalarOp

input_dims(qargs=None)

Return tuple of input dimension for specified subsystems.

is_unitary(atol=None, rtol=None)[소스]

Return True if operator is a unitary matrix.

multiply(other)

Return the linear operator other * self.

DEPRECATED: use other * operator instead.

매개변수

other (complex) – a complex number.

반환값

the linear operator other * self.

반환 형식

BaseOperator

예외

NotImplementedError – if subclass does not support multiplication.

property num_qubits

Return the number of qubits if a N-qubit operator or None otherwise.

output_dims(qargs=None)

Return tuple of output dimension for specified subsystems.

power(n)[소스]

Return the power of the ScalarOp.

매개변수

n (Number) – the exponent for the scalar op.

반환값

the coeff ** n ScalarOp.

반환 형식

ScalarOp

예외

QiskitError – if the input and output dimensions of the operator are not equal, or the power is not a positive integer.

property qargs

Return the qargs for the operator.

reshape(input_dims=None, output_dims=None)

Return a shallow copy with reshaped input and output subsystem dimensions.

Arg:
input_dims (None or tuple): new subsystem input dimensions.

If None the original input dims will be preserved [Default: None].

output_dims (None or tuple): new subsystem output dimensions.

If None the original output dims will be preserved [Default: None].

반환값

returns self with reshaped input and output dimensions.

반환 형식

BaseOperator

예외

QiskitError – if combined size of all subsystem input dimension or subsystem output dimensions is not constant.

property rtol

The relative tolerance parameter for float comparisons.

classmethod set_atol(value)

Set the class default absolute tolerance parameter for float comparisons.

DEPRECATED: use operator.atol = value instead

classmethod set_rtol(value)

Set the class default relative tolerance parameter for float comparisons.

DEPRECATED: use operator.rtol = value instead

subtract(other)

Return the linear operator self - other.

DEPRECATED: use operator - other instead.

매개변수

other (BaseOperator) – an operator object.

반환값

the operator self - other.

반환 형식

BaseOperator

tensor(other)[소스]

Return the tensor product operator self ⊗ other.

매개변수

other (BaseOperator) – an operator object.

반환값

if other is an ScalarOp. BaseOperator: if other is not an ScalarOp.

반환 형식

ScalarOp

to_matrix()[소스]

Convert to a Numpy matrix.

to_operator()[소스]

Convert to an Operator object.

transpose()[소스]

Return the transpose of the operator.