{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# vec_make" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 概要" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "この関数は関数\"mat_make\"を実行する際に必要不可欠な値を計算する\\\n", "この関数は\"mat_make\"内での実行を想定しており、それ以外で用いることは想定していない\\\n", "\"mat_make\"と分離させたのは一つの関数が複雑化するのを回避するためである" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 引数一覧" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|argument name|type|role|\n", "|---|---|---|\n", "|ele|str|「mat_make」で扱う行列の要素が格納されたlist|\n", "|coflst|list(elements:int)|「mat_make」の行列要素に作用させる係数を格納したlist|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 戻り値" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "app_lst(list):計算結果を格納するlist\\\n", "格納されている要素はfloat型" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python code" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```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": 2 }