---
title: ScalarOp (v2.4)
description: API reference for qiskit.quantum_info.ScalarOp in qiskit v2.4
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/2.4/qiskit.quantum_info.ScalarOp
---

# ScalarOp

*class* `qiskit.quantum_info.ScalarOp(dims=None, coeff=1)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L29-L250)

Bases: `LinearOp`

Scalar identity operator class.

This is a symbolic representation of a 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()`](#qiskit.quantum_info.ScalarOp.compose "qiskit.quantum_info.ScalarOp.compose"), [`dot()`](#qiskit.quantum_info.ScalarOp.dot "qiskit.quantum_info.ScalarOp.dot"), [`tensor()`](#qiskit.quantum_info.ScalarOp.tensor "qiskit.quantum_info.ScalarOp.tensor"), [`expand()`](#qiskit.quantum_info.ScalarOp.expand "qiskit.quantum_info.ScalarOp.expand") methods.

Initialize an operator object.

**Parameters**

- **dims** ([*int*](https://docs.python.org/3/library/functions.html#int)  *or*[*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple)) – subsystem dimensions.
- **coeff** (*Number*) – scalar coefficient for the identity operator (Default: 1).

**Raises**

[**QiskitError**](/docs/api/qiskit/2.4/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – If the optional coefficient is invalid.

## Attributes

### atol

Default value: `1e-08`

### 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

Default value: `1e-05`

## Methods

### adjoint

`adjoint()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/mixins/adjoint.py#L42-L44)

Return the adjoint of the Operator.

**Return type**

[*Self*](https://docs.python.org/3/library/typing.html#typing.Self)

### compose

`compose(other, qargs=None, front=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L97-L132)

Return the operator composition with another ScalarOp.

**Parameters**

- **other** ([*ScalarOp*](#qiskit.quantum_info.ScalarOp "qiskit.quantum_info.ScalarOp")) – a ScalarOp object.
- **qargs** ([*list*](https://docs.python.org/3/library/stdtypes.html#list) *or None*) – a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).
- **front** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If True compose using right operator multiplication, instead of left multiplication \[default: False].

**Returns**

The composed ScalarOp.

**Return type**

[ScalarOp](#qiskit.quantum_info.ScalarOp "qiskit.quantum_info.ScalarOp")

**Raises**

[**QiskitError**](/docs/api/qiskit/2.4/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if other cannot be converted to an operator, or has incompatible dimensions for specified subsystems.

> **Note**
>
> Composition (`&`) by default is defined as left matrix multiplication for matrix operators, while `@` (equivalent to [`dot()`](#qiskit.quantum_info.ScalarOp.dot "qiskit.quantum_info.ScalarOp.dot")) is defined as right matrix multiplication. That is that `A & B == A.compose(B)` is equivalent to `B @ A == B.dot(A)` when `A` and `B` are of the same type.
>
> Setting the `front=True` kwarg changes this to right matrix multiplication and is equivalent to the [`dot()`](#qiskit.quantum_info.ScalarOp.dot "qiskit.quantum_info.ScalarOp.dot") method `A.dot(B) == A.compose(B, front=True)`.

### conjugate

`conjugate()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L69-L72)

Return the conjugate of the ScalarOp.

### copy

`copy()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/base_operator.py#L143-L145)

Make a deep copy of current operator.

### dot

`dot(other, qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/mixins/group.py#L136-L152)

Return the right multiplied operator self \* other.

**Parameters**

- **other** ([*Operator*](/docs/api/qiskit/2.4/qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) – an operator object.
- **qargs** ([*list*](https://docs.python.org/3/library/stdtypes.html#list) *or None*) – a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).

**Returns**

The right matrix multiplied Operator.

**Return type**

[Operator](/docs/api/qiskit/2.4/qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")

> **Note**
>
> The dot product can be obtained using the `@` binary operator. Hence `a.dot(b)` is equivalent to `a @ b`.

### expand

`expand(other)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L159-L169)

Return the reverse-order tensor product with another ScalarOp.

**Parameters**

**other** ([*ScalarOp*](#qiskit.quantum_info.ScalarOp "qiskit.quantum_info.ScalarOp")) – a ScalarOp object.

**Returns**

**the tensor product $b \otimes a$, where $a$**

is the current ScalarOp, and $b$ is the other ScalarOp.

**Return type**

[ScalarOp](#qiskit.quantum_info.ScalarOp "qiskit.quantum_info.ScalarOp")

### input\_dims

`input_dims(qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/base_operator.py#L135-L137)

Return tuple of input dimension for specified subsystems.

### is\_unitary

`is_unitary(atol=None, rtol=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L77-L83)

Return True if operator is a unitary matrix.

### output\_dims

`output_dims(qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/base_operator.py#L139-L141)

Return tuple of output dimension for specified subsystems.

### power

`power(n)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L134-L145)

Return the power of the ScalarOp.

**Parameters**

**n** ([*float*](https://docs.python.org/3/library/functions.html#float)) – the exponent for the scalar op.

**Returns**

the `coeff ** n` ScalarOp.

**Return type**

[ScalarOp](#qiskit.quantum_info.ScalarOp "qiskit.quantum_info.ScalarOp")

### reshape

`reshape(input_dims=None, output_dims=None, num_qubits=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/base_operator.py#L106-L133)

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

**Parameters**

- **input\_dims** (*None or* [*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple)) – new subsystem input dimensions. If None the original input dims will be preserved \[Default: None].
- **output\_dims** (*None or* [*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple)) – new subsystem output dimensions. If None the original output dims will be preserved \[Default: None].
- **num\_qubits** (*None or* [*int*](https://docs.python.org/3/library/functions.html#int)) – reshape to an N-qubit operator \[Default: None].

**Returns**

returns self with reshaped input and output dimensions.

**Return type**

BaseOperator

**Raises**

[**QiskitError**](/docs/api/qiskit/2.4/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if combined size of all subsystem input dimension or subsystem output dimensions is not constant.

### tensor

`tensor(other)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L147-L157)

Return the tensor product with another ScalarOp.

**Parameters**

**other** ([*ScalarOp*](#qiskit.quantum_info.ScalarOp "qiskit.quantum_info.ScalarOp")) – a ScalarOp object.

**Returns**

**the tensor product $a \otimes b$, where $a$**

is the current ScalarOp, and $b$ is the other ScalarOp.

**Return type**

[ScalarOp](#qiskit.quantum_info.ScalarOp "qiskit.quantum_info.ScalarOp")

> **Note**
>
> The tensor product can be obtained using the `^` binary operator. Hence `a.tensor(b)` is equivalent to `a ^ b`.

### to\_matrix

`to_matrix()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L85-L89)

Convert to a Numpy matrix.

### to\_operator

`to_operator()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L91-L95)

Convert to an Operator object.

**Return type**

[*Operator*](/docs/api/qiskit/2.4/qiskit.quantum_info.Operator "qiskit.quantum_info.operators.operator.Operator")

### transpose

`transpose()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.4/qiskit/quantum_info/operators/scalar_op.py#L74-L75)

Return the transpose of the ScalarOp.
