// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rsp, %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x10a2d
movl %ebp, %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movsd 0x3804c(%rip), %xmm0    # 0x49080
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 0x8(%rsp), %rax
cmpq 0x8(%rbx), %rax
jne 0x112da
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2de68
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x48(%rsp), %rdi
callq 0xd660
testl %ebp, %ebp
jle 0x110df
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 0x112bb
cmpq %rsi, 0x10(%rbx)
jle 0x112bb
movq (%rbx), %rdi
movsd (%rdi,%rdx), %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rdi,%rdx)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %r14
jne 0x110ae
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2ae46
movq %r12, 0x28(%rsp)
cmpb $0x0, 0x74(%rsp)
je 0x11337
movq 0x8(%rsp), %rax
cmpq %rax, 0x40(%rsp)
jne 0x11318
movq %rbp, %r12
movq %r13, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq 0x48(%rsp), %rbp
testq %rbp, %rbp
js 0x112f9
cmpq %rbp, %rax
je 0x11169
movq (%rsp), %rdi
callq 0xd660
testq %rbp, %rbp
je 0x11161
movq %rbp, %rax
shrq $0x3d, %rax
jne 0x11375
leaq (,%rbp,8), %rdi
callq 0xd750
testq %rax, %rax
je 0x11375
movq %rax, (%rsp)
jmp 0x11169
movq $0x0, (%rsp)
movq %rbp, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
movq %r15, %rbp
movq %r15, %rsi
callq 0x2c6dc
movq 0x60(%rsp), %rdi
callq 0xd660
movq 0x50(%rsp), %rdi
callq 0xd660
movq 0x38(%rsp), %rdi
callq 0xd660
movq %rbp, 0x38(%rsp)
cmpq $0x0, 0x8(%rsp)
movq %r12, %rbp
je 0x111c0
movq %r13, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2ad2e
movq 0x28(%rsp), %r12
jmp 0x111c9
xorpd %xmm0, %xmm0
movq 0x28(%rsp), %r12
ucomisd 0x37e97(%rip), %xmm0    # 0x49068
jb 0x111d9
sqrtsd %xmm0, %xmm0
jmp 0x111de
callq 0xd3f0
movsd 0x37e7a(%rip), %xmm1    # 0x49060
divsd %xmm0, %xmm1
movq %r15, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movsd %xmm1, 0x48(%rsp)
testq %rax, %rax
js 0x11356
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x2ac56
testl %ebp, %ebp
jle 0x11263
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 0x112bb
cmpq %rsi, 0x10(%rbx)
jle 0x112bb
movq (%rbx), %rdi
movsd (%rdi,%rdx), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rdi,%rdx)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %r14
jne 0x1123a
movsd 0x10(%rsp), %xmm2
movapd %xmm2, %xmm0
subsd 0x30(%rsp), %xmm0
andpd 0x37eb5(%rip), %xmm0    # 0x49130
movsd 0x37e05(%rip), %xmm1    # 0x49088
ucomisd %xmm0, %xmm1
ja 0x1129d
incl %r12d
movapd %xmm2, %xmm0
cmpl $0x3e8, %r12d           # imm = 0x3E8
jne 0x1103c
movq (%rsp), %rdi
callq 0xd660
movsd 0x10(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c765(%rip), %rdi     # 0x4da27
leaq 0x3c793(%rip), %rsi     # 0x4da5c
leaq 0x3c7b5(%rip), %rcx     # 0x4da85
movl $0x151, %edx            # imm = 0x151
callq 0xd340
leaq 0x3e167(%rip), %rdi     # 0x4f448
leaq 0x3e1f0(%rip), %rsi     # 0x4f4d8
leaq 0x40250(%rip), %rcx     # 0x5153f
movl $0x5f, %edx
callq 0xd340
leaq 0x3bd9b(%rip), %rdi     # 0x4d09b
leaq 0x3bd6b(%rip), %rsi     # 0x4d072
leaq 0x3bf28(%rip), %rcx     # 0x4d236
movl $0xf1, %edx
callq 0xd340
leaq 0x3e737(%rip), %rdi     # 0x4fa56
leaq 0x3c802(%rip), %rsi     # 0x4db28
leaq 0x3e643(%rip), %rcx     # 0x4f970
movl $0xbe, %edx
callq 0xd340
leaq 0x3e604(%rip), %rdi     # 0x4f942
leaq 0x3c7e3(%rip), %rsi     # 0x4db28
leaq 0x3e624(%rip), %rcx     # 0x4f970
movl $0xbc, %edx
callq 0xd340
leaq 0x3bb5d(%rip), %rdi     # 0x4ceba
leaq 0x3bbf3(%rip), %rsi     # 0x4cf57
leaq 0x3c092(%rip), %rcx     # 0x4d3fd
movl $0x3f, %edx
callq 0xd340
movl $0x8, %edi
callq 0xd260
movq 0x67bea(%rip), %rcx     # 0x78f70
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x67c0c(%rip), %rsi     # 0x78fa0
movq 0x67ba5(%rip), %rdx     # 0x78f40
movq %rax, %rdi
callq 0xd990
jmp 0x113a5
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1d970
jmp 0x113c8
jmp 0x113c5
movq %rax, %rbx
movq 0x48(%rsp), %rdi
callq 0xd660
jmp 0x113c8
movq %rax, %rbx
movq (%rsp), %rdi
callq 0xd660
movq %rbx, %rdi
callq 0xd9c0
nop