---
title: LinearMap (latest version)
description: API reference for qiskit_noise_learning.math.LinearMap in the latest version of qiskit-noise-learning
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-noise-learning/generated/math-linear-map
---

# qiskit\_noise\_learning.math.LinearMap

*class* `qiskit_noise_learning.math.LinearMap(input_space: IndexedSpace[InputIndex], output_space: IndexedSpace[OutputIndex])`

[GitHub](https://github.com/Qiskit/qiskit-noise-learning/tree/stable/0.1/qiskit_noise_learning/math/linear_map.py)

Bases: [`Generic`](https://docs.python.org/3/library/typing.html#typing.Generic)\[`InputIndex`, `OutputIndex`], [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC)

An implicit linear map between two indexed spaces.

**Parameters**

- **input\_space** – The input space.
- **output\_space** – The output space.

### \_\_init\_\_

`__init__(input_space: IndexedSpace[InputIndex], output_space: IndexedSpace[OutputIndex])`

## Methods

|                                                                                                                                                               |                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| [`__init__`](#qiskit_noise_learning.math.LinearMap.__init__ "qiskit_noise_learning.math.LinearMap.__init__")(input\_space, output\_space)                     |                                                                   |
| [`compose`](#qiskit_noise_learning.math.LinearMap.compose "qiskit_noise_learning.math.LinearMap.compose")(outer)                                              | Post-compose: self maps I->O, outer maps O->C, result maps I->C.  |
| [`left_multiply`](#qiskit_noise_learning.math.LinearMap.left_multiply "qiskit_noise_learning.math.LinearMap.left_multiply")(matrix)                           | Multiply on the left by an explicit matrix.                       |
| [`pre_compose`](#qiskit_noise_learning.math.LinearMap.pre_compose "qiskit_noise_learning.math.LinearMap.pre_compose")(inner)                                  | Pre-compose: inner maps A->I, self maps I->O, result maps A->O.   |
| [`projected_output`](#qiskit_noise_learning.math.LinearMap.projected_output "qiskit_noise_learning.math.LinearMap.projected_output")(output\_indices, vector) | Compute a projection of the map applied to a vector.              |
| [`rows`](#qiskit_noise_learning.math.LinearMap.rows "qiskit_noise_learning.math.LinearMap.rows")(output\_indices)                                             | Construct the sub-matrix whose rows are the given output indices. |

## Attributes

|                                                                                                                          |                   |
| ------------------------------------------------------------------------------------------------------------------------ | ----------------- |
| [`input_space`](#qiskit_noise_learning.math.LinearMap.input_space "qiskit_noise_learning.math.LinearMap.input_space")    | The input space.  |
| [`output_space`](#qiskit_noise_learning.math.LinearMap.output_space "qiskit_noise_learning.math.LinearMap.output_space") | The output space. |

### input\_space

Type: [`IndexedSpace`](/docs/api/qiskit-noise-learning/generated/math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[`InputIndex`]

The input space.

### output\_space

Type: [`IndexedSpace`](/docs/api/qiskit-noise-learning/generated/math-indexed-space "qiskit_noise_learning.math.indexed_space.IndexedSpace")\[`OutputIndex`]

The output space.

### rows

*abstractmethod* `rows(output_indices: Iterable[OutputIndex]) → IndexedMatrix[OutputIndex, InputIndex]`

Construct the sub-matrix whose rows are the given output indices.

**Parameters**

**output\_indices** – The labels for the desired rows of the matrix.

**Returns**

[`IndexedMatrix`](/docs/api/qiskit-noise-learning/generated/math-indexed-matrix "qiskit_noise_learning.math.IndexedMatrix")

### left\_multiply

`left_multiply(matrix: IndexedMatrix[RowLabel, OutputIndex]) → IndexedMatrix[RowLabel, InputIndex]`

Multiply on the left by an explicit matrix.

**Parameters**

**matrix** – A matrix whose column indices are output indices of this map.

**Returns**

The resulting matrix.

### projected\_output

`projected_output(output_indices: Iterable[OutputIndex], vector: Mapping[InputIndex, float]) → IndexedVector[OutputIndex]`

Compute a projection of the map applied to a vector.

The projection is defined by an iterable of output indices: only the component of the vector on those output indices will be returned.

**Parameters**

- **output\_indices** – The output indices defining the projection.
- **vector** – A mapping from input indices to floats.

**Returns**

The projected output vector.

**Raises**

[**KeyError**](https://docs.python.org/3/library/exceptions.html#KeyError) – If an input index appearing in the rows is not present in `vector`.

### compose

`compose(outer: LinearMap[OutputIndex, OtherOutput]) → ComposedLinearMap[InputIndex, OtherOutput]`

Post-compose: self maps I->O, outer maps O->C, result maps I->C.

### pre\_compose

`pre_compose(inner: LinearMap[OtherInput, InputIndex]) → ComposedLinearMap[OtherInput, OutputIndex]`

Pre-compose: inner maps A->I, self maps I->O, result maps A->O.
