// File: /workspace/github_cpp_makefile_star2_O3/KokiKishimoto[P]cp_decomposition/./updater.hpp
// Function: Updater::SGD(Triple&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&)
void SGD(Triple& triple, std::vector<double>& gradient_r, std::vector<double>& gradient_s, std::vector<double>& gradient_o, std::vector<double>& norms, std::vector< std::vector<double> >& subjVec, std::vector< std::vector<double> >& objVec, std::vector< std::vector<double> >& relationVec) {
		std::vector<double>& r_v = relationVec[triple.relation];
		if (norms[0] >= threshold) {
			double x = (threshold / norms[0]);
			for (int i = 0; i < gradient_r.size(); i++) {
				r_v[i] -= learningRate * x * gradient_r[i];
			}
		} else {
			for (int i = 0; i < gradient_r.size(); i++) {
				r_v[i] -= learningRate * gradient_r[i];
			}			
		}

		std::vector<double>& s_e_v = subjVec[triple.subj];
		if (norms[1] >= threshold) {
			double x = (threshold / norms[1]);
			for (int i = 0; i < gradient_s.size(); i++) {
				s_e_v[i] -= learningRate * x * gradient_s[i];
			}
		} else {
			for (int i = 0; i < gradient_s.size(); i++) {
				s_e_v[i] -= learningRate * gradient_s[i];
			}			
		}

		std::vector<double>& o_e_v = objVec[triple.obj];
		if (norms[2] >= threshold) {
			double x = (threshold / norms[2]);
			for (int i = 0; i < gradient_o.size(); i++) {
				o_e_v[i] -= learningRate * x * gradient_o[i];
			}
		} else {
			for (int i = 0; i < gradient_o.size(); i++) {
				o_e_v[i] -= learningRate * gradient_o[i];
			}			
		}		
	}

// Assembly:
pushq %rbx
movq 0x10(%rsp), %r10
movq 0x20(%rsp), %rbx
movslq 0x8(%rsi), %rax
leaq (%rax,%rax,2), %r11
shlq $0x3, %r11
movq (%r9), %rax
movsd (%rax), %xmm1
movsd 0x18(%rdi), %xmm0
addq (%rbx), %r11
ucomisd %xmm0, %xmm1
jae 0x5530
movq (%rdx), %r9
movq 0x8(%rdx), %rdx
subq %r9, %rdx
je 0x5578
sarq $0x3, %rdx
movq (%r11), %r11
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %ebx, %ebx
movsd 0x8(%rdi), %xmm0
movsd (%r11,%rbx,8), %xmm1
mulsd (%r9,%rbx,8), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r11,%rbx,8)
incq %rbx
cmpq %rbx, %rdx
jne 0x550b
jmp 0x5578
movq (%rdx), %r9
movq 0x8(%rdx), %rdx
subq %r9, %rdx
je 0x5578
divsd %xmm1, %xmm0
sarq $0x3, %rdx
movq (%r11), %r11
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %ebx, %ebx
movsd (%r11,%rbx,8), %xmm1
movsd 0x8(%rdi), %xmm2
mulsd %xmm0, %xmm2
mulsd (%r9,%rbx,8), %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, (%r11,%rbx,8)
incq %rbx
cmpq %rbx, %rdx
jne 0x5551
movq 0x18(%rsp), %rdx
movslq (%rsi), %r9
leaq (%r9,%r9,2), %r11
shlq $0x3, %r11
movsd 0x8(%rax), %xmm1
movsd 0x18(%rdi), %xmm0
addq (%r10), %r11
ucomisd %xmm0, %xmm1
jae 0x55e2
movq (%rcx), %r9
movq 0x8(%rcx), %rcx
subq %r9, %rcx
je 0x562b
sarq $0x3, %rcx
movq (%r11), %r10
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %r11d, %r11d
movsd 0x8(%rdi), %xmm0
movsd (%r10,%r11,8), %xmm1
mulsd (%r9,%r11,8), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r10,%r11,8)
incq %r11
cmpq %r11, %rcx
jne 0x55bd
jmp 0x562b
movq (%rcx), %r9
movq 0x8(%rcx), %rcx
subq %r9, %rcx
je 0x562b
divsd %xmm1, %xmm0
sarq $0x3, %rcx
movq (%r11), %r10
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %r11d, %r11d
movsd (%r10,%r11,8), %xmm1
movsd 0x8(%rdi), %xmm2
mulsd %xmm0, %xmm2
mulsd (%r9,%r11,8), %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, (%r10,%r11,8)
incq %r11
cmpq %r11, %rcx
jne 0x5604
movslq 0x4(%rsi), %rcx
leaq (%rcx,%rcx,2), %rsi
shlq $0x3, %rsi
movsd 0x10(%rax), %xmm1
movsd 0x18(%rdi), %xmm0
addq (%rdx), %rsi
ucomisd %xmm0, %xmm1
jae 0x5689
movq (%r8), %rax
movq 0x8(%r8), %rcx
subq %rax, %rcx
je 0x56ce
sarq $0x3, %rcx
movq (%rsi), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
movsd 0x8(%rdi), %xmm0
movsd (%rdx,%rsi,8), %xmm1
mulsd (%rax,%rsi,8), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x5667
jmp 0x56ce
movq (%r8), %rax
movq 0x8(%r8), %rcx
subq %rax, %rcx
je 0x56ce
divsd %xmm1, %xmm0
sarq $0x3, %rcx
movq (%rsi), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
movsd 0x8(%rdi), %xmm2
mulsd %xmm0, %xmm2
mulsd (%rax,%rsi,8), %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x56aa
popq %rbx
retq