// File: /workspace/github_c_makefile_star2_O1/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, 0x28(%rsp)
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, 0x10(%rsp)
movq %r9, 0x18(%rsp)
movq %r9, %rsi
callq 0x6e487
cmpl $0x0, 0x4(%rbp)
jle 0x6e8e6
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rbx
xorl %r13d, %r13d
cmpl $0x0, (%rbp)
movq 0x18(%rsp), %rax
js 0x6e8da
movq $-0x1, %r15
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x4(%rbp), %edi
movq %r12, %rsi
movl %r13d, %edx
movq %r14, %rcx
callq 0x6e7fe
movq 0x28(%rsp), %rdx
mulsd 0x8(%rsp), %xmm0
mulsd 0x8(%rdx,%r15,8), %xmm0
movq (%rbx,%r13,8), %rax
movsd %xmm0, 0x8(%rax,%r15,8)
movslq (%rbp), %rax
incq %r15
cmpq %rax, %r15
movq 0x18(%rsp), %rax
jl 0x6e890
incq %r13
movslq 0x4(%rbp), %rax
cmpq %rax, %r13
jl 0x6e87e
cmpl $0x0, (%rbp)
jle 0x6e9ec
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
xorl %r15d, %r15d
cmpl $0x0, 0x8(%rbp)
jle 0x6e9dc
xorl %r13d, %r13d
movq %r12, %rdi
movl %r13d, %esi
callq 0x2e4b6
movsd %xmm0, 0x20(%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 0x6e98a
xorl %ebx, %ebx
movsd %xmm1, 0x8(%rsp)
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
callq 0x6e7fe
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 0x6e953
movq 0x18(%rsp), %rax
mulsd 0x28(%rax), %xmm1
movq 0x28(%rsp), %rax
mulsd (%rax,%r15,8), %xmm1
movsd 0x20(%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), %rax
cmpq %rax, %r13
jl 0x6e90e
incq %r15
movslq (%rbp), %rax
cmpq %rax, %r15
jl 0x6e901
cmpl $0x0, (%rbp)
jle 0x6eac8
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, 0x20(%rsp)
movl 0x4(%rbp), %edi
xorpd %xmm0, %xmm0
testl %edi, %edi
jle 0x6ea65
xorl %ebx, %ebx
movsd %xmm0, 0x8(%rsp)
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
callq 0x6e7fe
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 0x6ea22
movq 0x18(%rsp), %rax
mulsd 0x28(%rax), %xmm0
movq 0x28(%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 0x6e693
mulsd 0x8(%rsp), %xmm0
movsd 0x20(%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 0x6ea02
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq