// File: /workspace/github_c_makefile_star2_O3/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 0x16fe9
movq %rax, %rbx
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x16a0c
cmpl $0x1, %ebp
je 0x168a7
testl %ebp, %ebp
jne 0x16a04
testl %r15d, %r15d
je 0x16982
cmpl $0x2, %r15d
je 0x16906
cmpl $0x1, %r15d
jne 0x16a04
movq %r14, %xmm0
punpckldq 0x1b906(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b90e(%rip), %xmm0    # 0x32190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm1
mulsd 0x1c1be(%rip), %xmm1    # 0x32a58
addsd 0x1c1be(%rip), %xmm1    # 0x32a60
jmp 0x16a04
testl %r15d, %r15d
je 0x169c6
cmpl $0x2, %r15d
je 0x16940
cmpl $0x1, %r15d
jne 0x16a04
movq %r14, %xmm0
punpckldq 0x1b8af(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b8b7(%rip), %xmm0    # 0x32190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x1c133(%rip), %xmm1    # 0x32a20
sqrtsd %xmm1, %xmm1
mulsd 0x1c12f(%rip), %xmm1    # 0x32a28
addsd 0x1c12f(%rip), %xmm1    # 0x32a30
jmp 0x16a04
movq %r14, %xmm0
punpckldq 0x1b86d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b875(%rip), %xmm0    # 0x32190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm1
mulsd 0x1c115(%rip), %xmm1    # 0x32a48
addsd 0x1c115(%rip), %xmm1    # 0x32a50
jmp 0x16a04
movq %r14, %xmm0
punpckldq 0x1b833(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b83b(%rip), %xmm0    # 0x32190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x1b907(%rip), %xmm1    # 0x32270
sqrtsd %xmm1, %xmm1
mulsd 0x1c09b(%rip), %xmm1    # 0x32a10
addsd 0x1c09b(%rip), %xmm1    # 0x32a18
jmp 0x16a04
movq %r14, %xmm1
punpckldq 0x1b7f1(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1b7f9(%rip), %xmm1    # 0x32190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
addsd 0x1b8bd(%rip), %xmm0    # 0x32268
callq 0x9430
movapd %xmm0, %xmm1
mulsd 0x1c07c(%rip), %xmm1    # 0x32a38
addsd 0x1c07c(%rip), %xmm1    # 0x32a40
jmp 0x16a04
movq %r14, %xmm1
punpckldq 0x1b7ad(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1b7b5(%rip), %xmm1    # 0x32190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
addsd 0x1c011(%rip), %xmm0    # 0x32a00
callq 0x9430
movapd %xmm0, %xmm1
addsd %xmm0, %xmm1
addsd 0x1c004(%rip), %xmm1    # 0x32a08
maxsd 0x1b864(%rip), %xmm1    # 0x32270
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 0x1b741(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b749(%rip), %xmm0    # 0x32190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x1b815(%rip), %xmm0    # 0x32270
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 0x16fe1
movq %rax, %r14
movq %r15, 0x78(%rsp)
leaq (%rax,%r15,8), %r12
movq 0x18(%rbx), %rax
movsd 0x1b8ee(%rip), %xmm0    # 0x323b0
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 0x1b690(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b698(%rip), %xmm0    # 0x32190
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 0x1b9d5(%rip), %xmm0    # 0x324f8
movsd 0x1bf3d(%rip), %xmm3    # 0x32a68
divsd %xmm0, %xmm3
movapd %xmm3, %xmm1
addsd %xmm3, %xmm1
divsd 0x1bf31(%rip), %xmm1    # 0x32a70
movl 0x10(%rbx), %eax
cmpl $0x1, %eax
je 0x16b96
testl %eax, %eax
jne 0x17000
movl (%rbx), %eax
cmpl $0x2, %eax
je 0x16dc3
cmpl $0x1, %eax
je 0x16d83
testl %eax, %eax
jne 0x17000
movapd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd 0x1b6d3(%rip), %xmm0    # 0x32250
mulsd %xmm1, %xmm0
addsd 0x1b6e7(%rip), %xmm0    # 0x32270
movsd 0x1bef7(%rip), %xmm1    # 0x32a88
jmp 0x16e23
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jb 0x16d76
movapd %xmm3, %xmm4
xorpd 0x1b520(%rip), %xmm4    # 0x320d0
movapd %xmm3, 0x60(%rsp)
movapd %xmm1, 0x80(%rsp)
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%rbx), %xmm5
movapd %xmm5, %xmm1
mulsd 0x1b60a(%rip), %xmm1    # 0x321e0
mulsd %xmm4, %xmm1
ucomisd %xmm2, %xmm1
movsd 0x1b68a(%rip), %xmm0    # 0x32270
movapd %xmm4, 0x10(%rsp)
jne 0x16bf0
jnp 0x16c18
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), %xmm5
divsd 0x1b790(%rip), %xmm5    # 0x323b0
movapd 0x30(%rsp), %xmm1
addsd %xmm4, %xmm1
movl (%rbx), %eax
cmpl $0x2, %eax
movsd %xmm0, (%rsp)
je 0x16cc8
cmpl $0x1, %eax
je 0x16c6c
testl %eax, %eax
jne 0x17000
movapd %xmm1, %xmm0
mulsd 0x1b5fd(%rip), %xmm0    # 0x32250
mulsd %xmm1, %xmm0
addsd 0x1b611(%rip), %xmm0    # 0x32270
movsd 0x1be21(%rip), %xmm1    # 0x32a88
jmp 0x16d44
movapd %xmm1, %xmm0
mulsd 0x1bd10(%rip), %xmm0    # 0x32988
movsd %xmm5, 0x28(%rsp)
movapd %xmm1, 0x50(%rsp)
callq 0x9a60
movsd %xmm0, 0x40(%rsp)
movapd 0x50(%rsp), %xmm0
mulsd 0x1bddb(%rip), %xmm0    # 0x32a78
callq 0x9a60
movsd 0x28(%rsp), %xmm5
movapd 0x10(%rsp), %xmm4
movapd 0x60(%rsp), %xmm3
xorpd %xmm2, %xmm2
addsd 0x40(%rsp), %xmm0
movsd 0x1bda2(%rip), %xmm1    # 0x32a68
jmp 0x16d44
movapd %xmm1, %xmm0
mulsd 0x1bcb4(%rip), %xmm0    # 0x32988
movsd %xmm5, 0x28(%rsp)
movapd %xmm1, 0x50(%rsp)
callq 0x9a60
movsd %xmm0, 0x40(%rsp)
movapd 0x50(%rsp), %xmm0
mulsd 0x1bd7f(%rip), %xmm0    # 0x32a78
callq 0x9a60
movsd 0x28(%rsp), %xmm5
movapd 0x10(%rsp), %xmm4
movapd 0x60(%rsp), %xmm3
xorpd %xmm2, %xmm2
addsd 0x40(%rsp), %xmm0
movsd 0x1bd5e(%rip), %xmm1    # 0x32a80
divsd %xmm0, %xmm1
movapd 0x50(%rsp), %xmm6
movapd %xmm6, %xmm0
mulsd 0x1b518(%rip), %xmm0    # 0x32250
mulsd %xmm6, %xmm0
addsd 0x1b52c(%rip), %xmm0    # 0x32270
divsd %xmm0, %xmm1
movsd (%rsp), %xmm6
mulsd %xmm5, %xmm6
mulsd %xmm1, %xmm6
movsd 0x8(%rsp), %xmm0
addsd %xmm6, %xmm0
movapd 0x80(%rsp), %xmm1
addsd %xmm1, %xmm4
ucomisd %xmm4, %xmm3
jae 0x16bbf
mulsd %xmm0, %xmm1
maxsd %xmm2, %xmm1
jmp 0x16e27
movapd 0x30(%rsp), %xmm0
mulsd 0x1bbf7(%rip), %xmm0    # 0x32988
callq 0x9a60
movsd %xmm0, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
mulsd 0x1bcce(%rip), %xmm0    # 0x32a78
callq 0x9a60
xorpd %xmm2, %xmm2
addsd 0x10(%rsp), %xmm0
movsd 0x1bca7(%rip), %xmm1    # 0x32a68
jmp 0x16e23
movapd 0x30(%rsp), %xmm0
mulsd 0x1bbb7(%rip), %xmm0    # 0x32988
callq 0x9a60
movsd %xmm0, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
mulsd 0x1bc8e(%rip), %xmm0    # 0x32a78
callq 0x9a60
xorpd %xmm2, %xmm2
addsd 0x10(%rsp), %xmm0
movsd 0x1bc7f(%rip), %xmm1    # 0x32a80
divsd %xmm0, %xmm1
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm0
mulsd 0x1b439(%rip), %xmm0    # 0x32250
mulsd %xmm3, %xmm0
addsd 0x1b44d(%rip), %xmm0    # 0x32270
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 0x16ae3
movq 0x38(%rbx), %rcx
movq 0x40(%rbx), %rax
movq %rcx, 0x28(%rsp)
cmpq %rax, %rcx
jg 0x16feb
movq 0x28(%rbx), %rcx
movq 0x78(%rsp), %rdx
shlq $0x3, %rdx
movq 0x70(%rsp), %rsi
leaq (%rdx,%rsi,8), %rdx
leaq (%r14,%rdx), %r13
addq $0x10, %r13
testq %rcx, %rcx
je 0x16fc6
movsd 0x1b3d1(%rip), %xmm0    # 0x32270
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 0x1b140(%rip), %xmm0    # 0x32030
jb 0x16ef8
sqrtsd %xmm0, %xmm0
jmp 0x16efd
callq 0x9990
movsd %xmm0, (%r14)
addq $0x8, %r14
cmpq $0x0, 0x18(%rbx)
je 0x16fa5
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 0x1b0e6(%rip), %xmm0    # 0x32030
jb 0x16f52
sqrtsd %xmm0, %xmm0
jmp 0x16f57
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 0x16f37
incq %rbp
movsd 0x50(%rsp), %xmm0
addsd 0x30(%rbx), %xmm0
movq 0x28(%rbx), %rcx
cmpq %rcx, %rbp
jb 0x16ea1
movq 0x40(%rbx), %rax
jmp 0x16fc8
xorl %ecx, %ecx
movq 0x28(%rsp), %rsi
leaq 0x1(%rsi), %rdx
cmpq %rax, %rsi
movq %rdx, 0x28(%rsp)
jl 0x16e8e
jmp 0x16feb
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