qiskit-documentation/docs/api/qiskit/0.35/qiskit.providers.ibmq.rando...

138 lines
5.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: CQCExtractor
description: API reference for qiskit.providers.ibmq.random.CQCExtractor
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.providers.ibmq.random.CQCExtractor
---
# CQCExtractor
<Class id="qiskit.providers.ibmq.random.CQCExtractor" isDedicatedPage={true} github="https://github.com/qiskit/qiskit-ibmq-provider/tree/stable/0.18/qiskit/providers/ibmq/random/cqcextractor.py" signature="CQCExtractor(name, provider, client, methods)" modifiers="class">
Bases: `qiskit.providers.ibmq.random.baserandomservice.BaseRandomService`
Class for interfacing with a CQC remote extractor.
There are two extractor methods - Dodis (extractor 1) and Hayashi (extractor 2). These methods can be invoked synchronously or asynchronously. To invoke them synchronously:
```python
random_bits = extractor.run(*cqc_parameters)
```
To invoke them asynchronously:
```python
import numpy as np
extractor1_out = extractor.run_async_ext1(*ext1_parameters).block_until_ready()
extractor2_out = extractor.run_async_ext2(
ext2_seed=extractor1_out, *ext2_parameters).block_until_ready()
random_bits = np.append(extractor1_out, extractor2_out)
```
Running them asynchronously takes more steps because extractor 2 uses the output of extractor 1 as its seed, so it must wait for extractor 1 to finish first.
BaseRandomService constructor.
**Parameters**
* **name** (`str`) Name of the extractor.
* **provider** (`AccountProvider`) IBM Quantum Experience account provider.
* **client** (`RandomClient`) Client used to communicate with the server.
* **methods** (`List`) Service methods.
## Methods
### retrieve\_job
<Function id="qiskit.providers.ibmq.random.CQCExtractor.retrieve_job" signature="CQCExtractor.retrieve_job(job_id)">
Retrieve a previously submitted job.
**Parameters**
**job\_id** (`str`) Job ID.
**Return type**
`CQCExtractorJob`
**Returns**
A `CQCExtractorJob` instance.
</Function>
### run
<Function id="qiskit.providers.ibmq.random.CQCExtractor.run" signature="CQCExtractor.run(ext1_input_num_bits, ext1_output_num_bits, ext1_raw_bytes, ext1_wsr_bytes, ext2_seed_num_bits, ext2_wsr_multiplier, ext2_wsr_generator=None)">
Process input data synchronously.
**Parameters**
* **ext1\_input\_num\_bits** (`int`) Number of input bits, for extractor 1.
* **ext1\_output\_num\_bits** (`int`) Number of output bits, for extractor 1.
* **ext1\_raw\_bytes** (`bytes`) Initial random numbers, in bytes, for extractor 1.
* **ext1\_wsr\_bytes** (`bytes`) Initial WSRs, in bytes, for extractor 1.
* **ext2\_seed\_num\_bits** (`int`) Number of bits in the seed, for extractor 2.
* **ext2\_wsr\_multiplier** (`int`) WSR multiplier, for extractor 2. The number of bits used by extractor 2 is ext2\_seed\_num\_bits\*ext2\_wsr\_multiplier.
* **ext2\_wsr\_generator** (`Optional`\[`Callable`]) WSR generator used for extractor 2. It must take the number of bits as the input and a list of random bits (0s and 1s) as the output. If `None`, :func:`generate_wsr` is used.
**Return type**
`List`\[`int`]
**Returns**
An instance of `CQCExtractorJob` which can be used to retrieve the results later.
</Function>
### run\_async\_ext1
<Function id="qiskit.providers.ibmq.random.CQCExtractor.run_async_ext1" signature="CQCExtractor.run_async_ext1(ext1_input_num_bits, ext1_output_num_bits, ext1_raw_bytes, ext1_wsr_bytes)">
Run the first extractor asynchronously.
**Parameters**
* **ext1\_input\_num\_bits** (`int`) Number of input bits, for extractor 1.
* **ext1\_output\_num\_bits** (`int`) Number of output bits, for extractor 1.
* **ext1\_raw\_bytes** (`bytes`) Initial random numbers, in bytes, for extractor 1.
* **ext1\_wsr\_bytes** (`bytes`) Initial WSRs, in bytes, for extractor 1.
**Return type**
`CQCExtractorJob`
**Returns**
An instance of `CQCExtractorJob` which can be used to retrieve the results later.
**Raises**
**ValueError** If an invalid argument values are specified.
</Function>
### run\_async\_ext2
<Function id="qiskit.providers.ibmq.random.CQCExtractor.run_async_ext2" signature="CQCExtractor.run_async_ext2(ext2_seed, ext2_seed_num_bits, ext2_wsr_multiplier, ext2_wsr_generator=None)">
Run the second extractor asynchronously.
**Parameters**
* **ext2\_seed** (`List`\[`int`]) Seed used for extractor 2, such as the output of extractor 1.
* **ext2\_seed\_num\_bits** (`int`) Number of bits in the seed, for extractor 2.
* **ext2\_wsr\_multiplier** (`int`) WSR multiplier, for extractor 2. The number of bits used by extractor 2 is ext2\_seed\_num\_bits\*ext2\_wsr\_multiplier.
* **ext2\_wsr\_generator** (`Optional`\[`Callable`]) WSR generator used for extractor 2. It must take the number of bits as the input and a list of random bits (0s and 1s) as the output. If `None`, :func:`generate_wsr` is used.
**Return type**
`CQCExtractorJob`
**Returns**
An instance of `CQCExtractorJob` which can be used to retrieve the results later.
**Raises**
**ValueError** If an invalid argument values are specified.
</Function>
</Class>