// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/poly.c
// Function: polyfitcls
Polynomptr polyfitcls(double** data, int datasize, int degree)
{
	/*!Last Changed 26.01.2005*/
	int i, j, *array;
	double random_value, o, y, eta, *deltaw, update;
	Polynomptr p = create_polynom();
	Polynodeptr node;
 for (i = 0; i <= degree; i++)
	 {
		 random_value = produce_random_value(-0.01, 0.01);
		 add_polynode_to_polynom(p, i, random_value);
	 }
	eta = get_parameter_f("learning_rate");
	deltaw = safecalloc((degree + 1), sizeof(double), "polyfitcls", 11);
	for (j = 0; j < get_parameter_i("perceptronrun"); j++)
	 {
			array = random_array(datasize);
			for (i = 0; i < datasize; i++)
			 {
				 o = polynom_value(p, data[array[i]][0]);
					y = sigmoid(o);
     node = p->start;
					while (node)
					 {
						 update = (eta * (data[array[i]][1] - y) * fpow(data[array[i]][0], node->power) + get_parameter_f("alpha") * deltaw[node->power]);
						 node->coefficient += update;
							deltaw[node->power] = update;
						 node = node->next;
					 }
			 }
			safe_free(array);
			eta *= get_parameter_f("etadecrease");
	 }
	safe_free(deltaw);
 return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r12d
movl %esi, 0x1c(%rsp)
movq %rdi, %r14
leaq 0x4d70d(%rip), %rsi     # 0xa7d42
movl $0x10, %edi
movl $0x1, %edx
callq 0x390f5
movq %rax, %r15
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
testl %r12d, %r12d
js 0x5a680
leal 0x1(%r12), %ebx
xorl %ebp, %ebp
movsd 0x48755(%rip), %xmm0    # 0xa2db8
movsd 0x48755(%rip), %xmm1    # 0xa2dc0
callq 0x39f62
movq %r15, %rdi
movl %ebp, %esi
callq 0x5908a
incl %ebp
cmpl %ebp, %ebx
jne 0x5a65b
leaq 0x48251(%rip), %rdi     # 0xa28d8
callq 0x534b6
movsd %xmm0, 0x8(%rsp)
incl %r12d
movslq %r12d, %rdi
leaq 0x4d6df(%rip), %rdx     # 0xa7d7e
movl $0x8, %esi
movl $0xb, %ecx
callq 0x39210
movq %rax, %r12
leaq 0x4822e(%rip), %rdi     # 0xa28e6
callq 0x5341c
testl %eax, %eax
jle 0x5a85a
movl 0x1c(%rsp), %eax
movq %rax, 0x40(%rsp)
xorl %ebx, %ebx
leaq 0x482f9(%rip), %r13     # 0xa29d0
movq %r15, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movl 0x1c(%rsp), %ebx
movl %ebx, %edi
callq 0x39fdc
movq %rax, %rbp
testl %ebx, %ebx
jle 0x5a81b
xorl %ebx, %ebx
movq (%r15), %r15
testq %r15, %r15
je 0x5a75e
movslq (%rbp,%rbx,4), %rax
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x8(%r15), %edi
movsd 0x20(%rsp), %xmm0
callq 0x38db2
mulsd 0x28(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x5a717
jmp 0x5a762
xorpd %xmm0, %xmm0
callq 0x54568
movq 0x30(%rsp), %rax
movq (%rax), %r15
testq %r15, %r15
movsd 0x8(%rsp), %xmm2
je 0x5a808
movapd %xmm0, %xmm1
movsd %xmm0, 0x20(%rsp)
movsd %xmm2, 0x8(%rsp)
movslq (%rbp,%rbx,4), %rax
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm3
subsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x10(%rsp)
movl 0x8(%r15), %edi
callq 0x38db2
movsd %xmm0, 0x28(%rsp)
movq %r13, %rdi
callq 0x534b6
movsd 0x8(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
movslq 0x8(%r15), %rax
mulsd (%r12,%rax,8), %xmm0
movsd 0x28(%rsp), %xmm3
mulsd 0x10(%rsp), %xmm3
addsd %xmm0, %xmm3
movsd (%r15), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%r15)
movsd %xmm3, (%r12,%rax,8)
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x5a78e
incq %rbx
cmpq 0x40(%rsp), %rbx
movq 0x30(%rsp), %r15
jne 0x5a6f9
movq %rbp, %rdi
callq 0x39194
leaq 0x480a2(%rip), %rdi     # 0xa28cc
callq 0x534b6
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq 0x38(%rsp), %rbx
incl %ebx
leaq 0x48099(%rip), %rdi     # 0xa28e6
callq 0x5341c
cmpl %eax, %ebx
jl 0x5a6dc
movq %r12, %rdi
callq 0x39194
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq