// File: /workspace/github_c_makefile_star2_O1/zpole[P]IICV/vl/homkermap.c
// Function: vl_homogeneouskernelmap_new
VlHomogeneousKernelMap *
vl_homogeneouskernelmap_new (VlHomogeneousKernelType kernelType,
                             double gamma,
                             vl_size order,
                             double period,
                             VlHomogeneousKernelMapWindowType windowType)
{
  int tableWidth, tableHeight ;
  VlHomogeneousKernelMap * self = vl_malloc(sizeof(VlHomogeneousKernelMap)) ;
  if (! self) return NULL ;

  assert(gamma > 0) ;

  assert(kernelType == VlHomogeneousKernelIntersection ||
         kernelType == VlHomogeneousKernelChi2 ||
         kernelType == VlHomogeneousKernelJS) ;

  assert(windowType == VlHomogeneousKernelMapWindowUniform ||
         windowType == VlHomogeneousKernelMapWindowRectangular) ;

  if (period < 0) {
    switch (windowType) {
    case VlHomogeneousKernelMapWindowUniform:
      switch (kernelType) {
      case VlHomogeneousKernelChi2:         period = 5.86 * sqrt(order + 0)  + 3.65 ; break ;
      case VlHomogeneousKernelJS:           period = 6.64 * sqrt(order + 0)  + 7.24 ; break ;
      case VlHomogeneousKernelIntersection: period = 2.38 * log(order + 0.8) + 5.6 ; break ;
      }
      break ;
    case VlHomogeneousKernelMapWindowRectangular:
      switch (kernelType) {
      case VlHomogeneousKernelChi2:         period = 8.80 * sqrt(order + 4.44) - 12.6 ; break ;
      case VlHomogeneousKernelJS:           period = 9.63 * sqrt(order + 1.00) - 2.93;  break ;
      case VlHomogeneousKernelIntersection: period = 2.00 * log(order + 0.99)  + 3.52 ; break ;
      }
      break ;
    }
    period = VL_MAX(period, 1.0) ;
  }

  self->kernelType = kernelType ;
  self->windowType = windowType ;
  self->gamma = gamma ;
  self->order = order ;
  self->period = period ;
  self->numSubdivisions = 8 + 8*order ;
  self->subdivision = 1.0 / self->numSubdivisions ;
  self->minExponent = -20 ;
  self->maxExponent = 8 ;

  tableHeight = (int) (2*self->order + 1) ;
  tableWidth = (int) (self->numSubdivisions * (self->maxExponent - self->minExponent + 1)) ;
  self->table = vl_malloc (sizeof(double) *
                           (tableHeight * tableWidth + 2*(1+self->order))) ;
  if (! self->table) {
    vl_free(self) ;
    return NULL ;
  }

  {
    vl_index exponent ;
    vl_uindex i, j ;
    double * tablep = self->table ;
    double * kappa = self->table + tableHeight * tableWidth ;
    double * freq = kappa + (1+self->order) ;
    double L = 2.0 * VL_PI / self->period ;

    /* precompute the sampled periodicized spectrum */
    j = 0 ;
    i = 0 ;
    while (i <= self->order) {
      freq[i] = j ;
      kappa[i] = vl_homogeneouskernelmap_get_smooth_spectrum(self, j * L) ;
      ++ j ;
      if (kappa[i] > 0 || j >= 3*i) ++ i ;
    }

    /* fill table */
    for (exponent  = self->minExponent ;
         exponent <= self->maxExponent ; ++ exponent) {

      double x, Lxgamma, Llogx, xgamma ;
      double sqrt2kappaLxgamma ;
      double mantissa = 1.0 ;

      for (i = 0 ; i < self->numSubdivisions ;
           ++i, mantissa += self->subdivision) {
        x = ldexp(mantissa, (int)exponent) ;
        xgamma = pow(x, self->gamma) ;
        Lxgamma = L * xgamma ;
        Llogx = L * log(x) ;

        *tablep++ = sqrt(Lxgamma * kappa[0]) ;
        for (j = 1 ; j <= self->order ; ++j) {
          sqrt2kappaLxgamma = sqrt(2.0 * Lxgamma * kappa[j]) ;
          *tablep++ = sqrt2kappaLxgamma * cos(freq[j] * Llogx) ;
          *tablep++ = sqrt2kappaLxgamma * sin(freq[j] * Llogx) ;
        }
      } /* next mantissa */
    } /* next exponent */
  }
  return self ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %edx, %ebp
movsd %xmm1, 0x8(%rsp)
movq %rsi, %r14
movsd %xmm0, 0x10(%rsp)
movl %edi, %r15d
movl $0x50, %edi
callq 0x95b0
testq %rax, %rax
je 0x170bd
movq %rax, %rbx
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x16af3
cmpl $0x1, %ebp
je 0x1691c
testl %ebp, %ebp
jne 0x16aeb
testl %r15d, %r15d
je 0x169fa
cmpl $0x2, %r15d
je 0x1697c
cmpl $0x1, %r15d
jne 0x16aeb
movq %r14, %xmm1
punpckldq 0x1c892(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c89a(%rip), %xmm1    # 0x33190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x16ab7
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x16ac0
testl %r15d, %r15d
je 0x16a41
cmpl $0x2, %r15d
je 0x169b7
cmpl $0x1, %r15d
jne 0x16aeb
movq %r14, %xmm1
punpckldq 0x1c83a(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c842(%rip), %xmm1    # 0x33190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
addsd 0x1d0ce(%rip), %xmm0    # 0x33a30
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x16ad2
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x16adb
movq %r14, %xmm1
punpckldq 0x1c7f7(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c7ff(%rip), %xmm1    # 0x33190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x16a81
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x16a8a
movq %r14, %xmm1
punpckldq 0x1c7bc(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c7c4(%rip), %xmm1    # 0x33190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
addsd 0x1c880(%rip), %xmm0    # 0x33260
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x16a9c
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x16aa5
movq %r14, %xmm1
punpckldq 0x1c779(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c781(%rip), %xmm1    # 0x33190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
addsd 0x1c835(%rip), %xmm0    # 0x33258
callq 0x9430
movapd %xmm0, %xmm1
mulsd 0x1d014(%rip), %xmm1    # 0x33a48
addsd 0x1d014(%rip), %xmm1    # 0x33a50
jmp 0x16aeb
movq %r14, %xmm1
punpckldq 0x1c732(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c73a(%rip), %xmm1    # 0x33190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
addsd 0x1cfa6(%rip), %xmm0    # 0x33a10
callq 0x9430
movapd %xmm0, %xmm1
addsd %xmm0, %xmm1
addsd 0x1cf99(%rip), %xmm1    # 0x33a18
jmp 0x16aeb
callq 0x9990
movapd %xmm0, %xmm1
mulsd 0x1cfc6(%rip), %xmm1    # 0x33a58
addsd 0x1cfc6(%rip), %xmm1    # 0x33a60
jmp 0x16aeb
callq 0x9990
movapd %xmm0, %xmm1
mulsd 0x1cf73(%rip), %xmm1    # 0x33a20
addsd 0x1cf73(%rip), %xmm1    # 0x33a28
jmp 0x16aeb
callq 0x9990
movapd %xmm0, %xmm1
mulsd 0x1cfa0(%rip), %xmm1    # 0x33a68
addsd 0x1cfa0(%rip), %xmm1    # 0x33a70
jmp 0x16aeb
callq 0x9990
movapd %xmm0, %xmm1
mulsd 0x1cf55(%rip), %xmm1    # 0x33a38
addsd 0x1cf55(%rip), %xmm1    # 0x33a40
maxsd 0x1c76d(%rip), %xmm1    # 0x33260
movl %r15d, (%rbx)
movl %ebp, 0x10(%rbx)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rbx)
movq %r14, 0x18(%rbx)
movsd %xmm1, 0x20(%rbx)
leaq 0x8(,%r14,8), %rax
movq %rax, 0x28(%rbx)
movq %rax, %xmm0
punpckldq 0x1c65a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1c662(%rip), %xmm0    # 0x33190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x1c71e(%rip), %xmm0    # 0x33260
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rbx)
movq $-0x14, 0x38(%rbx)
movq $0x8, 0x40(%rbx)
leal 0x1(,%r14,2), %ecx
imull %ecx, %eax
leal (%rax,%rax,8), %ecx
leal (%rcx,%rcx,2), %ecx
addl %eax, %eax
addl %ecx, %eax
movslq %eax, %r15
leaq (%r15,%r14,2), %rax
leaq 0x10(,%rax,8), %rdi
callq 0x95b0
movq %rax, 0x48(%rbx)
testq %rax, %rax
je 0x170b5
movq %rax, %r14
movq %r15, 0x78(%rsp)
leaq (%rax,%r15,8), %r12
movq 0x18(%rbx), %rax
movsd 0x1c7f7(%rip), %xmm0    # 0x333a0
divsd 0x20(%rbx), %xmm0
movsd %xmm0, 0x48(%rsp)
movq %rax, 0x70(%rsp)
leaq (%r12,%rax,8), %r15
addq $0x8, %r15
xorl %ebp, %ebp
xorpd %xmm2, %xmm2
xorl %r13d, %r13d
movq %r13, %xmm0
punpckldq 0x1c5a9(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1c5b1(%rip), %xmm0    # 0x33190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, (%r15,%rbp,8)
mulsd 0x48(%rsp), %xmm1
movapd %xmm1, 0x30(%rsp)
movsd 0x20(%rbx), %xmm0
mulsd 0x1c8ee(%rip), %xmm0    # 0x334f8
movsd 0x1ce66(%rip), %xmm3    # 0x33a78
divsd %xmm0, %xmm3
movapd %xmm3, %xmm1
addsd %xmm3, %xmm1
divsd 0x1ce5a(%rip), %xmm1    # 0x33a80
movl 0x10(%rbx), %eax
cmpl $0x1, %eax
je 0x16c7d
testl %eax, %eax
jne 0x170d4
movl (%rbx), %eax
cmpl $0x2, %eax
je 0x16ea6
cmpl $0x1, %eax
je 0x16e66
testl %eax, %eax
jne 0x170d4
movapd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd 0x1c5dc(%rip), %xmm0    # 0x33240
mulsd %xmm1, %xmm0
addsd 0x1c5f0(%rip), %xmm0    # 0x33260
movsd 0x1ce20(%rip), %xmm1    # 0x33a98
jmp 0x16f06
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jb 0x16e59
movapd %xmm3, %xmm4
xorpd 0x1c439(%rip), %xmm4    # 0x330d0
movapd %xmm3, 0x60(%rsp)
movapd %xmm1, 0x80(%rsp)
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%rbx), %xmm1
mulsd 0x1c517(%rip), %xmm1    # 0x331d0
mulsd %xmm4, %xmm1
ucomisd %xmm2, %xmm1
movsd 0x1c597(%rip), %xmm0    # 0x33260
movapd %xmm4, 0x10(%rsp)
jne 0x16cd3
jnp 0x16cf6
movapd %xmm1, %xmm0
movsd %xmm1, (%rsp)
callq 0x9860
movapd 0x10(%rsp), %xmm4
movapd 0x60(%rsp), %xmm3
xorpd %xmm2, %xmm2
divsd (%rsp), %xmm0
movsd 0x20(%rbx), %xmm6
divsd 0x1c69d(%rip), %xmm6    # 0x333a0
movapd 0x30(%rsp), %xmm1
addsd %xmm4, %xmm1
movl (%rbx), %eax
cmpl $0x2, %eax
movsd %xmm0, (%rsp)
je 0x16dab
cmpl $0x1, %eax
je 0x16d4f
testl %eax, %eax
jne 0x170d4
movapd %xmm1, %xmm0
mulsd 0x1c50a(%rip), %xmm0    # 0x33240
mulsd %xmm1, %xmm0
addsd 0x1c51e(%rip), %xmm0    # 0x33260
movsd 0x1cd4e(%rip), %xmm1    # 0x33a98
jmp 0x16e27
movapd %xmm1, %xmm0
mulsd 0x1cc2d(%rip), %xmm0    # 0x33988
movsd %xmm6, 0x28(%rsp)
movapd %xmm1, 0x50(%rsp)
callq 0x9a60
movsd %xmm0, 0x40(%rsp)
movapd 0x50(%rsp), %xmm0
mulsd 0x1cd08(%rip), %xmm0    # 0x33a88
callq 0x9a60
movsd 0x28(%rsp), %xmm6
movapd 0x10(%rsp), %xmm4
movapd 0x60(%rsp), %xmm3
xorpd %xmm2, %xmm2
addsd 0x40(%rsp), %xmm0
movsd 0x1cccf(%rip), %xmm1    # 0x33a78
jmp 0x16e27
movapd %xmm1, %xmm0
mulsd 0x1cbd1(%rip), %xmm0    # 0x33988
movsd %xmm6, 0x28(%rsp)
movapd %xmm1, 0x50(%rsp)
callq 0x9a60
movsd %xmm0, 0x40(%rsp)
movapd 0x50(%rsp), %xmm0
mulsd 0x1ccac(%rip), %xmm0    # 0x33a88
callq 0x9a60
movsd 0x28(%rsp), %xmm6
movapd 0x10(%rsp), %xmm4
movapd 0x60(%rsp), %xmm3
xorpd %xmm2, %xmm2
addsd 0x40(%rsp), %xmm0
movsd 0x1cc8b(%rip), %xmm1    # 0x33a90
divsd %xmm0, %xmm1
movapd 0x50(%rsp), %xmm5
movapd %xmm5, %xmm0
mulsd 0x1c425(%rip), %xmm0    # 0x33240
mulsd %xmm5, %xmm0
addsd 0x1c439(%rip), %xmm0    # 0x33260
divsd %xmm0, %xmm1
movsd (%rsp), %xmm5
mulsd %xmm6, %xmm5
mulsd %xmm1, %xmm5
movsd 0x8(%rsp), %xmm0
addsd %xmm5, %xmm0
movapd 0x80(%rsp), %xmm1
addsd %xmm1, %xmm4
ucomisd %xmm4, %xmm3
jae 0x16ca6
mulsd %xmm0, %xmm1
maxsd %xmm2, %xmm1
jmp 0x16f0a
movapd 0x30(%rsp), %xmm0
mulsd 0x1cb14(%rip), %xmm0    # 0x33988
callq 0x9a60
movsd %xmm0, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
mulsd 0x1cbfb(%rip), %xmm0    # 0x33a88
callq 0x9a60
xorpd %xmm2, %xmm2
addsd 0x10(%rsp), %xmm0
movsd 0x1cbd4(%rip), %xmm1    # 0x33a78
jmp 0x16f06
movapd 0x30(%rsp), %xmm0
mulsd 0x1cad4(%rip), %xmm0    # 0x33988
callq 0x9a60
movsd %xmm0, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
mulsd 0x1cbbb(%rip), %xmm0    # 0x33a88
callq 0x9a60
xorpd %xmm2, %xmm2
addsd 0x10(%rsp), %xmm0
movsd 0x1cbac(%rip), %xmm1    # 0x33a90
divsd %xmm0, %xmm1
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm0
mulsd 0x1c346(%rip), %xmm0    # 0x33240
mulsd %xmm3, %xmm0
addsd 0x1c35a(%rip), %xmm0    # 0x33260
divsd %xmm0, %xmm1
movsd %xmm1, (%r12,%rbp,8)
incq %r13
ucomisd %xmm2, %xmm1
seta %al
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
cmpq %rcx, %r13
setae %cl
orb %al, %cl
movzbl %cl, %eax
addq %rax, %rbp
cmpq 0x18(%rbx), %rbp
jbe 0x16bca
movq 0x38(%rbx), %rax
movq %rax, 0x28(%rsp)
cmpq 0x40(%rbx), %rax
jg 0x170bf
movq 0x78(%rsp), %rax
shlq $0x3, %rax
movq 0x70(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
leaq (%r14,%rax), %r13
addq $0x10, %r13
cmpq $0x0, 0x28(%rbx)
je 0x1709b
movsd 0x1c2e3(%rip), %xmm0    # 0x33260
xorl %ebp, %ebp
movsd %xmm0, 0x50(%rsp)
movq 0x28(%rsp), %rdi
callq 0x90c0
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rbx), %xmm1
callq 0x9270
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x9430
movsd %xmm0, 0x8(%rsp)
movsd (%r12), %xmm0
mulsd (%rsp), %xmm0
ucomisd 0x1c062(%rip), %xmm0    # 0x33030
jb 0x16fd6
sqrtsd %xmm0, %xmm0
jmp 0x16fdb
callq 0x9990
movsd %xmm0, (%r14)
addq $0x8, %r14
cmpq $0x0, 0x18(%rbx)
je 0x17083
movsd 0x8(%rsp), %xmm0
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movl $0x1, %r15d
movsd (%r12,%r15,8), %xmm0
mulsd (%rsp), %xmm0
ucomisd 0x1c008(%rip), %xmm0    # 0x33030
jb 0x17030
sqrtsd %xmm0, %xmm0
jmp 0x17035
callq 0x9990
movsd %xmm0, 0x10(%rsp)
movsd -0x8(%r13,%r15,8), %xmm0
mulsd 0x8(%rsp), %xmm0
callq 0x9450
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, (%r14)
movsd -0x8(%r13,%r15,8), %xmm0
mulsd 0x8(%rsp), %xmm0
callq 0x9860
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%r14)
addq $0x10, %r14
incq %r15
cmpq 0x18(%rbx), %r15
jbe 0x17015
incq %rbp
movsd 0x50(%rsp), %xmm0
addsd 0x30(%rbx), %xmm0
cmpq 0x28(%rbx), %rbp
jb 0x16f7f
movq 0x28(%rsp), %rcx
leaq 0x1(%rcx), %rax
cmpq 0x40(%rbx), %rcx
movq %rax, 0x28(%rsp)
jl 0x16f6a
jmp 0x170bf
movq %rbx, %rdi
callq 0x9580
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90b0