// File: Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::ParamsIterationUpdate()
void IsiSage::ParamsIterationUpdate(){
    Util::log("SAGE iteration step for updating params");
    int n_step = 1;
    SageResult last_update_result; 
    while(n_step <= max_iter_num){
        Util::log("====== Starting the " + to_string(n_step) + "th iteration step ======");
        // save init result of all path
        last_update_result = result;
        complex_mat y;
        for(int i_path = 0; i_path < max_path_num; ++i_path){
            y = CIR;
            //========== Expectation Step ==================
            for(int j = 0; j<max_path_num; ++j){
                if(j!=i_path){
                    y.row(result.tau(j)-1) -= SignalConstruct(j);
                }
            }
            //========== Maximization Step =================
            // update tau 
            RowVectorXcd tau_data = UpdateTau(y, i_path);
            // update AoA
            UpdateAoA(tau_data, i_path);
            // update AoD
            UpdateAoD(tau_data, i_path);
            // update doppler
            UpdateDoppler(tau_data, i_path);
            // update alpha 
            UpdateAlpha(tau_data, i_path);

        }
        // judge coverage
        if(IterConvergence(last_update_result, result)){
            Util::log("Iteration has coveraged !");
            break;
        }

        ++n_step;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x310(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x9dd0
movq -0x308(%rbp), %rdx
leaq 0x531be(%rip), %rsi     # 0x6fbe6
leaq -0x28(%rbp), %rdi
callq 0xb320
jmp 0x1ca33
leaq -0x28(%rbp), %rdi
callq 0x13b80
jmp 0x1ca3e
leaq -0x28(%rbp), %rdi
callq 0x9470
leaq -0x29(%rbp), %rdi
callq 0x9840
movl $0x1, -0x40(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xf8c0
movq -0x310(%rbp), %rcx
movl -0x40(%rbp), %eax
cmpl 0x158(%rcx), %eax
jg 0x1d06c
movl -0x40(%rbp), %esi
leaq -0x118(%rbp), %rdi
callq 0x1fef0
jmp 0x1ca8a
leaq 0x5317d(%rip), %rsi     # 0x6fc0e
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rdx
callq 0x1fea0
jmp 0x1caa6
leaq 0x53176(%rip), %rdx     # 0x6fc23
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x13b30
jmp 0x1cac2
leaq -0xd8(%rbp), %rdi
callq 0x13b80
jmp 0x1cad0
leaq -0xd8(%rbp), %rdi
callq 0x9470
leaq -0xf8(%rbp), %rdi
callq 0x9470
leaq -0x118(%rbp), %rdi
callq 0x9470
movq -0x310(%rbp), %rsi
addq $0x1c0, %rsi            # imm = 0x1C0
leaq -0xb8(%rbp), %rdi
callq 0x21680
jmp 0x1cb10
leaq -0x130(%rbp), %rdi
callq 0xf850
jmp 0x1cb1e
movl $0x0, -0x134(%rbp)
movq -0x310(%rbp), %rcx
movl -0x134(%rbp), %eax
cmpl 0x15c(%rcx), %eax
jge 0x1cee5
movq -0x310(%rbp), %rsi
addq $0x138, %rsi            # imm = 0x138
leaq -0x130(%rbp), %rdi
callq 0x21730
jmp 0x1cb5d
movl $0x0, -0x138(%rbp)
movq -0x310(%rbp), %rcx
movl -0x138(%rbp), %eax
cmpl 0x15c(%rcx), %eax
jge 0x1ccf0
movl -0x138(%rbp), %eax
cmpl -0x134(%rbp), %eax
je 0x1ccda
movq -0x310(%rbp), %rsi
movl -0x138(%rbp), %edx
leaq -0x148(%rbp), %rdi
callq 0x1c4a0
jmp 0x1cbad
movq -0x310(%rbp), %rdi
addq $0x1c0, %rdi            # imm = 0x1C0
movslq -0x138(%rbp), %rsi
callq 0x14090
movq %rax, -0x318(%rbp)
jmp 0x1cbd0
movq -0x318(%rbp), %rax
movl (%rax), %eax
decl %eax
movslq %eax, %rdx
leaq -0x180(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x20060
jmp 0x1cbf3
leaq -0x180(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x200b0
jmp 0x1cc08
leaq -0x148(%rbp), %rdi
callq 0x20040
jmp 0x1ccda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1cc3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x9470
leaq -0x29(%rbp), %rdi
callq 0x9840
jmp 0x1d08d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1d081
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1cc9b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1cc8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x9470
leaq -0xf8(%rbp), %rdi
callq 0x9470
leaq -0x118(%rbp), %rdi
callq 0x9470
jmp 0x1d081
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1d05e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x20040
jmp 0x1d05e
jmp 0x1ccdc
movl -0x138(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x138(%rbp)
jmp 0x1cb67
leaq -0x1a8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x1fe70
jmp 0x1cd05
movq -0x310(%rbp), %rsi
movl -0x134(%rbp), %ecx
leaq -0x190(%rbp), %rdi
leaq -0x1a8(%rbp), %rdx
callq 0x1d0a0
jmp 0x1cd27
leaq -0x1a8(%rbp), %rdi
callq 0xfac0
leaq -0x1b8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x20010
jmp 0x1cd48
movq -0x310(%rbp), %rdi
movl -0x134(%rbp), %edx
leaq -0x1b8(%rbp), %rsi
callq 0x1d5e0
jmp 0x1cd63
leaq -0x1b8(%rbp), %rdi
callq 0x20040
leaq -0x1c8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x20010
jmp 0x1cd84
movq -0x310(%rbp), %rdi
movl -0x134(%rbp), %edx
leaq -0x1c8(%rbp), %rsi
callq 0x1dde0
jmp 0x1cd9f
leaq -0x1c8(%rbp), %rdi
callq 0x20040
leaq -0x1d8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x20010
jmp 0x1cdc0
movq -0x310(%rbp), %rdi
movl -0x134(%rbp), %edx
leaq -0x1d8(%rbp), %rsi
callq 0x1e5d0
jmp 0x1cddb
leaq -0x1d8(%rbp), %rdi
callq 0x20040
leaq -0x1e8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x20010
jmp 0x1cdfc
movq -0x310(%rbp), %rdi
movl -0x134(%rbp), %edx
leaq -0x1e8(%rbp), %rsi
callq 0x1b930
jmp 0x1ce17
leaq -0x1e8(%rbp), %rdi
callq 0x20040
leaq -0x190(%rbp), %rdi
callq 0x20040
movl -0x134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0x1cb28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0xfac0
jmp 0x1d05e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1ced4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x20040
jmp 0x1ced4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x20040
jmp 0x1ced4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x20040
jmp 0x1ced4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x20040
leaq -0x190(%rbp), %rdi
callq 0x20040
jmp 0x1d05e
leaq -0x260(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x21760
jmp 0x1cefa
movq -0x310(%rbp), %rsi
addq $0x1c0, %rsi            # imm = 0x1C0
leaq -0x2d8(%rbp), %rdi
callq 0x21760
jmp 0x1cf16
movq -0x310(%rbp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq -0x260(%rbp), %rsi
leaq -0x2d8(%rbp), %rdx
callq *%rax
movb %al, -0x319(%rbp)
jmp 0x1cf3c
leaq -0x2d8(%rbp), %rdi
callq 0xf9f0
leaq -0x260(%rbp), %rdi
callq 0xf9f0
movb -0x319(%rbp), %al
testb $0x1, %al
jne 0x1cf63
jmp 0x1d02c
leaq -0x2f9(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0x9dd0
movq -0x328(%rbp), %rdx
leaq 0x52cb8(%rip), %rsi     # 0x6fc3c
leaq -0x2f8(%rbp), %rdi
callq 0xb320
jmp 0x1cf92
leaq -0x2f8(%rbp), %rdi
callq 0x13b80
jmp 0x1cfa0
leaq -0x2f8(%rbp), %rdi
callq 0x9470
leaq -0x2f9(%rbp), %rdi
callq 0x9840
movl $0x3, -0x300(%rbp)
jmp 0x1d03f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1cfea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0xf9f0
leaq -0x260(%rbp), %rdi
callq 0xf9f0
jmp 0x1d05e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1d01e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x9470
leaq -0x2f9(%rbp), %rdi
callq 0x9840
jmp 0x1d05e
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x300(%rbp)
leaq -0x130(%rbp), %rdi
callq 0xfac0
movl -0x300(%rbp), %eax
testl %eax, %eax
je 0x1d059
jmp 0x1d057
jmp 0x1d06c
jmp 0x1ca63
leaq -0x130(%rbp), %rdi
callq 0xfac0
jmp 0x1d081
leaq -0xb8(%rbp), %rdi
callq 0xf9f0
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
leaq -0xb8(%rbp), %rdi
callq 0xf9f0
movq -0x38(%rbp), %rdi
callq 0x9dc0
nopw %cs:(%rax,%rax)