Portuguese
Idiomas
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

# ClassicalFunction¶

class ClassicalFunction(source, name=None)[código fonte]

Bases: `ClassicalElement`

Represent a classical function and its logic network.

Creates a `ClassicalFunction` from Python source code in `source`.

The code should be a single function with types.

Parâmetros
• source (str) – Python code with type hints.

• name (str) – Optional. Default: «classicalfunction». ClassicalFunction name.

Levanta

QiskitError – If source is not a string.

Methods

 `add_decomposition` Add a decomposition of the instruction to the SessionEquivalenceLibrary. `assemble` Assemble a QasmQobjInstruction `broadcast_arguments` Validation and handling of the arguments and its relationship. `c_if` Set a classical equality condition on this instruction between the register or cbit `classical` and value `val`. `compile` Parses and creates the logical circuit `control` Return controlled version of gate. `copy` Copy of the instruction. `inverse` Invert this instruction. `is_parameterized` Return True .IFF. `power` Creates a unitary gate as gate^exponent. `qasm` Return a default OpenQASM string for the instruction. `repeat` Creates an instruction with gate repeated n amount of times. `reverse_ops` For a composite instruction, reverse the order of sub-instructions. `simulate` Evaluate the expression on a bitstring. `simulate_all` Returns a truth table. `soft_compare` Soft comparison between gates. `synth` Synthesis the logic network into a `QuantumCircuit`. `to_matrix` Return a Numpy.array for the gate unitary matrix. `validate_parameter` Gate parameters should be int, float, or ParameterExpression

Attributes

args

Returns the classicalfunction arguments

condition_bits

Get Clbits in condition.

decompositions

Get the decompositions of the instruction from the SessionEquivalenceLibrary.

definition

Return definition in terms of other basic gates.

duration

Get the duration.

label

Return instruction label

name

Return the name.

network

Returns the logical network

num_clbits

Return the number of clbits.

num_qubits

Return the number of qubits.

params

return instruction params.

qregs

The list of qregs used by the classicalfunction

scopes

Returns the scope dict

truth_table

Returns (and computes) the truth table

types

Dumps a list of scopes with their variables and types.

Retorno

A list of scopes as dicts, where key is the variable name and value is its type.

Tipo de retorno

list(dict)

unit

Get the time unit of duration.