Using Aqua utilities to simplify your work
Aqua comes with a sizeable set of utilities that offer some great functionality that simplifies generating your applications. In this section, we will implement a few utilities that may be useful, particularly when integrating your quantum applications with classical applications. We'll start with a simple converter from decimal into binary:
- First, we'll import the
utils
module and convert the decimal number6
into binary:# Import the utils module from qiskit.aqua import utils # convert the number 6 from decimal to binary binary_value = utils.decimal_to_binary(6, max_num_digits=0) print('Binary result: ', binary_value)
The preceding code will print out the binary result of the value 6:
Binary result: 110
- Next, we need to create some random unitary values. This will take the specified dimension value,
N
, as its argument to create a random N x N unitary matrix. This can be especially useful if you want to apply...