// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/svmkernel.c
// Function: k_function
double k_function(Svm_nodeptr x, Svm_nodeptr y, Svm_parameter param)
{
	/*Last Changed 26.04.2005*/
	double sum, d;
	switch (param.kernel_type)
	 {
 		case    KLINEAR :return dot(x, y);
				                break;
		 case    KPOLY   :return pow(param.gamma * dot(x, y) + param.coef0, param.degree);
				                break;
		 case    KRBF    :sum = 0;
               		 	 while (x->index != -1 && y->index !=-1)
					   												 {
             		  	   	if (x->index == y->index)
																   			 {
					                   d = x->value - y->value;
					                   sum += d*d;
					                   ++x;
					                   ++y;
						   													 }
				                  else
		   																	 {
					                   if (x->index > y->index)
																		   			 {	
						                    sum += y->value * y->value;
						                    ++y;
												   									 }
					                   else
								   									  			{
						                    sum += x->value * x->value;
				   		                 ++x;
		   																			 }
   																			 }
																   	 }
			                 while (x->index != -1)
												   					 { 
				                  sum += x->value * x->value;
				                  ++x;
						   											 }
			                 while (y->index != -1)
		   															 {
   				               sum += y->value * y->value;
				                  ++y;
																   	 }
			                 return exp(-param.gamma * sum);
										 	   				 break;
		 case    KSIGMOID:return tanh(param.gamma * dot(x, y) + param.coef0);
			                 break;
   case KPREDEFINED:return current_dataset->kernel->values[(int)x->value][(int)y->value];
                    break;
		 default         :printf(m1232, param.kernel_type);
                    return 0;				            
	 }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl 0x24(%rsp), %eax
cmpq $0x4, %rax
ja 0x85a7b
leaq 0x20(%rsp), %rbx
leaq 0x1c157(%rip), %rcx     # 0xa1a94
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x10, %rsp
popq %rbx
jmp 0x855cf
leaq 0x47f19(%rip), %rax     # 0xcd870
movq (%rax), %rax
movq 0x1407210(%rax), %rax
cvttsd2si 0x8(%rdi), %ecx
movq 0x8(%rax), %rax
cvttsd2si 0x8(%rsi), %edx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq %edx, %rcx
movsd (%rax,%rcx,8), %xmm0
jmp 0x85a8e
leaq 0x10(%rdi), %rax
xorpd %xmm0, %xmm0
movl (%rdi), %ecx
cmpl $-0x1, %ecx
je 0x859f4
movl (%rsi), %edx
cmpl $-0x1, %edx
je 0x859f4
cmpl %edx, %ecx
je 0x859b2
jle 0x859ca
movsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rsi
jmp 0x8598d
movsd 0x8(%rdi), %xmm1
subsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rsi
jmp 0x859d7
movsd 0x8(%rdi), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rdi
addq $0x10, %rax
jmp 0x8598b
movsd -0x8(%rax), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
movl (%rax), %ecx
addq $0x10, %rax
cmpl $-0x1, %ecx
jne 0x859e1
jmp 0x85a0c
movsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rsi
cmpl $-0x1, (%rsi)
jne 0x859fb
movsd 0x10(%rbx), %xmm1
xorpd 0x107b2(%rip), %xmm1    # 0x961d0
mulsd %xmm1, %xmm0
addq $0x10, %rsp
popq %rbx
jmp 0x4060
movsd 0x10(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x855cf
mulsd 0x8(%rsp), %xmm0
addsd 0x18(%rbx), %xmm0
addq $0x10, %rsp
popq %rbx
jmp 0x4040
movsd 0x10(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x855cf
mulsd 0x8(%rsp), %xmm0
addsd 0x18(%rbx), %xmm0
cvtsi2sdl 0x8(%rbx), %xmm1
addq $0x10, %rsp
popq %rbx
jmp 0x42f0
leaq 0x1c026(%rip), %rdi     # 0xa1aa8
movl %eax, %esi
xorl %eax, %eax
callq 0x4030
xorps %xmm0, %xmm0
addq $0x10, %rsp
popq %rbx
retq