{ "cells": [ { "cell_type": "markdown", "id": "4c2b68f4", "metadata": {}, "source": [ "## vec_make" ] }, { "cell_type": "markdown", "id": "ee0c4a9f", "metadata": {}, "source": [ "### **概要**\n", "This function calculates essential values required for executing the [mat_maker](../eng/mat_maker_en.ipynb).\\\n", "It is intended to be used internally within [mat_maker](../eng/mat_maker_en.ipynb) and is not designed for standalone use.\\\n", "It has been separated from [mat_maker](../eng/mat_maker_en.ipynb) to avoid making the function overly complex." ] }, { "cell_type": "markdown", "id": "3a8b23f9", "metadata": {}, "source": [ "### **引数一覧**\n", "|argument name|type|role|\n", "|---|---|---|\n", "|ele|str|A list of elements representing the matrix used in `mat_maker`|\n", "|coflst|list(elements:int)|A list containing the coefficients applied to the matrix elements used in `mat_maker`|" ] }, { "cell_type": "markdown", "id": "6e4b88d8", "metadata": {}, "source": [ "### **戻り値**\n", "app_lst(list):\\\n", "A list for storing the calculation results.\\\n", "Each element is of type float." ] }, { "cell_type": "markdown", "id": "490e3d89", "metadata": {}, "source": [ "### **Python code**\n", "```python\n", "def vec_make(ele, coflst):\n", " \"\"\"\n", " This function computes essential values required for executing function, \"mat_make\".\n", " This function is intended to be used only within the function, \"mat_make\", and is not designed for standalone use.\n", "\n", " Parameters:\n", " gate_inf: the results of the Jordan–Wigner and Bravyi–Kitaev transformations performed using OpenFermion\n", " zero_one\n", "\n", " Returns:\n", " (list, list): The coefficients information and Pauli matrix product information.\n", " \"\"\"\n", " app_lst = []\n", " cor_list_one = []\n", " cor_list_two = []\n", " for i in range(len(coflst)):\n", " corlen = len(ele)//len(coflst)\n", " cor_list_one = ele[corlen*i: corlen*i+corlen//2]\n", " cor_list_two = ele[corlen*i+corlen//2: corlen*i+corlen]\n", " for j in range(len(cor_list_one)):\n", " app_lst.append(-cor_list_one[j]/coflst[i])\n", " for j in range(len(cor_list_two)):\n", " app_lst.append(cor_list_two[j]*coflst[i])\n", " return app_lst\n", "```" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }