// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xd8, %rsp
movl %edi, 0xcc(%rsp)
movsd %xmm0, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movsd %xmm1, 0xb0(%rsp)
movl %edx, 0xac(%rsp)
movl $0x50, %edi
callq 0x9660
movq %rax, 0x98(%rsp)
cmpq $0x0, 0x98(%rsp)
jne 0x21b4d
movq $0x0, 0xd0(%rsp)
jmp 0x223cb
xorps %xmm0, %xmm0
ucomisd 0xb0(%rsp), %xmm0
jbe 0x21e48
movl 0xac(%rsp), %eax
movl %eax, 0x2c(%rsp)
testl %eax, %eax
je 0x21b82
jmp 0x21b70
movl 0x2c(%rsp), %eax
subl $0x1, %eax
je 0x21cbb
jmp 0x21e01
movl 0xcc(%rsp), %eax
movl %eax, 0x28(%rsp)
testl %eax, %eax
je 0x21c59
jmp 0x21b97
movl 0x28(%rsp), %eax
subl $0x1, %eax
je 0x21bb0
jmp 0x21ba2
movl 0x28(%rsp), %eax
subl $0x2, %eax
je 0x21c06
jmp 0x21cb6
movaps 0x375a9(%rip), %xmm1    # 0x59160
movq 0xb8(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x375a4(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x9b20
movsd 0x37ca8(%rip), %xmm1    # 0x59890
mulsd %xmm1, %xmm0
movsd 0x37ca4(%rip), %xmm1    # 0x59898
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
jmp 0x21cb6
movaps 0x37553(%rip), %xmm1    # 0x59160
movq 0xb8(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x3754e(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x9b20
movsd 0x37c42(%rip), %xmm1    # 0x59880
mulsd %xmm1, %xmm0
movsd 0x37c3e(%rip), %xmm1    # 0x59888
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
jmp 0x21cb6
movaps 0x37500(%rip), %xmm1    # 0x59160
movq 0xb8(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x374fb(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x37474(%rip), %xmm1    # 0x59100
addsd %xmm1, %xmm0
callq 0x94c0
movsd 0x37bd3(%rip), %xmm1    # 0x59870
mulsd %xmm1, %xmm0
movsd 0x37bcf(%rip), %xmm1    # 0x59878
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
jmp 0x21e01
movl 0xcc(%rsp), %eax
movl %eax, 0x24(%rsp)
testl %eax, %eax
je 0x21daa
jmp 0x21cd0
movl 0x24(%rsp), %eax
subl $0x1, %eax
je 0x21ce9
jmp 0x21cdb
movl 0x24(%rsp), %eax
subl $0x2, %eax
je 0x21d4b
jmp 0x21dff
movaps 0x37470(%rip), %xmm1    # 0x59160
movq 0xb8(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x3746b(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x37b4c(%rip), %xmm1    # 0x59868
addsd %xmm1, %xmm0
callq 0x9b20
movsd 0x37b2b(%rip), %xmm1    # 0x59858
mulsd %xmm1, %xmm0
movsd 0x37b27(%rip), %xmm1    # 0x59860
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
jmp 0x21dff
movaps 0x3740e(%rip), %xmm1    # 0x59160
movq 0xb8(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x37409(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x3735a(%rip), %xmm1    # 0x590d8
addsd %xmm1, %xmm0
callq 0x9b20
movsd 0x37ab9(%rip), %xmm1    # 0x59848
mulsd %xmm1, %xmm0
movsd 0x37ab5(%rip), %xmm1    # 0x59850
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
jmp 0x21dff
movaps 0x373af(%rip), %xmm1    # 0x59160
movq 0xb8(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x373aa(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x37a63(%rip), %xmm1    # 0x59840
addsd %xmm1, %xmm0
callq 0x94c0
addsd %xmm0, %xmm0
movsd 0x37a46(%rip), %xmm1    # 0x59838
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
jmp 0x21e01
movsd 0xb0(%rsp), %xmm0
movsd 0x372c6(%rip), %xmm1    # 0x590d8
ucomisd %xmm1, %xmm0
jbe 0x21e29
movsd 0xb0(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0x21e39
movsd 0x372a7(%rip), %xmm0    # 0x590d8
movsd %xmm0, 0x18(%rsp)
jmp 0x21e39
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movl 0xcc(%rsp), %ecx
movq 0x98(%rsp), %rax
movl %ecx, (%rax)
movl 0xac(%rsp), %ecx
movq 0x98(%rsp), %rax
movl %ecx, 0x10(%rax)
movsd 0xc0(%rsp), %xmm0
movq 0x98(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0xb8(%rsp), %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x18(%rax)
movsd 0xb0(%rsp), %xmm0
movq 0x98(%rsp), %rax
movsd %xmm0, 0x20(%rax)
movq 0xb8(%rsp), %rax
leaq 0x8(,%rax,8), %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x98(%rsp), %rax
movq 0x28(%rax), %xmm1
movaps 0x37285(%rip), %xmm0    # 0x59160
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x37289(%rip), %xmm0    # 0x59170
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x371da(%rip), %xmm0    # 0x590d8
divsd %xmm1, %xmm0
movq 0x98(%rsp), %rax
movsd %xmm0, 0x30(%rax)
movq 0x98(%rsp), %rax
movq $-0x14, 0x38(%rax)
movq 0x98(%rsp), %rax
movq $0x8, 0x40(%rax)
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rax
shlq %rax
addq $0x1, %rax
movl %eax, 0xa4(%rsp)
movq 0x98(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x98(%rsp), %rcx
movq 0x40(%rcx), %rcx
movq 0x98(%rsp), %rdx
subq 0x38(%rdx), %rcx
addq $0x1, %rcx
imulq %rcx, %rax
movl %eax, 0xa8(%rsp)
movl 0xa4(%rsp), %eax
imull 0xa8(%rsp), %eax
movslq %eax, %rdi
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x1, %rax
shlq %rax
addq %rax, %rdi
shlq $0x3, %rdi
callq 0x9660
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x98(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x21fe9
movq 0x98(%rsp), %rdi
callq 0x9620
movq $0x0, 0xd0(%rsp)
jmp 0x223cb
movq 0x98(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x98(%rsp), %rax
movq 0x48(%rax), %rax
movl 0xa4(%rsp), %ecx
imull 0xa8(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq 0x98(%rsp), %rcx
movq 0x18(%rcx), %rcx
addq $0x1, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x68(%rsp)
movq 0x98(%rsp), %rax
movsd 0x371db(%rip), %xmm0    # 0x59230
divsd 0x20(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpq 0x18(%rcx), %rax
ja 0x2216e
movq 0x80(%rsp), %xmm0
movaps 0x370be(%rip), %xmm2    # 0x59160
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x370c2(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm0
movaps %xmm0, %xmm3
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm3, %xmm0
movq 0x68(%rsp), %rax
movq 0x88(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x98(%rsp), %rdi
movq 0x80(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
mulsd 0x60(%rsp), %xmm0
callq 0x223e0
movq 0x70(%rsp), %rax
movq 0x88(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %rax
movq 0x88(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x22155
movq 0x80(%rsp), %rax
imulq $0x3, 0x88(%rsp), %rcx
cmpq %rcx, %rax
jb 0x22169
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x22078
movq 0x98(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpq 0x40(%rcx), %rax
jg 0x223bb
movsd 0x36f34(%rip), %xmm0    # 0x590d8
movsd %xmm0, 0x30(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x223a0
movsd 0x30(%rsp), %xmm0
movq 0x90(%rsp), %rax
movl %eax, %edi
callq 0x90c0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
movq 0x98(%rsp), %rax
movsd 0x8(%rax), %xmm1
callq 0x92b0
movsd %xmm0, 0x40(%rsp)
movsd 0x60(%rsp), %xmm0
mulsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x94c0
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x50(%rsp), %xmm0
movq 0x70(%rsp), %rax
mulsd (%rax), %xmm0
callq 0x9b20
movq 0x78(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x78(%rsp)
movsd %xmm0, (%rax)
movq $0x1, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpq 0x18(%rcx), %rax
ja 0x2236c
movsd 0x36e44(%rip), %xmm0    # 0x590e0
mulsd 0x50(%rsp), %xmm0
movq 0x70(%rsp), %rax
movq 0x80(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
callq 0x9b20
movsd %xmm0, 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq 0x68(%rsp), %rax
movq 0x80(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd 0x48(%rsp), %xmm0
callq 0x94e0
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x78(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x78(%rsp)
movsd %xmm0, (%rax)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x68(%rsp), %rax
movq 0x80(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd 0x48(%rsp), %xmm0
callq 0x99e0
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x78(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x78(%rsp)
movsd %xmm0, (%rax)
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x2227a
jmp 0x2236e
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
movq 0x98(%rsp), %rax
movsd 0x30(%rax), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x221b6
jmp 0x223a2
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x22182
movq 0x98(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
addq $0xd8, %rsp
retq
nopl (%rax,%rax)