// File: /workspace/github_c_makefile_star2_O2/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 0x6669f
movq %rbx, 0x10(%rsp)
movq 0x28(%rbx), %rbx
xorl %r13d, %r13d
movslq 0x4(%rbp), %rax
cmpq %rax, %r13
jge 0x66ab6
xorl %r15d, %r15d
movslq (%rbp), %rax
cmpq %rax, %r15
jg 0x66ab1
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 0x669e3
mulsd 0x8(%rsp), %xmm0
movq 0x20(%rsp), %rax
mulsd (%rax,%r15,8), %xmm0
movq (%rbx,%r13,8), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
jmp 0x66a67
incq %r13
jmp 0x66a5b
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
xorl %r15d, %r15d
movslq (%rbp), %rax
cmpq %rax, %r15
jge 0x66bad
xorl %r13d, %r13d
movslq 0x8(%rbp), %rax
cmpq %rax, %r13
jge 0x66ba5
movq %r12, %rdi
movl %r13d, %esi
callq 0x2aea2
movsd %xmm0, 0x18(%rsp)
movq 0x18(%rbp), %rax
movq 0x28(%rbp), %rcx
movq (%rax,%r15,8), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x38(%rsp)
movq (%rcx), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x40(%rsp)
xorpd %xmm1, %xmm1
xorl %ebx, %ebx
movslq 0x4(%rbp), %rdi
cmpq %rdi, %rbx
jge 0x66b5b
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
movsd %xmm1, 0x8(%rsp)
callq 0x669e3
movsd 0x8(%rsp), %xmm1
movq 0x38(%rbp), %rax
movq (%rax,%rbx,8), %rax
mulsd (%rax,%r15,8), %xmm0
addsd %xmm0, %xmm1
incq %rbx
jmp 0x66b22
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
jmp 0x66ad7
incq %r15
jmp 0x66ac7
movq 0x10(%rsp), %rcx
movq 0x18(%rcx), %r15
xorl %r13d, %r13d
cltq
cmpq %rax, %r13
jge 0x66c80
movq 0x28(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x18(%rsp)
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
movslq 0x4(%rbp), %rdi
cmpq %rdi, %rbx
jge 0x66c22
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
movsd %xmm0, 0x8(%rsp)
callq 0x669e3
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
jmp 0x66bdd
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 0x6687d
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
movl (%rbp), %eax
jmp 0x66bb9
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq