// File: /workspace/github_c_makefile_star2_O3/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 0x93ea5
leaq 0x10(%rsp), %rcx
leaq 0x1de19(%rip), %rdx     # 0xb1b34
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl (%rdi), %eax
cmpl $-0x1, %eax
je 0x93eb5
xorpd %xmm0, %xmm0
movl (%rsi), %ecx
cmpl $-0x1, %ecx
je 0x93eb9
cmpl %ecx, %eax
jne 0x93d56
movsd 0x8(%rdi), %xmm1
mulsd 0x8(%rsi), %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rdi
jmp 0x93d58
jle 0x93d5e
addq $0x10, %rsi
jmp 0x93d62
addq $0x10, %rdi
movl (%rdi), %eax
cmpl $-0x1, %eax
jne 0x93d33
jmp 0x93eb9
leaq 0x41afb(%rip), %rax     # 0xd5870
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 0x93eb9
movl (%rdi), %eax
xorpd %xmm1, %xmm1
cmpl $-0x1, %eax
je 0x93ed5
movl (%rsi), %edx
cmpl $-0x1, %edx
je 0x93ebb
cmpl %edx, %eax
jne 0x93dd7
movsd 0x8(%rdi), %xmm0
subsd 0x8(%rsi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
addq $0x10, %rdi
jmp 0x93de6
jle 0x93dec
movsd 0x8(%rsi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
addq $0x10, %rsi
jmp 0x93dfd
movsd 0x8(%rdi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
addq $0x10, %rdi
movl (%rdi), %eax
jmp 0x93da7
movsd 0x10(%rcx), %xmm0
movl (%rdi), %eax
xorpd %xmm1, %xmm1
cmpl $-0x1, %eax
je 0x93e40
movl (%rsi), %edx
cmpl $-0x1, %edx
je 0x93e40
cmpl %edx, %eax
jne 0x93e30
movsd 0x8(%rdi), %xmm2
mulsd 0x8(%rsi), %xmm2
addsd %xmm2, %xmm1
addq $0x10, %rdi
jmp 0x93e32
jle 0x93e38
addq $0x10, %rsi
jmp 0x93e3c
addq $0x10, %rdi
movl (%rdi), %eax
jmp 0x93e0c
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 0x93e8e
movl (%rsi), %edx
cmpl $-0x1, %edx
je 0x93e8e
cmpl %edx, %eax
jne 0x93e7e
movsd 0x8(%rdi), %xmm2
mulsd 0x8(%rsi), %xmm2
addsd %xmm2, %xmm1
addq $0x10, %rdi
jmp 0x93e80
jle 0x93e86
addq $0x10, %rsi
jmp 0x93e8a
addq $0x10, %rdi
movl (%rdi), %eax
jmp 0x93e5a
mulsd %xmm1, %xmm0
addsd 0x18(%rcx), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x8(%rcx), %xmm1
popq %rax
jmp 0x42f0
leaq 0x1dc9c(%rip), %rdi     # 0xb1b48
movl %eax, %esi
xorl %eax, %eax
callq 0x4030
xorpd %xmm0, %xmm0
popq %rax
retq
addq $0x10, %rdi
movsd -0x8(%rdi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
cmpl $-0x1, (%rdi)
leaq 0x10(%rdi), %rdi
jne 0x93ebf
cmpl $-0x1, (%rsi)
je 0x93ef4
addq $0x10, %rsi
movsd -0x8(%rsi), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
cmpl $-0x1, (%rsi)
leaq 0x10(%rsi), %rsi
jne 0x93ede
movsd 0x10(%rcx), %xmm0
xorpd 0x122cf(%rip), %xmm0    # 0xa61d0
mulsd %xmm1, %xmm0
popq %rax
jmp 0x4060