| { |
| "cells": [ |
| { |
| "cell_type": "markdown", |
| "metadata": { |
| "colab_type": "text", |
| "id": "view-in-github" |
| }, |
| "source": [ |
| "<a href=\"https://colab.research.google.com/github/apache/mahout/blob/main/examples/Simple_Example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": null, |
| "metadata": { |
| "colab": { |
| "base_uri": "https://localhost:8080/" |
| }, |
| "id": "lNDTZhztd2dp", |
| "outputId": "ea3b9e41-43a8-44e7-9daf-e62e71d93143" |
| }, |
| "outputs": [], |
| "source": [ |
| "# pip install git+https://github.com/apache/mahout.git@main" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 2, |
| "metadata": { |
| "id": "M3O-QEdbd1Y2" |
| }, |
| "outputs": [], |
| "source": [ |
| "# Import the QuMat class\n", |
| "from qumat.qumat import QuMat" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 9, |
| "metadata": { |
| "id": "56zR0RS4eNuY" |
| }, |
| "outputs": [], |
| "source": [ |
| "# Create an instance of QuMat with a qiskit backend configuration\n", |
| "qiskit_backend_config = {\n", |
| " 'backend_name': 'qiskit',\n", |
| " 'backend_options': {\n", |
| " 'simulator_type': 'aer_simulator',\n", |
| " 'shots': 1024\n", |
| " }\n", |
| "}\n", |
| "qiskit_circuit = QuMat(qiskit_backend_config)\n", |
| "\n", |
| "# Create a quantum circuit\n", |
| "qiskit_circuit.create_empty_circuit(num_qubits=2)\n", |
| "\n", |
| "# Apply quantum gates to the circuit\n", |
| "qiskit_circuit.apply_hadamard_gate(qubit_index=0)\n", |
| "qiskit_circuit.apply_cnot_gate(control_qubit_index=0, target_qubit_index=1)\n", |
| "qiskit_circuit.apply_pauli_x_gate(qubit_index=0)\n", |
| "qiskit_circuit.execute_circuit()" |
| ] |
| }, |
| { |
| "cell_type": "code", |
| "execution_count": 10, |
| "metadata": { |
| "id": "1FaC7deljh5I" |
| }, |
| "outputs": [], |
| "source": [ |
| "# Create an instance of QuMat with a cirq backend configuration\n", |
| "cirq_backend_config = {\n", |
| " 'backend_name': 'cirq', # Replace with the actual backend you want to use\n", |
| " 'backend_options': {\n", |
| " 'simulator_type': 'default',\n", |
| " 'shots': 1024 # Number of shots for measurement\n", |
| "\n", |
| " }\n", |
| "}\n", |
| "cirq_circuit = QuMat(cirq_backend_config)\n", |
| "\n", |
| "# Create a quantum circuit\n", |
| "cirq_circuit.create_empty_circuit(num_qubits=2)\n", |
| "\n", |
| "# Apply quantum gates to the circuit\n", |
| "cirq_circuit.apply_hadamard_gate(qubit_index=0)\n", |
| "cirq_circuit.apply_cnot_gate(control_qubit_index=0, target_qubit_index=1)\n", |
| "cirq_circuit.apply_pauli_x_gate(qubit_index=0)\n", |
| "cirq_circuit.execute_circuit()\n" |
| ] |
| } |
| ], |
| "metadata": { |
| "colab": { |
| "authorship_tag": "ABX9TyNiuKjMe3+6/4/lQ29BvXn0", |
| "include_colab_link": true, |
| "provenance": [] |
| }, |
| "kernelspec": { |
| "display_name": "Python 3", |
| "name": "python3" |
| }, |
| "language_info": { |
| "name": "python" |
| } |
| }, |
| "nbformat": 4, |
| "nbformat_minor": 0 |
| } |