coeff_make

Outline

This function generates the input arguments used by mat_maker function within PItBE.
It is strongly recommended to use the output of this function when executing mat_maker.
This function solves a system of equations that depends on the length of the input vector vec.
For example, when the length is 8, it solves a system of equations as shown below.
Here, the values \(\alpha_i\) represent the input, and the corresponding outputs are denoted by \(\alpha_i\).
\[\begin{split}\begin{aligned} &\alpha_1\sum_{n=0}^{7}{}a_{0n}^2 - \alpha_1^{-1}\sum_{n=8}^{15}{}a_{0n}^2 = 0\\ &\alpha_2\sum_{n=0}^{3}{}a_{0n}^2 - \alpha_2^{-1}\sum_{n=4}^{7}{}a_{0n}^2 +\alpha_3 \sum_{n=8}^{11}{}a_{0n}^2 - \alpha_3^{-1}\sum_{n=12}^{15}{}a_{0n}^2 = 0\\ &\alpha_1\alpha_2\sum_{n=0}^{3}{}a_{0n}^2 - \alpha_1\alpha_2^{-1}\sum_{n=4}^{7}{}a_{0n}^2 + \alpha_1^{-1}\alpha_3 \sum_{n=8}^{11}{}a_{0n}^2 - \alpha_1^{-1}\alpha_3^{-1}\sum_{n=12}^{15}{}a_{0n}^2 = 0\\ &\sum_{n=0}^3\Biggl(\alpha_{n+4}\sum_{l=4n}^{4n+1}a_{02l}^2+\alpha_{n+4}^{-1}\sum_{l=4n+2}^{4n+3}a_{02l}^2\Biggr) = 0\\ &\alpha_1\sum_{n=0}^1\Biggl(\alpha_{n+4}\sum_{l=4n}^{4n+1}a_{02l}^2+\alpha_{n+4}^{-1}\sum_{l=4n+2}^{4n+3}a_{02l}^2\Biggr) + \alpha_1^{-1}\sum_{n=2}^3\Biggl(\alpha_{n+4}\sum_{l=4n}^{4n+1}a_{02l}^2+\alpha_{n+4}^{-1}\sum_{l=4n+2}^{4n+3}a_{02l}^2\Biggr) = 0\\ &\sum_{n=0}^1\alpha_{n+1}\Biggl(\alpha_{2n+4}\sum_{l=0}^{1}a_{0(8n+l)}^2+\alpha_{2n+4}^{-1}\sum_{l=0}^{1}a_{{02(8n+l+2)}}^2\Biggr) + \sum_{n=0}^1\alpha_{n+1}^{-1}\Biggl(\alpha_{2n+5}\sum_{l=0}^{1}a_{0(8n+l+5)}^2+\alpha_{2n+2}^{-1}\sum_{l=0}^{1}a_{{02(8n+l+6)}}^2\Biggr) = 0\\ &\sum_{n=0}^1\alpha_{1}^{(-1)^n}\alpha_{n+1}\Biggl(\alpha_{2n+4}\sum_{l=0}^{1}a_{0(8n+l)}^2+\alpha_{2n+4}^{-1}\sum_{l=0}^{1}a_{{02(8n+l+2)}}^2\Biggr) + \sum_{n=0}^1\alpha_{1}^{(-1)^n}\alpha_{n+1}^{-1}\Biggl(\alpha_{2n+5}\sum_{l=0}^{1}a_{0(8n+l+5)}^2+\alpha_{2n+2}^{-1}\sum_{l=0}^{1}a_{{02(8n+l+6)}}^2\Biggr) = 0\\ \end{aligned}\end{split}\]

By solving the above system of equations, it is possible to construct a unitary matrix whose first column vector corresponds to an arbitrary input sequence.

Index List

argument name

type

role

vec

list(elements:float)

A list of normalized coefficients used in the linear combination

Return

coeff_list (list):
A list containing the computed results. Required for executing the mat_make function.

Python code

def coeff_make(vec):
    """
    This function generates the arguments used by the mat_make function within this package.
    It is strongly recommended to use the output of this function when executing mat_make.
    This function solves the system of equations described above.
    (a_i is the input value, and α_i is the desired solution.)

    Parameters:
        vec: The first column vector of the unitary matrix to be constructed

    Returns:
        list: the desired solution
    """
    # Local Value
    coeff_list = [] # A list to store the desired solution
    cal_list = [] # A list to store the sumation (ex: a_1 + a_2 + a_3 + a_4)
    # Solve the system of equations
    if len(vec) == 2:
        print("You do not need to calculate coefficients!!")
        return [vec[1], vec[0]]
    else:
        # Take the sum over a subset of the input values, 'vec'
        for i in range(int(np.log2(len(vec))) - 1):
            pre_list = []
            sep_num = 2**(i+1)
            elelen = len(vec)
            for j in range(sep_num):
                sum_list = vec[elelen//sep_num*j:
                               (elelen//sep_num*(j+1))]
                sum_pow = np.sum(np.array(sum_list)**2)
                if sum_pow == 0:
                    pre_list.append(1)
                else:
                    pre_list.append(sum_pow)
            cal_list.append(pre_list)
        # Compute the square of the ratio of two sums
        for i in range(len(cal_list)):
            save_list = []
            for j in range(len(cal_list[i])//2):
                save_list.append(np.sqrt(cal_list[i]\
                                [2*j]/cal_list[i][2*j+1]))
            coeff_list.append(save_list)
        return coeff_list

Sample Run

[ ]:
import numpy as np
import pitbe
[ ]:
input_vector = [0.5, 0.433, 0.25, 0.433, 0.433, 0.3536, 0., 0.]
print(pitbe.coeff_make(input_vector))
[[1.483163853864426], [1.3228881288499281, 0.5590366356510099]]