// File: /workspace/github_cpp_makefile_star2_O1/Kingsford-Group[P]ghost2/src/sigApprox.hpp
// Function: inverseIter(Eigen::Matrix<double, -1, -1, 0, -1, -1>*, double)
double inverseIter(MatrixXd *A, double mu)
{
  int N=(*A).rows(); // rows and cols should be the same
  double prev=200, cur;  // dummy value
  bool flag=false;
  VectorXd seed = randomVec(N);
  for(int i=0;i<N;i++)
    (*A)(i,i) -= mu;
  LDLT<MatrixXd,Lower> ALU = (*A).ldlt();
  for(int i=0;i<1000;i++)
  {
    VectorXd temp = seed;
    seed = ALU.solve(seed);
    cur = normalize(&seed); // in place
    if(fabs(cur-prev) < ZERO) 
    {
      for(int i=0;i<N;i++)
        if(fabs(temp(i)) > ZERO)
        {
          cur*=(temp(i)*seed(i)>0)?1:-1;
          break;
        }
      flag=true;
      break;
    }
    prev=cur;
  }
  for(int i=0;i<N;i++)
    (*A)(i,i) += mu;
//  if(!flag) cout << "warning: did not converge\n"; // uncomment for warning
  cur = 1.0/cur + mu;
  return cur;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movsd %xmm0, 0x18(%rsp)
movq %rdi, %rbx
movq 0x8(%rdi), %r12
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
callq 0x10a2d
testl %r12d, %r12d
jle 0x10c74
movq 0x8(%rbx), %rsi
xorl %eax, %eax
testq %rsi, %rsi
movl $0x0, %ecx
cmovgq %rsi, %rcx
movl %r12d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq 0x8(,%rsi,8), %rsi
xorl %edi, %edi
cmpq %rdi, %rcx
je 0x10f1f
cmpq %rdi, 0x10(%rbx)
jle 0x10f1f
movq (%rbx), %r8
movsd (%r8,%rax), %xmm0
subsd 0x18(%rsp), %xmm0
movsd %xmm0, (%r8,%rax)
incq %rdi
addq %rsi, %rax
cmpq %rdi, %rdx
jne 0x10c41
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x2ae46
movl %r12d, %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movsd 0x383ed(%rip), %xmm0    # 0x49080
movsd %xmm0, (%rsp)
xorl %r13d, %r13d
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x1d864
cmpb $0x0, 0x8c(%rsp)
je 0x10f7c
movq 0x10(%rsp), %rax
cmpq %rax, 0x58(%rsp)
jne 0x10f5d
leaq 0x50(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq %r15, 0x48(%rsp)
movq 0x60(%rsp), %rbp
testq %rbp, %rbp
js 0x10f3e
cmpq %rbp, %rax
je 0x10d2a
movq 0x8(%rsp), %rdi
callq 0xd660
testq %rbp, %rbp
je 0x10d21
movq %rbp, %rax
shrq $0x3d, %rax
jne 0x10f9b
leaq (,%rbp,8), %rdi
callq 0xd750
testq %rax, %rax
je 0x10f9b
movq %rax, 0x8(%rsp)
jmp 0x10d2a
movq $0x0, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x2c6dc
movq %r15, %rdi
callq 0x10b07
movapd %xmm0, %xmm2
testl %r12d, %r12d
setle %al
movapd %xmm0, %xmm3
subsd (%rsp), %xmm3
andpd 0x383d1(%rip), %xmm3    # 0x49130
movsd 0x38321(%rip), %xmm0    # 0x49088
ucomisd %xmm3, %xmm0
setbe %cl
movapd %xmm2, %xmm0
jbe 0x10d79
movsd (%rsp), %xmm0
orb %al, %cl
movapd %xmm3, 0x90(%rsp)
je 0x10d96
movapd %xmm2, 0x30(%rsp)
movsd %xmm0, (%rsp)
jmp 0x10e1e
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rdx
testq %rdx, %rdx
movl $0x0, %eax
cmovleq %rax, %rdx
xorl %eax, %eax
cmpq %rax, %rdx
je 0x10f00
movsd (%rcx,%rax,8), %xmm0
movapd %xmm0, %xmm1
andpd 0x38368(%rip), %xmm1    # 0x49130
ucomisd 0x382b8(%rip), %xmm1    # 0x49088
ja 0x10de2
incq %rax
cmpq %rax, %r14
jne 0x10dae
movapd %xmm2, 0x30(%rsp)
jmp 0x10e1e
cmpq %rax, 0x10(%rsp)
jle 0x10f00
movq 0x8(%rsp), %rcx
mulsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
cmpltsd %xmm0, %xmm1
movapd %xmm1, %xmm0
andpd %xmm2, %xmm0
xorpd 0x38330(%rip), %xmm2    # 0x49140
andnpd %xmm2, %xmm1
orpd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movq 0x20(%rsp), %rdi
callq 0xd660
movsd 0x38258(%rip), %xmm0    # 0x49088
ucomisd 0x90(%rsp), %xmm0
ja 0x10e4b
incl %r13d
cmpl $0x3e8, %r13d           # imm = 0x3E8
jne 0x10c9b
testl %r12d, %r12d
movapd 0x30(%rsp), %xmm1
jle 0x10eaa
movq 0x8(%rbx), %rdx
xorl %eax, %eax
testq %rdx, %rdx
movl $0x0, %ecx
cmovgq %rdx, %rcx
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leaq 0x8(,%rdx,8), %rdx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x10f1f
cmpq %rsi, 0x10(%rbx)
jle 0x10f1f
movq (%rbx), %rdi
movsd (%rdi,%rax), %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rdi,%rax)
incq %rsi
addq %rdx, %rax
cmpq %rsi, %r12
jne 0x10e79
movsd 0x381ae(%rip), %xmm0    # 0x49060
divsd %xmm1, %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq 0x78(%rsp), %rdi
callq 0xd660
movq 0x68(%rsp), %rdi
callq 0xd660
movq 0x50(%rsp), %rdi
callq 0xd660
movq 0x8(%rsp), %rdi
callq 0xd660
movsd (%rsp), %xmm0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3fbfa(%rip), %rdi     # 0x50b01
leaq 0x3cb4e(%rip), %rsi     # 0x4da5c
leaq 0x405a3(%rip), %rcx     # 0x514b8
movl $0x18a, %edx            # imm = 0x18A
callq 0xd340
leaq 0x3cb01(%rip), %rdi     # 0x4da27
leaq 0x3cb2f(%rip), %rsi     # 0x4da5c
leaq 0x3cb51(%rip), %rcx     # 0x4da85
movl $0x151, %edx            # imm = 0x151
callq 0xd340
leaq 0x3c156(%rip), %rdi     # 0x4d09b
leaq 0x3c126(%rip), %rsi     # 0x4d072
leaq 0x3c2e3(%rip), %rcx     # 0x4d236
movl $0xf1, %edx
callq 0xd340
leaq 0x3eaf2(%rip), %rdi     # 0x4fa56
leaq 0x3cbbd(%rip), %rsi     # 0x4db28
leaq 0x3e9fe(%rip), %rcx     # 0x4f970
movl $0xbe, %edx
callq 0xd340
leaq 0x3e9bf(%rip), %rdi     # 0x4f942
leaq 0x3cb9e(%rip), %rsi     # 0x4db28
leaq 0x3e9df(%rip), %rcx     # 0x4f970
movl $0xbc, %edx
callq 0xd340
movl $0x8, %edi
callq 0xd260
movq 0x67fc4(%rip), %rcx     # 0x78f70
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x67fe6(%rip), %rsi     # 0x78fa0
movq 0x67f7f(%rip), %rdx     # 0x78f40
movq %rax, %rdi
callq 0xd990
movq %rax, %rbx
jmp 0x10fee
jmp 0x10fd2
jmp 0x10fd2
movq %rax, %rbx
movq 0x20(%rsp), %rdi
callq 0xd660
jmp 0x10fe4
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x1d970
movq 0x8(%rsp), %rdi
callq 0xd660
movq %rbx, %rdi
callq 0xd9c0