// File: Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::UpdateAlpha(Eigen::Matrix<std::complex<double>, 1, -1, 1, 1, -1>, int)
void IsiSage::UpdateAlpha(const RowVectorXcd tau_data, const int iL){
    Util::log("updating Alpha of the " + to_string(iL) + "th path");
    MatrixX2cd C2 = getAntennaResponse(result.theta_rx(iL), result.phi_rx(iL), 2);
    MatrixX2cd C1 = getAntennaResponse(result.theta_tx(iL), result.phi_tx(iL), 1);
    Matrix2cd part1 = C2.adjoint() * C2;
    Matrix2cd part2 = C1.adjoint() * C1;
    MatrixXcd D = kroneckerProduct(part1, part2);
    // X_l 
    MatrixXcd X(config.Rx, config.Tx);
    complex<double> cycle_data = 0;
    complex<double> temp = 0;
    for(int i_tx = 0; i_tx < config.Tx; ++i_tx){
        for(int i_rx = 0; i_rx < config.Rx; ++i_rx){
            cycle_data = 0;
            temp = 0;
            for(int i_cyc = 0; i_cyc < config.cycle_num; ++i_cyc){
                double t = (i_cyc * config.Tcy + i_tx * config.Tt + i_rx * config.Tr) * config.T; 
                temp.real(cos(2*PI* result.doppler(iL) *t));
                temp.imag(sin(2*PI* result.doppler(iL) *t));
                cycle_data += temp * tau_data(i_cyc * config.subchannel_num + i_tx * config.Rx + i_rx);
            }
            X(i_rx, i_tx) = cycle_data;
        }
    }
    VectorXcd c_2_1 = C2.col(0);
    VectorXcd c_2_2 = C2.col(1);
    Vector4cd f;
    VectorXcd c_1_1_conj = C1.col(0).conjugate();
    VectorXcd c_1_2_conj = C1.col(1).conjugate();
    f(0) = c_2_1.adjoint() * X * c_1_1_conj;
    f(1) = c_2_1.adjoint() * X * c_1_2_conj;
    f(2) = c_2_2.adjoint() * X * c_1_1_conj;
    f(3) = c_2_2.adjoint() * X * c_1_2_conj;
    result.alpha.col(iL) = D.inverse() * f / config.cycle_num;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6c0, %rsp            # imm = 0x6C0
movq %rsi, -0x5e8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x5e0(%rbp)
movl -0x14(%rbp), %esi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x5d8(%rbp)
callq 0x1fef0
movq -0x5d8(%rbp), %rdx
leaq 0x5424e(%rip), %rsi     # 0x6fbc7
leaq -0x58(%rbp), %rdi
callq 0x1fea0
jmp 0x1b984
leaq 0x54253(%rip), %rdx     # 0x6fbde
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x13b30
jmp 0x1b99a
leaq -0x38(%rbp), %rdi
callq 0x13b80
jmp 0x1b9a5
leaq -0x38(%rbp), %rdi
callq 0x9470
leaq -0x58(%rbp), %rdi
callq 0x9470
leaq -0x78(%rbp), %rdi
callq 0x9470
movq -0x5e0(%rbp), %rdi
addq $0x200, %rdi            # imm = 0x200
movslq -0x14(%rbp), %rsi
callq 0x14140
movq -0x5e0(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x5f8(%rbp)
addq $0x210, %rdi            # imm = 0x210
movslq -0x14(%rbp), %rsi
callq 0x14140
movsd -0x5f8(%rbp), %xmm0
movq -0x5e0(%rbp), %rsi
movsd (%rax), %xmm1
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq -0x98(%rbp), %rdi
movl $0x2, %edx
callq *%rax
movq -0x5e0(%rbp), %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x5f0(%rbp)
jmp 0x1ba42
movq -0x5e0(%rbp), %rdi
movq -0x5f0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x608(%rbp)
addq $0x1f0, %rdi            # imm = 0x1F0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x600(%rbp)
jmp 0x1ba75
movsd -0x608(%rbp), %xmm0
movq -0x5e0(%rbp), %rsi
movq -0x600(%rbp), %rax
movsd (%rax), %xmm1
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq -0xa8(%rbp), %rdi
movl $0x1, %edx
callq *%rax
jmp 0x1baa6
leaq -0x118(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x21030
jmp 0x1babb
leaq -0x108(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0x21080
jmp 0x1bad7
leaq -0xf0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x210d0
jmp 0x1baec
leaq -0x188(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x21030
jmp 0x1bb01
leaq -0x178(%rbp), %rdi
leaq -0x188(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x21080
jmp 0x1bb1d
leaq -0x160(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x210d0
jmp 0x1bb32
leaq -0xf0(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x21110
movq %rdx, -0x618(%rbp)
movq %rax, -0x610(%rbp)
jmp 0x1bb55
movq -0x618(%rbp), %rax
movq -0x610(%rbp), %rcx
movq %rcx, -0x1b0(%rbp)
movq %rax, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x21160
jmp 0x1bb86
movq -0x5e0(%rbp), %rdx
movq %rdx, %rsi
addq $0x8, %rsi
addq $0xc, %rdx
leaq -0x1c8(%rbp), %rdi
callq 0x20450
jmp 0x1bba6
leaq -0x1d8(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x14330
jmp 0x1bbba
leaq -0x1e8(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x14330
jmp 0x1bbce
movl $0x0, -0x1ec(%rbp)
movq -0x5e0(%rbp), %rcx
movl -0x1ec(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0x1bf03
movl $0x0, -0x1f0(%rbp)
movq -0x5e0(%rbp), %rcx
movl -0x1f0(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x1beed
leaq -0x1d8(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x202e0
jmp 0x1bc1f
leaq -0x1e8(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x202e0
jmp 0x1bc30
movl $0x0, -0x1f4(%rbp)
movq -0x5e0(%rbp), %rcx
movl -0x1f4(%rbp), %eax
cmpl 0x10(%rcx), %eax
jge 0x1be9a
movq -0x5e0(%rbp), %rdi
movl -0x1f4(%rbp), %eax
movl 0xbc(%rdi), %ecx
imull %ecx, %eax
movl -0x1ec(%rbp), %ecx
movl 0xb4(%rdi), %edx
imull %edx, %ecx
addl %ecx, %eax
movl -0x1f0(%rbp), %ecx
movl 0xb8(%rdi), %edx
imull %edx, %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xa8(%rdi), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x200(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x620(%rbp)
jmp 0x1bcb9
movq -0x620(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x53ba4(%rip), %xmm1    # 0x6f870
mulsd %xmm1, %xmm0
movsd -0x200(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x9e90
leaq -0x1e8(%rbp), %rdi
callq 0x13d00
jmp 0x1bcef
movq -0x5e0(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x628(%rbp)
jmp 0x1bd0f
movq -0x628(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x53b4e(%rip), %xmm1    # 0x6f870
mulsd %xmm1, %xmm0
movsd -0x200(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x9180
leaq -0x1e8(%rbp), %rdi
callq 0x13d20
jmp 0x1bd45
movq -0x5e8(%rbp), %rdi
movq -0x5e0(%rbp), %rcx
movl -0x1f4(%rbp), %eax
movl 0x8(%rcx), %edx
movl 0xa0(%rcx), %ecx
imull %ecx, %eax
movl -0x1ec(%rbp), %ecx
imull %edx, %ecx
addl %ecx, %eax
movl -0x1f0(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x20350
movq %rax, -0x630(%rbp)
jmp 0x1bd89
movq -0x630(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
callq 0x20310
movsd %xmm1, -0x640(%rbp)
movsd %xmm0, -0x638(%rbp)
jmp 0x1bdae
movsd -0x640(%rbp), %xmm0
movsd -0x638(%rbp), %xmm1
movsd %xmm1, -0x210(%rbp)
movsd %xmm0, -0x208(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x203e0
jmp 0x1bde3
jmp 0x1bde5
movl -0x1f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f4(%rbp)
jmp 0x1bc3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1be3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1be33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9470
leaq -0x58(%rbp), %rdi
callq 0x9470
leaq -0x78(%rbp), %rdi
callq 0x9470
jmp 0x1c48e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1c482
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1c476
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1c46a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1c45e
movslq -0x1f0(%rbp), %rsi
movslq -0x1ec(%rbp), %rdx
leaq -0x1c8(%rbp), %rdi
callq 0x13c40
movq %rax, -0x648(%rbp)
jmp 0x1bebd
movq -0x648(%rbp), %rax
movq -0x1d8(%rbp), %rcx
movq %rcx, (%rax)
movq -0x1d0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x1f0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f0(%rbp)
jmp 0x1bbf8
jmp 0x1beef
movl -0x1ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ec(%rbp)
jmp 0x1bbd8
xorl %eax, %eax
movl %eax, %edx
leaq -0x258(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x20580
jmp 0x1bf1c
leaq -0x220(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x20cb0
jmp 0x1bf31
leaq -0x2a0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movl $0x1, %edx
callq 0x20580
jmp 0x1bf4b
leaq -0x268(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x20cb0
jmp 0x1bf60
leaq -0x2e0(%rbp), %rdi
callq 0x20cf0
jmp 0x1bf6e
xorl %eax, %eax
movl %eax, %edx
leaq -0x368(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x20580
jmp 0x1bf87
leaq -0x330(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0x20e60
jmp 0x1bf9c
leaq -0x2f0(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x20eb0
jmp 0x1bfb1
leaq -0x3f0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x1, %edx
callq 0x20580
jmp 0x1bfcb
leaq -0x3b8(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x20e60
jmp 0x1bfe0
leaq -0x378(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x20eb0
jmp 0x1bff5
leaq -0x448(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x20720
jmp 0x1c00a
leaq -0x438(%rbp), %rdi
leaq -0x448(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
callq 0x20d80
jmp 0x1c026
leaq -0x420(%rbp), %rdi
leaq -0x438(%rbp), %rsi
leaq -0x2f0(%rbp), %rdx
callq 0x21390
jmp 0x1c042
leaq -0x420(%rbp), %rdi
callq 0x213e0
movsd %xmm1, -0x658(%rbp)
movsd %xmm0, -0x650(%rbp)
jmp 0x1c060
movsd -0x658(%rbp), %xmm0
movsd -0x650(%rbp), %xmm1
movsd %xmm1, -0x400(%rbp)
movsd %xmm0, -0x3f8(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x2e0(%rbp), %rdi
callq 0x20fa0
movq %rax, -0x660(%rbp)
jmp 0x1c099
movq -0x660(%rbp), %rax
movups -0x400(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x4a0(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x20720
jmp 0x1c0bf
leaq -0x490(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
callq 0x20d80
jmp 0x1c0db
leaq -0x478(%rbp), %rdi
leaq -0x490(%rbp), %rsi
leaq -0x378(%rbp), %rdx
callq 0x21390
jmp 0x1c0f7
leaq -0x478(%rbp), %rdi
callq 0x213e0
movsd %xmm1, -0x670(%rbp)
movsd %xmm0, -0x668(%rbp)
jmp 0x1c115
movsd -0x670(%rbp), %xmm0
movsd -0x668(%rbp), %xmm1
movsd %xmm1, -0x458(%rbp)
movsd %xmm0, -0x450(%rbp)
leaq -0x2e0(%rbp), %rdi
movl $0x1, %esi
callq 0x20fa0
movq %rax, -0x678(%rbp)
jmp 0x1c14f
movq -0x678(%rbp), %rax
movups -0x458(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x4f8(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x20720
jmp 0x1c175
leaq -0x4e8(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
callq 0x20d80
jmp 0x1c191
leaq -0x4d0(%rbp), %rdi
leaq -0x4e8(%rbp), %rsi
leaq -0x2f0(%rbp), %rdx
callq 0x21390
jmp 0x1c1ad
leaq -0x4d0(%rbp), %rdi
callq 0x213e0
movsd %xmm1, -0x688(%rbp)
movsd %xmm0, -0x680(%rbp)
jmp 0x1c1cb
movsd -0x688(%rbp), %xmm0
movsd -0x680(%rbp), %xmm1
movsd %xmm1, -0x4b0(%rbp)
movsd %xmm0, -0x4a8(%rbp)
leaq -0x2e0(%rbp), %rdi
movl $0x2, %esi
callq 0x20fa0
movq %rax, -0x690(%rbp)
jmp 0x1c205
movq -0x690(%rbp), %rax
movups -0x4b0(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x550(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x20720
jmp 0x1c22b
leaq -0x540(%rbp), %rdi
leaq -0x550(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
callq 0x20d80
jmp 0x1c247
leaq -0x528(%rbp), %rdi
leaq -0x540(%rbp), %rsi
leaq -0x378(%rbp), %rdx
callq 0x21390
jmp 0x1c263
leaq -0x528(%rbp), %rdi
callq 0x213e0
movsd %xmm1, -0x6a0(%rbp)
movsd %xmm0, -0x698(%rbp)
jmp 0x1c281
movsd -0x6a0(%rbp), %xmm0
movsd -0x698(%rbp), %xmm1
movsd %xmm1, -0x508(%rbp)
movsd %xmm0, -0x500(%rbp)
leaq -0x2e0(%rbp), %rdi
movl $0x3, %esi
callq 0x20fa0
movq %rax, -0x6a8(%rbp)
jmp 0x1c2bb
movq -0x6a8(%rbp), %rax
movups -0x508(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x1a0(%rbp), %rdi
callq 0x21240
movq %rax, -0x6b0(%rbp)
jmp 0x1c2e1
movq -0x6b0(%rbp), %rax
movq %rax, -0x598(%rbp)
leaq -0x598(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x21440
movq %rdx, -0x6c0(%rbp)
movq %rax, -0x6b8(%rbp)
jmp 0x1c312
movq -0x5e0(%rbp), %rdx
movq -0x6c0(%rbp), %rax
movq -0x6b8(%rbp), %rcx
movq %rcx, -0x590(%rbp)
movq %rax, -0x588(%rbp)
addq $0x10, %rdx
leaq -0x580(%rbp), %rdi
leaq -0x590(%rbp), %rsi
callq 0x21490
jmp 0x1c34e
movq -0x5e0(%rbp), %rsi
addq $0x220, %rsi            # imm = 0x220
movslq -0x14(%rbp), %rdx
leaq -0x5d0(%rbp), %rdi
callq 0x207b0
jmp 0x1c36e
leaq -0x5d0(%rbp), %rdi
leaq -0x580(%rbp), %rsi
callq 0x21550
jmp 0x1c383
leaq -0x378(%rbp), %rdi
callq 0x20c20
leaq -0x2f0(%rbp), %rdi
callq 0x20c20
leaq -0x268(%rbp), %rdi
callq 0x20c20
leaq -0x220(%rbp), %rdi
callq 0x20c20
leaq -0x1c8(%rbp), %rdi
callq 0xfac0
leaq -0x1a0(%rbp), %rdi
callq 0xfac0
leaq -0xa8(%rbp), %rdi
callq 0x13f10
leaq -0x98(%rbp), %rdi
callq 0x13f10
addq $0x6c0, %rsp            # imm = 0x6C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1c452
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1c446
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1c43a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x378(%rbp), %rdi
callq 0x20c20
leaq -0x2f0(%rbp), %rdi
callq 0x20c20
leaq -0x268(%rbp), %rdi
callq 0x20c20
leaq -0x220(%rbp), %rdi
callq 0x20c20
leaq -0x1c8(%rbp), %rdi
callq 0xfac0
leaq -0x1a0(%rbp), %rdi
callq 0xfac0
leaq -0xa8(%rbp), %rdi
callq 0x13f10
leaq -0x98(%rbp), %rdi
callq 0x13f10
movq -0x80(%rbp), %rdi
callq 0x9dc0
nopw (%rax,%rax)