// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
movq 0x18(%rsp), %r10
movq 0x28(%rsp), %rbx
movslq 0x8(%rsi), %rax
imulq $0x18, %rax, %r11
movq (%r9), %rax
movsd (%rax), %xmm1
movsd 0x18(%rdi), %xmm0
addq (%rbx), %r11
ucomisd %xmm0, %xmm1
jae 0x4f38
movq (%rdx), %r9
movq 0x8(%rdx), %rdx
subq %r9, %rdx
sarq $0x3, %rdx
xorl %ebx, %ebx
cmpq %rbx, %rdx
je 0x4f78
movsd 0x8(%rdi), %xmm0
movq (%r11), %r14
mulsd (%r9,%rbx,8), %xmm0
movsd (%r14,%rbx,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r14,%rbx,8)
incq %rbx
jmp 0x4f10
divsd %xmm1, %xmm0
movq (%rdx), %r9
movq 0x8(%rdx), %rdx
subq %r9, %rdx
sarq $0x3, %rdx
xorl %ebx, %ebx
cmpq %rbx, %rdx
je 0x4f78
movq (%r11), %r14
movsd 0x8(%rdi), %xmm1
mulsd %xmm0, %xmm1
mulsd (%r9,%rbx,8), %xmm1
movsd (%r14,%rbx,8), %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, (%r14,%rbx,8)
incq %rbx
jmp 0x4f4c
movq 0x20(%rsp), %rdx
movslq (%rsi), %r9
imulq $0x18, %r9, %r9
movsd 0x8(%rax), %xmm1
movsd 0x18(%rdi), %xmm0
addq (%r10), %r9
ucomisd %xmm0, %xmm1
jae 0x4fd0
movq (%rcx), %r10
movq 0x8(%rcx), %rcx
subq %r10, %rcx
sarq $0x3, %rcx
xorl %r11d, %r11d
cmpq %r11, %rcx
je 0x5011
movsd 0x8(%rdi), %xmm0
movq (%r9), %rbx
mulsd (%r10,%r11,8), %xmm0
movsd (%rbx,%r11,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rbx,%r11,8)
incq %r11
jmp 0x4fa8
divsd %xmm1, %xmm0
movq (%rcx), %r10
movq 0x8(%rcx), %rcx
subq %r10, %rcx
sarq $0x3, %rcx
xorl %r11d, %r11d
cmpq %r11, %rcx
je 0x5011
movq (%r9), %rbx
movsd 0x8(%rdi), %xmm1
mulsd %xmm0, %xmm1
mulsd (%r10,%r11,8), %xmm1
movsd (%rbx,%r11,8), %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, (%rbx,%r11,8)
incq %r11
jmp 0x4fe5
movslq 0x4(%rsi), %rcx
imulq $0x18, %rcx, %rcx
movsd 0x10(%rax), %xmm1
movsd 0x18(%rdi), %xmm0
addq (%rdx), %rcx
ucomisd %xmm0, %xmm1
jae 0x5063
movq (%r8), %rax
movq 0x8(%r8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x50a2
movsd 0x8(%rdi), %xmm0
movq (%rcx), %r8
mulsd (%rax,%rsi,8), %xmm0
movsd (%r8,%rsi,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r8,%rsi,8)
incq %rsi
jmp 0x503c
divsd %xmm1, %xmm0
movq (%r8), %rax
movq 0x8(%r8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x50a2
movq (%rcx), %r8
movsd 0x8(%rdi), %xmm1
mulsd %xmm0, %xmm1
mulsd (%rax,%rsi,8), %xmm1
movsd (%r8,%rsi,8), %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, (%r8,%rsi,8)
incq %rsi
jmp 0x5077
popq %rbx
popq %r14
retq