// File: /workspace/github_cpp_makefile_star2_O3/Kingsford-Group[P]ghost2/src/sigApprox.hpp
// Function: rayleigh(Eigen::Matrix<double, -1, -1, 0, -1, -1>*)
double rayleigh(MatrixXd *A)
{
  int N=(*A).rows();
  double prev=200, cur;
  bool flag=false;
  VectorXd seed = randomVec(N);
  for(int i=0;i<1000;i++)
  {
    VectorXd mu = seed.transpose()*(*A)*seed;
    cur=mu[0];
    for(int i=0;i<N;i++)
      (*A)(i,i) -= cur;
    seed = (*A).ldlt().solve(seed);
    seed.normalize();
    for(int i=0;i<N;i++)
      (*A)(i,i) += cur;
    if(fabs(cur-prev) < ZERO) {flag=true; break;}
    prev=cur;
  }
//  if(!flag) cout << "warning: did not converge\n"; // uncomment for warning
  return cur;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rbp
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0xfa13
movl %ebp, %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movsd 0x38141(%rip), %xmm0    # 0x48080
xorl %r12d, %r12d
leaq 0x38(%rsp), %r13
movsd %xmm0, 0x30(%rsp)
movq %r15, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
leaq 0x48(%rsp), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq 0x28(%rsp), %rax
cmpq 0x8(%rbx), %rax
jne 0x10177
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2caba
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x48(%rsp), %rdi
callq 0xc660
testl %ebp, %ebp
jle 0xffea
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
movl $0x0, %eax
cmovgq %rcx, %rax
leaq 0x8(,%rcx,8), %rcx
xorl %edx, %edx
xorl %esi, %esi
cmpq %rsi, %rax
je 0x10158
cmpq %rsi, 0x10(%rbx)
jle 0x10158
movq (%rbx), %rdi
movsd (%rdi,%rdx), %xmm0
subsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rdi,%rdx)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %r14
jne 0xffb9
movq %r13, %rdi
movq %rbx, %rsi
callq 0x29980
cmpb $0x0, 0x74(%rsp)
je 0x101d4
movq 0x40(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x101b5
movq %r13, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2b2b6
movq 0x60(%rsp), %rdi
callq 0xc660
movq 0x50(%rsp), %rdi
callq 0xc660
movq 0x38(%rsp), %rdi
callq 0xc660
movq %r15, 0x38(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x10061
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2988c
jmp 0x10065
xorpd %xmm0, %xmm0
ucomisd 0x37ffb(%rip), %xmm0    # 0x48068
jb 0x10075
sqrtsd %xmm0, %xmm0
jmp 0x1007a
callq 0xc3f0
movsd 0x37fde(%rip), %xmm1    # 0x48060
divsd %xmm0, %xmm1
movq %r15, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x38(%rsp)
movsd %xmm1, 0x48(%rsp)
testq %rax, %rax
js 0x10196
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x29718
testl %ebp, %ebp
jle 0x100ff
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
movl $0x0, %eax
cmovgq %rcx, %rax
leaq 0x8(,%rcx,8), %rcx
xorl %edx, %edx
xorl %esi, %esi
cmpq %rsi, %rax
je 0x10158
cmpq %rsi, 0x10(%rbx)
jle 0x10158
movq (%rbx), %rdi
movsd (%rdi,%rdx), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rdi,%rdx)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %r14
jne 0x100d6
movsd 0x8(%rsp), %xmm2
movapd %xmm2, %xmm0
subsd 0x30(%rsp), %xmm0
andpd 0x38019(%rip), %xmm0    # 0x48130
movsd 0x37f69(%rip), %xmm1    # 0x48088
ucomisd %xmm0, %xmm1
ja 0x10139
incl %r12d
movapd %xmm2, %xmm0
cmpl $0x3e8, %r12d           # imm = 0x3E8
jne 0xff47
movq 0x20(%rsp), %rdi
callq 0xc660
movsd 0x8(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c8f8(%rip), %rdi     # 0x4ca57
leaq 0x3c926(%rip), %rsi     # 0x4ca8c
leaq 0x3c948(%rip), %rcx     # 0x4cab5
movl $0x151, %edx            # imm = 0x151
callq 0xc340
leaq 0x3e2fa(%rip), %rdi     # 0x4e478
leaq 0x3e383(%rip), %rsi     # 0x4e508
leaq 0x4018f(%rip), %rcx     # 0x5031b
movl $0x5f, %edx
callq 0xc340
leaq 0x3bd4d(%rip), %rdi     # 0x4beea
leaq 0x3bde3(%rip), %rsi     # 0x4bf87
leaq 0x3c282(%rip), %rcx     # 0x4c42d
movl $0x3f, %edx
callq 0xc340
leaq 0x3e8ca(%rip), %rdi     # 0x4ea86
leaq 0x3c995(%rip), %rsi     # 0x4cb58
leaq 0x3e7d6(%rip), %rcx     # 0x4e9a0
movl $0xbe, %edx
callq 0xc340
leaq 0x3e797(%rip), %rdi     # 0x4e972
leaq 0x3c976(%rip), %rsi     # 0x4cb58
leaq 0x3e7b7(%rip), %rcx     # 0x4e9a0
movl $0xbc, %edx
callq 0xc340
jmp 0x10213
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1c664
jmp 0x10216
movq %rax, %rbx
movq 0x48(%rsp), %rdi
callq 0xc660
jmp 0x10216
movq %rax, %rbx
movq 0x20(%rsp), %rdi
callq 0xc660
movq %rbx, %rdi
callq 0xc9c0