// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/rbf.c
// Function: rbf_backward_propagation
Rbfweights rbf_backward_propagation(Rbfnetworkptr network, Instanceptr inst, double* p, double* y, Rbf_parameterptr params)
{
	/*!Last Changed 19.08.2007*/
	int i, h, j;
	double sum, x_j, m_hj, s_h;
 Rbfweights changeinweights;
 allocate_rbfweights(&changeinweights, params);
	/*Update wih*/
	for (i = 0; i < network->output; i++)
		 for (h = 0; h < network->hidden + 1; h++)
				 changeinweights.w.values[i][h] = params->eta * real_actual_difference(network->output, inst, i, y) * p[h];
	/*Update mhj*/
	for (h = 0; h < network->hidden; h++)
		 for (j = 0; j < network->input; j++)
			 {
				 x_j = real_feature(inst, j);
					m_hj = network->weights.m.values[h][j];
					s_h = network->weights.s.values[0][h];
				 sum = 0.0;
				 for (i = 0; i < network->output; i++)
						 sum += real_actual_difference(network->output, inst, i, y) * network->weights.w.values[i][h];
					changeinweights.m.values[h][j] = (params->eta * sum * p[h] * (x_j - m_hj)) / (s_h * s_h);   
			 }
	/*Update sh*/
	for (h = 0; h < network->hidden; h++)
	 {
		 s_h = network->weights.s.values[0][h];
			sum = 0.0;
			for (i = 0; i < network->output; i++)
					sum += real_actual_difference(network->output, inst, i, y) * network->weights.w.values[i][h];
			changeinweights.s.values[0][h] = (params->eta * sum * p[h] * distance_to_rbf_gaussian(inst, network->input, network->weights.m.values[h])) / (s_h * s_h * s_h);
	 }
 return changeinweights;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r14
movq %rcx, 0x20(%rsp)
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %rbx
movq %r9, 0x28(%rsp)
movq %r9, %rsi
callq 0x6fbf7
movl (%rbp), %eax
movl 0x4(%rbp), %ecx
testl %ecx, %ecx
movq %rbx, 0x10(%rsp)
jle 0x70056
movq 0x28(%rbx), %rbx
xorl %r13d, %r13d
testl %eax, %eax
js 0x7004b
movq $-0x1, %r15
movq 0x28(%rsp), %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x4(%rbp), %edi
movq %r12, %rsi
movl %r13d, %edx
movq %r14, %rcx
callq 0x6ff71
mulsd 0x8(%rsp), %xmm0
movq 0x20(%rsp), %rax
mulsd 0x8(%rax,%r15,8), %xmm0
movq (%rbx,%r13,8), %rax
movsd %xmm0, 0x8(%rax,%r15,8)
movslq (%rbp), %rax
incq %r15
cmpq %rax, %r15
jl 0x6fffe
movl 0x4(%rbp), %ecx
incq %r13
movslq %ecx, %rdx
cmpq %rdx, %r13
jl 0x6fff3
testl %eax, %eax
jle 0x70237
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x30(%rsp)
movl 0x8(%rbp), %ecx
xorl %r15d, %r15d
testl %ecx, %ecx
jle 0x7014e
xorl %r13d, %r13d
movq %r12, %rdi
movl %r13d, %esi
callq 0x2ed6a
movsd %xmm0, 0x18(%rsp)
movq 0x18(%rbp), %rax
movq (%rax,%r15,8), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x28(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x40(%rsp)
movl 0x4(%rbp), %edi
xorpd %xmm1, %xmm1
testl %edi, %edi
jle 0x700f9
xorl %ebx, %ebx
movsd %xmm1, 0x8(%rsp)
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
callq 0x6ff71
movsd 0x8(%rsp), %xmm1
movq 0x38(%rbp), %rax
movq (%rax,%rbx,8), %rax
mulsd (%rax,%r15,8), %xmm0
addsd %xmm0, %xmm1
incq %rbx
movslq 0x4(%rbp), %rdi
cmpq %rdi, %rbx
jl 0x700c2
movq 0x28(%rsp), %rax
mulsd 0x28(%rax), %xmm1
movq 0x20(%rsp), %rax
mulsd (%rax,%r15,8), %xmm1
movsd 0x18(%rsp), %xmm0
subsd 0x38(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm1
mulsd %xmm1, %xmm1
divsd %xmm1, %xmm0
movq 0x30(%rsp), %rax
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
movslq 0x8(%rbp), %rcx
cmpq %rcx, %r13
jl 0x7007d
movl (%rbp), %eax
incq %r15
movslq %eax, %rdx
cmpq %rdx, %r15
jl 0x70072
testl %eax, %eax
jle 0x70237
movq 0x10(%rsp), %rax
movq 0x18(%rax), %r15
xorl %r13d, %r13d
movq 0x28(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0x4(%rbp), %edi
xorpd %xmm0, %xmm0
testl %edi, %edi
jle 0x701d4
xorl %ebx, %ebx
movsd %xmm0, 0x8(%rsp)
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
callq 0x6ff71
movq 0x38(%rbp), %rax
movq (%rax,%rbx,8), %rax
mulsd (%rax,%r13,8), %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
incq %rbx
movslq 0x4(%rbp), %rdi
cmpq %rdi, %rbx
jl 0x70191
movq 0x28(%rsp), %rax
mulsd 0x28(%rax), %xmm0
movq 0x20(%rsp), %rax
mulsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x8(%rbp), %esi
movq 0x18(%rbp), %rax
movq (%rax,%r13,8), %rdx
movq %r12, %rdi
callq 0x6fe07
mulsd 0x8(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq (%r15), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
movslq (%rbp), %rax
cmpq %rax, %r13
jl 0x70171
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq