// File: godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::Train()
void Train()
    {

        //Pre-processing
        alpha = 0.0f;
        for(int t=0;t<4.0f * ro;t++)
        {
            int v = GetSignalValue(t);
            signalVector.push_back(v);
            OscillateFeedForward(v,t);

            f_vector1.push_back(log(V/U));
        }

        signalVector.clear();
        resultVector.clear();

        //Training
        alpha = 0.001f;
        for(int t = 4.0f * ro;t<(4.0f*ro+TOTAL_TIME);t++)
        {
            int v = GetSignalValue(t);
            signalVector.push_back(v);
            OscillateFeedForward(v,t);
            getNetwork()->UpdateWeights();

            f_vector1.push_back(log(V/U));


            double correlation = GetCorrelationTrace(signalVector,resultVector,t);
       //     cout<<correlation<<endl;
         //   cout<<resultVector.size()<<endl;
            corVector1.push_back(correlation);
        }  

        string ro_string = to_string(ro);
        string prefix_o = "Output: ro= ";
        
        std::vector<std::pair<std::string,
        std::vector<double>>> vals = {{"Values", resultVector}};
        string stt = prefix_o+ro_string+" .csv";
        write_csv(ro_string + " values.csv", vals);

        std::vector<std::pair<std::string,
        std::vector<double>>> f_vals = {{"Values", f_vector1}};
        string spp = (string)"F values: ro= "+ro_string+(string)" .csv";
        write_csv(ro_string + " F.csv", f_vals);

        std::vector<std::pair<std::string,
        std::vector<double>>> c_vals = {{"Values", corVector1}};
        write_csv(ro_string + " Cor.csv", c_vals);

/*
        std::vector<std::pair<std::string,
        std::vector<double>>> vals2 = {{"j", getNetwork()->GetWeights()}};
        write_csv("weight_vector.csv", vals2);
*/


    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x398(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rax)
movl $0x0, -0xc(%rbp)
movq -0x398(%rbp), %rax
cvtsi2sdl -0xc(%rbp), %xmm1
movsd 0x8f93(%rip), %xmm0     # 0xe050
mulsd 0x1d0(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5164
movq -0x398(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x7c00
movq -0x398(%rbp), %rdi
movl %eax, -0x10(%rbp)
addq $0x2a0, %rdi            # imm = 0x2A0
cvtsi2sdl -0x10(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq -0x18(%rbp), %rsi
callq 0x4310
movq -0x398(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x7d00
movq -0x398(%rbp), %rax
movq %rax, %rcx
addq $0x2e8, %rcx            # imm = 0x2E8
movq %rcx, -0x3a0(%rbp)
movsd 0x168(%rax), %xmm0
divsd 0x160(%rax), %xmm0
callq 0x2170
movq -0x3a0(%rbp), %rdi
movsd %xmm0, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0x4310
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x50a9
movq -0x398(%rbp), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
callq 0x42f0
movq -0x398(%rbp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
callq 0x42f0
movq -0x398(%rbp), %rax
movsd 0x8ea7(%rip), %xmm0     # 0xe040
movsd %xmm0, 0x68(%rax)
movsd 0x8eaa(%rip), %xmm0     # 0xe050
mulsd 0x1d0(%rax), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x24(%rbp)
movq -0x398(%rbp), %rax
cvtsi2sdl -0x24(%rbp), %xmm1
movsd 0x1d0(%rax), %xmm0
cvtsi2sdl 0x1d8(%rax), %xmm2
movsd 0x8e77(%rip), %xmm3     # 0xe050
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x534d
movq -0x398(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x7c00
movq -0x398(%rbp), %rdi
movl %eax, -0x28(%rbp)
addq $0x2a0, %rdi            # imm = 0x2A0
movq %rdi, -0x3a8(%rbp)
cvtsi2sdl -0x28(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x4310
movq -0x398(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x24(%rbp), %edx
callq 0x7d00
movq -0x398(%rbp), %rdi
callq 0x7e70
movq %rax, %rdi
callq 0x2e70
movq -0x398(%rbp), %rax
movq %rax, %rcx
addq $0x2e8, %rcx            # imm = 0x2E8
movq %rcx, -0x3b0(%rbp)
movsd 0x160(%rax), %xmm1
movsd 0x168(%rax), %xmm0
divsd %xmm1, %xmm0
callq 0x2170
movq -0x3b0(%rbp), %rdi
movsd %xmm0, -0x38(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x4310
movq -0x3a8(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4490
movq -0x398(%rbp), %rsi
addq $0x1f8, %rsi            # imm = 0x1F8
leaq -0x70(%rbp), %rdi
callq 0x4490
jmp 0x52ba
movq -0x398(%rbp), %rdi
movl -0x24(%rbp), %ecx
leaq -0x58(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x7e90
movsd %xmm0, -0x3b8(%rbp)
jmp 0x52db
leaq -0x70(%rbp), %rdi
callq 0x4430
leaq -0x58(%rbp), %rdi
callq 0x4430
movsd -0x3b8(%rbp), %xmm0
movq -0x398(%rbp), %rdi
movsd %xmm0, -0x40(%rbp)
addq $0x38, %rdi
leaq -0x40(%rbp), %rsi
callq 0x43a0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x51b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x533f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4430
leaq -0x58(%rbp), %rdi
callq 0x4430
jmp 0x5cdb
movq -0x398(%rbp), %rax
movsd 0x1d0(%rax), %xmm0
leaq -0xa0(%rbp), %rdi
callq 0x80d0
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x2300
movq -0x3c0(%rbp), %rdx
leaq 0x8dac(%rip), %rsi      # 0xe135
leaq -0xc0(%rbp), %rdi
callq 0x2250
jmp 0x5397
leaq -0xc1(%rbp), %rdi
callq 0x2220
movq -0x398(%rbp), %rdx
leaq -0x128(%rbp), %rdi
movq %rdi, -0x130(%rbp)
addq $0x1f8, %rdx            # imm = 0x1F8
leaq 0x8d7c(%rip), %rsi      # 0xe142
callq 0x8120
jmp 0x53cd
leaq -0x128(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq $0x1, -0xe8(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x81f0
movq -0x3c8(%rbp), %rcx
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
leaq -0xe0(%rbp), %rdi
callq 0x8210
jmp 0x541c
leaq -0x131(%rbp), %rdi
callq 0x8290
leaq -0x128(%rbp), %rax
movq %rax, -0x3d8(%rbp)
addq $0x38, %rax
movq %rax, -0x3d0(%rbp)
movq -0x3d0(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x81c0
movq -0x3d8(%rbp), %rcx
movq -0x3e0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x3d0(%rbp)
jne 0x5441
leaq -0x178(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x8300
jmp 0x548e
leaq 0x8cb4(%rip), %rdx      # 0xe149
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x82b0
jmp 0x54aa
leaq -0x178(%rbp), %rdi
callq 0x20f0
leaq 0x8c92(%rip), %rdx      # 0xe14f
leaq -0x198(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x8640
jmp 0x54d2
leaq -0x1b0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x86c0
jmp 0x54e7
movq -0x398(%rbp), %rdi
leaq -0x198(%rbp), %rsi
leaq -0x1b0(%rbp), %rdx
callq 0x8380
jmp 0x5503
leaq -0x1b0(%rbp), %rdi
callq 0x87b0
leaq -0x198(%rbp), %rdi
callq 0x20f0
movq -0x398(%rbp), %rdx
leaq -0x210(%rbp), %rdi
movq %rdi, -0x218(%rbp)
addq $0x2e8, %rdx            # imm = 0x2E8
leaq 0x8c04(%rip), %rsi      # 0xe142
callq 0x8120
jmp 0x5545
leaq -0x210(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq $0x1, -0x1d0(%rbp)
leaq -0x219(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x81f0
movq -0x3e8(%rbp), %rcx
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rdx
leaq -0x1c8(%rbp), %rdi
callq 0x8210
jmp 0x5594
leaq -0x219(%rbp), %rdi
callq 0x8290
leaq -0x210(%rbp), %rax
movq %rax, -0x3f8(%rbp)
addq $0x38, %rax
movq %rax, -0x3f0(%rbp)
movq -0x3f0(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x400(%rbp)
callq 0x81c0
movq -0x3f8(%rbp), %rcx
movq -0x400(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x3f0(%rbp)
jne 0x55b9
leaq -0x281(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x2300
movq -0x408(%rbp), %rdx
leaq 0x8b50(%rip), %rsi      # 0xe15b
leaq -0x280(%rbp), %rdi
callq 0x2250
jmp 0x5619
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x88e0
jmp 0x5635
leaq -0x2a9(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x2300
movq -0x410(%rbp), %rdx
leaq 0x8af3(%rip), %rsi      # 0xe149
leaq -0x2a8(%rbp), %rdi
callq 0x2250
jmp 0x5664
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0x8810
jmp 0x5680
leaq -0x2a8(%rbp), %rdi
callq 0x20f0
leaq -0x2a9(%rbp), %rdi
callq 0x2220
leaq -0x260(%rbp), %rdi
callq 0x20f0
leaq -0x280(%rbp), %rdi
callq 0x20f0
leaq -0x281(%rbp), %rdi
callq 0x2220
leaq 0x8aa7(%rip), %rdx      # 0xe16a
leaq -0x2d0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x8640
jmp 0x56d8
leaq -0x2e8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x86c0
jmp 0x56ed
movq -0x398(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
leaq -0x2e8(%rbp), %rdx
callq 0x8380
jmp 0x5709
leaq -0x2e8(%rbp), %rdi
callq 0x87b0
leaq -0x2d0(%rbp), %rdi
callq 0x20f0
movq -0x398(%rbp), %rdx
leaq -0x348(%rbp), %rdi
movq %rdi, -0x350(%rbp)
addq $0x38, %rdx
leaq 0x8a01(%rip), %rsi      # 0xe142
callq 0x8120
jmp 0x5748
leaq -0x348(%rbp), %rax
movq %rax, -0x310(%rbp)
movq $0x1, -0x308(%rbp)
leaq -0x351(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x81f0
movq -0x418(%rbp), %rcx
movq -0x310(%rbp), %rsi
movq -0x308(%rbp), %rdx
leaq -0x300(%rbp), %rdi
callq 0x8210
jmp 0x5797
leaq -0x351(%rbp), %rdi
callq 0x8290
leaq -0x348(%rbp), %rax
movq %rax, -0x428(%rbp)
addq $0x38, %rax
movq %rax, -0x420(%rbp)
movq -0x420(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x430(%rbp)
callq 0x81c0
movq -0x428(%rbp), %rcx
movq -0x430(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x420(%rbp)
jne 0x57bc
leaq 0x897d(%rip), %rdx      # 0xe171
leaq -0x378(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x8640
jmp 0x5809
leaq -0x390(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x86c0
jmp 0x581e
movq -0x398(%rbp), %rdi
leaq -0x378(%rbp), %rsi
leaq -0x390(%rbp), %rdx
callq 0x8380
jmp 0x583a
leaq -0x390(%rbp), %rdi
callq 0x87b0
leaq -0x378(%rbp), %rdi
callq 0x20f0
leaq -0x300(%rbp), %rdi
callq 0x87b0
leaq -0x240(%rbp), %rdi
callq 0x20f0
leaq -0x1c8(%rbp), %rdi
callq 0x87b0
leaq -0x158(%rbp), %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x87b0
leaq -0xc0(%rbp), %rdi
callq 0x20f0
leaq -0xa0(%rbp), %rdi
callq 0x20f0
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x2220
jmp 0x5ccf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movq -0x130(%rbp), %rax
leaq -0x128(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x438(%rbp)
je 0x5923
movq -0x438(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x440(%rbp)
callq 0x81c0
movq -0x440(%rbp), %rax
leaq -0x128(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x438(%rbp)
jne 0x58f2
jmp 0x5cc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x131(%rbp), %rdi
callq 0x8290
leaq -0x128(%rbp), %rax
movq %rax, -0x450(%rbp)
addq $0x38, %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x458(%rbp)
callq 0x81c0
movq -0x450(%rbp), %rcx
movq -0x458(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x448(%rbp)
jne 0x5959
jmp 0x5cc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5cb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x20f0
jmp 0x5cb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5cab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x59f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x87b0
leaq -0x198(%rbp), %rdi
callq 0x20f0
jmp 0x5cab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movq -0x218(%rbp), %rax
leaq -0x210(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x460(%rbp)
je 0x5a5c
movq -0x460(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x468(%rbp)
callq 0x81c0
movq -0x468(%rbp), %rax
leaq -0x210(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x460(%rbp)
jne 0x5a2b
jmp 0x5cab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x219(%rbp), %rdi
callq 0x8290
leaq -0x210(%rbp), %rax
movq %rax, -0x478(%rbp)
addq $0x38, %rax
movq %rax, -0x470(%rbp)
movq -0x470(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x480(%rbp)
callq 0x81c0
movq -0x478(%rbp), %rcx
movq -0x480(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x470(%rbp)
jne 0x5a92
jmp 0x5cab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5b2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5b22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5b0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x20f0
leaq -0x2a9(%rbp), %rdi
callq 0x2220
leaq -0x260(%rbp), %rdi
callq 0x20f0
leaq -0x280(%rbp), %rdi
callq 0x20f0
leaq -0x281(%rbp), %rdi
callq 0x2220
jmp 0x5c9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5c93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5b76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x87b0
leaq -0x2d0(%rbp), %rdi
callq 0x20f0
jmp 0x5c93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movq -0x350(%rbp), %rax
leaq -0x348(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x488(%rbp)
je 0x5bde
movq -0x488(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x490(%rbp)
callq 0x81c0
movq -0x490(%rbp), %rax
leaq -0x348(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x488(%rbp)
jne 0x5bad
jmp 0x5c93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x351(%rbp), %rdi
callq 0x8290
leaq -0x348(%rbp), %rax
movq %rax, -0x4a0(%rbp)
addq $0x38, %rax
movq %rax, -0x498(%rbp)
movq -0x498(%rbp), %rdi
addq $-0x38, %rdi
movq %rdi, -0x4a8(%rbp)
callq 0x81c0
movq -0x4a0(%rbp), %rcx
movq -0x4a8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x498(%rbp)
jne 0x5c14
jmp 0x5c93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5c87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5c7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x87b0
leaq -0x378(%rbp), %rdi
callq 0x20f0
leaq -0x300(%rbp), %rdi
callq 0x87b0
leaq -0x240(%rbp), %rdi
callq 0x20f0
leaq -0x1c8(%rbp), %rdi
callq 0x87b0
leaq -0x158(%rbp), %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x87b0
leaq -0xc0(%rbp), %rdi
callq 0x20f0
leaq -0xa0(%rbp), %rdi
callq 0x20f0
movq -0x78(%rbp), %rdi
callq 0x22f0
nopw %cs:(%rax,%rax)
nop