{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# PyOR Quantum\n", "## Author: Vineeth Thalakottoor\n", "## Introduction to kets and bras" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Define the source path\n", "SourcePath = '/media/HD2/Vineeth/PostDoc_Simulations/Github/PyOR_V1/PyOR_Combined/PyOR/Source_Doc'\n", "\n", "# Add source path\n", "import sys\n", "sys.path.append(SourcePath)\n", "\n", "# Import PyOR package\n", "from PyOR_QuantumLibrary import QuantumLibrary\n", "QLib = QuantumLibrary()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Quantum object initialized: shape=(2, 1), type='ket', dtype=complex128\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.0\\\\0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[1.0],\n", "[ 0]])" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ket1 = QLib.Basis_Ket(2,0, PrintDefault=True)\n", "ket1.matrix" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Quantum object initialized: shape=(2, 1), type='ket', dtype=complex128\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0\\\\1.0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[ 0],\n", "[1.0]])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ket2 = QLib.Basis_Ket(2,1, PrintDefault=True)\n", "ket2.matrix" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Quantum object initialized: shape=(1, 2), type='bra', dtype=complex128\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([[1.0, 0]])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bra1 = QLib.Basis_Bra(2,0, PrintDefault=True)\n", "bra1.matrix" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Quantum object initialized: shape=(1, 2), type='bra', dtype=complex128\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 1.0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([[0, 1.0]])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bra2 = QLib.Basis_Bra(2,1, PrintDefault=True)\n", "bra2.matrix" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1.0\\\\2.0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[1.0],\n", "[2.0]])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create a state\n", "psi1 = 1 * ket1 + 2 * ket2\n", "psi1.matrix" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }