// File: /workspace/github_c_makefile_star2_O1/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 %rax
movl 0x14(%rsp), %eax
cmpq $0x4, %rax
ja 0x91493
leaq 0x10(%rsp), %rcx
leaq 0x1d800(%rip), %rdx     # 0xaeabc
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl (%rdi), %eax
cmpl $-0x1, %eax
je 0x914a3
xorpd %xmm0, %xmm0
movl (%rsi), %ecx
cmpl $-0x1, %ecx
je 0x914a7
cmpl %ecx, %eax
jne 0x912f7
movsd 0x8(%rdi), %xmm1
mulsd 0x8(%rsi), %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rdi
jmp 0x912f9
jle 0x912ff
addq $0x10, %rsi
jmp 0x91303
addq $0x10, %rdi
movl (%rdi), %eax
cmpl $-0x1, %eax
jne 0x912d4
jmp 0x914a7
leaq 0x4155a(%rip), %rax     # 0xd2870
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 0x914a7
movl (%rdi), %eax
xorpd %xmm1, %xmm1
cmpl $-0x1, %eax
je 0x9139a
movl (%rsi), %edx
cmpl $-0x1, %edx
je 0x9139a
cmpl %edx, %eax
jne 0x91370
movsd 0x8(%rdi), %xmm0
subsd 0x8(%rsi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
addq $0x10, %rdi
jmp 0x9137f
jle 0x91385
movsd 0x8(%rsi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
addq $0x10, %rsi
jmp 0x91396
movsd 0x8(%rdi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
addq $0x10, %rdi
movl (%rdi), %eax
jmp 0x91348
cmpl $-0x1, (%rdi)
je 0x913b9
addq $0x10, %rdi
movsd -0x8(%rdi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
cmpl $-0x1, (%rdi)
leaq 0x10(%rdi), %rdi
jne 0x913a3
cmpl $-0x1, (%rsi)
je 0x913d8
addq $0x10, %rsi
movsd -0x8(%rsi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
cmpl $-0x1, (%rsi)
leaq 0x10(%rsi), %rsi
jne 0x913c2
movsd 0x10(%rcx), %xmm0
xorpd 0x11deb(%rip), %xmm0    # 0xa31d0
mulsd %xmm1, %xmm0
popq %rax
jmp 0x4060
movsd 0x10(%rcx), %xmm0
movl (%rdi), %eax
xorpd %xmm1, %xmm1
cmpl $-0x1, %eax
je 0x9142e
movl (%rsi), %edx
cmpl $-0x1, %edx
je 0x9142e
cmpl %edx, %eax
jne 0x9141e
movsd 0x8(%rdi), %xmm2
mulsd 0x8(%rsi), %xmm2
addsd %xmm2, %xmm1
addq $0x10, %rdi
jmp 0x91420
jle 0x91426
addq $0x10, %rsi
jmp 0x9142a
addq $0x10, %rdi
movl (%rdi), %eax
jmp 0x913fa
mulsd %xmm1, %xmm0
addsd 0x18(%rcx), %xmm0
popq %rax
jmp 0x4040
movsd 0x10(%rcx), %xmm0
movl (%rdi), %eax
xorpd %xmm1, %xmm1
cmpl $-0x1, %eax
je 0x9147c
movl (%rsi), %edx
cmpl $-0x1, %edx
je 0x9147c
cmpl %edx, %eax
jne 0x9146c
movsd 0x8(%rdi), %xmm2
mulsd 0x8(%rsi), %xmm2
addsd %xmm2, %xmm1
addq $0x10, %rdi
jmp 0x9146e
jle 0x91474
addq $0x10, %rsi
jmp 0x91478
addq $0x10, %rdi
movl (%rdi), %eax
jmp 0x91448
mulsd %xmm1, %xmm0
addsd 0x18(%rcx), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x8(%rcx), %xmm1
popq %rax
jmp 0x42f0
leaq 0x1d636(%rip), %rdi     # 0xaead0
movl %eax, %esi
xorl %eax, %eax
callq 0x4030
xorpd %xmm0, %xmm0
popq %rax
retq