// File: /workspace/github_cpp_makefile_star2_O2/Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::InitDoppler(Eigen::Matrix<std::complex<double>, 1, -1, 1, 1, -1>, int)
void IsiSage::InitDoppler(const RowVectorXcd tau_data, const int iL){
    Util::log("init doppler...");
    // go through doppler frequecy bound to find index with max value
    double min_doppler = -config.max_doppler;
    double max_doppler = config.max_doppler;
    double step = config.doppler_step; // step of doppler is 0.1 hz
    int doppler_size = (int)(max_doppler-min_doppler)/step + 1;
    VectorXd doppler_data(doppler_size);
    doppler_data.setZero(doppler_size);
    complex<double> cycle_data = 0;
    complex<double> temp = 0;
    for(double i_step = 0; i_step < doppler_size; ++i_step){
        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;
                for(int i_cyc = 0; i_cyc < config.cycle_num; ++i_cyc){
                    double t = i_cyc * config.cycle_interval + (i_tx * config.Tt + i_rx * config.Tr) * config.T; 
                    temp.real(cos(2*PI*(min_doppler+i_step*step)*t));
                    temp.imag(-sin(2*PI*(min_doppler+i_step*step)*t));
                    cycle_data += temp * tau_data(i_cyc * config.subchannel_num + i_tx * config.Rx + i_rx);
                }
                doppler_data(i_step) +=norm(cycle_data);
            }
        }
    }
    int max_index = 0;
    doppler_data.maxCoeff(&max_index);
    result.doppler(iL) = min_doppler + max_index * config.doppler_step;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x16c5b(%rip), %rsi     # 0x1d773
leaq 0x88(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x3b5e
movl %ebp, 0x14(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x547e
leaq 0x88(%rsp), %rdi
callq 0x3100
movsd 0xd8(%rbx), %xmm0
movapd %xmm0, 0x30(%rsp)
addsd %xmm0, %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movsd 0x120(%rbx), %xmm1
movsd %xmm1, 0x48(%rsp)
divsd %xmm1, %xmm0
addsd 0x1685c(%rip), %xmm0    # 0x1d3d8
cvttsd2si %xmm0, %eax
leaq 0x1c(%rsp), %r15
movl %eax, (%r15)
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xaade
movslq (%r15), %rsi
movq %r12, %rdi
callq 0xab0e
movapd 0x30(%rsp), %xmm0
xorpd 0x1687f(%rip), %xmm0    # 0x1d430
movapd %xmm0, 0x30(%rsp)
xorpd %xmm0, %xmm0
leaq 0x70(%rsp), %r15
movapd %xmm0, (%r15)
xorpd %xmm1, %xmm1
cvtsi2sdl 0x1c(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6d3e
movapd %xmm1, %xmm0
mulsd 0x48(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
mulsd 0x167f7(%rip), %xmm0    # 0x1d3e8
movsd %xmm0, 0x60(%rsp)
movsd %xmm1, 0x50(%rsp)
cvttsd2si %xmm1, %rax
movq %rax, 0x58(%rsp)
xorl %ebp, %ebp
cmpl 0xc(%rbx), %ebp
jge 0x6d2b
xorl %r12d, %r12d
cmpl 0x8(%rbx), %r12d
jge 0x6d24
xorl %r13d, %r13d
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movsd %xmm0, 0x8(%rsp)
cmpl 0x10(%rbx), %r13d
jge 0x6cee
cvtsi2sd %r13d, %xmm0
movl 0xb4(%rbx), %eax
imull %ebp, %eax
movl 0xb8(%rbx), %ecx
imull %r12d, %ecx
addl %eax, %ecx
cvtsi2sd %ecx, %xmm1
mulsd 0xa8(%rbx), %xmm1
mulsd 0xc8(%rbx), %xmm0
addsd %xmm1, %xmm0
mulsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
callq 0x3470
movsd %xmm0, 0x70(%rsp)
movsd 0x68(%rsp), %xmm0
callq 0x3080
xorpd 0x16799(%rip), %xmm0    # 0x1d430
movlpd %xmm0, 0x78(%rsp)
movl 0xa0(%rbx), %eax
imull %r13d, %eax
movl 0x8(%rbx), %ecx
imull %ebp, %ecx
addl %r12d, %eax
addl %ecx, %eax
movslq %eax, %rsi
movq %r14, %rdi
callq 0xab8c
movq %r15, %rdi
movq %rax, %rsi
callq 0xab66
movsd (%rsp), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
incl %r13d
jmp 0x6c31
leaq 0x20(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x564e
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
incl %r12d
jmp 0x6c15
incl %ebp
jmp 0x6c09
movsd 0x50(%rsp), %xmm1
addsd 0x1669f(%rip), %xmm1    # 0x1d3d8
jmp 0x6bc9
leaq 0x18(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x20(%rsp), %rdi
callq 0xab3e
movl 0x18(%rsp), %ebp
movsd 0x120(%rbx), %xmm0
movsd %xmm0, (%rsp)
addq $0x1d0, %rbx            # imm = 0x1D0
movslq 0x14(%rsp), %rsi
movq %rbx, %rdi
callq 0x564e
cvtsi2sd %ebp, %xmm0
mulsd (%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x20(%rsp), %rdi
callq 0x32c0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6dc1
jmp 0x6dc1
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x3100
jmp 0x6dce
movq %rax, %rbx
jmp 0x6dce
jmp 0x6dc1
movq %rax, %rbx
movq 0x20(%rsp), %rdi
callq 0x32c0
movq %rbx, %rdi
callq 0x3430