// File: /workspace/github_cpp_makefile_star2_O2/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 $0xb8, %rsp
movsd %xmm0, (%rsp)
movq %rdi, %rbx
movl 0x8(%rdi), %r14d
leaq 0x30(%rsp), %rdi
movl %r14d, %esi
callq 0x10980
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
cmpq %r15, %r14
je 0x10a4b
movq %rbx, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x18b38
movsd (%rax), %xmm0
subsd (%rsp), %xmm0
movsd %xmm0, (%rax)
incq %r15
jmp 0x10a26
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x23c34
xorl %ebp, %ebp
movsd 0x2f5fe(%rip), %xmm0    # 0x40060
movsd %xmm0, 0x8(%rsp)
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %r12
cmpl $0x3e8, %ebp            # imm = 0x3E8
je 0x10b96
movq %r15, %rdi
movq %r12, %rsi
callq 0x18b82
leaq 0x78(%rsp), %rdi
movq %r12, %rsi
callq 0x18bc4
movq %rax, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
movq %r12, %rdi
leaq 0x40(%rsp), %rsi
callq 0x25dfa
movq %r12, %rdi
callq 0x109cb
movapd %xmm0, %xmm1
movapd %xmm0, %xmm2
subsd 0x8(%rsp), %xmm2
andpd 0x2f665(%rip), %xmm2    # 0x40130
movsd 0x2f595(%rip), %xmm0    # 0x40068
movapd %xmm2, 0x60(%rsp)
ucomisd %xmm2, %xmm0
movapd %xmm1, 0x10(%rsp)
ja 0x10af0
movsd %xmm1, 0x8(%rsp)
jmp 0x10b76
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x10b76
movq %r15, %rdi
movq %r13, %rsi
callq 0x18c1c
movsd (%rax), %xmm0
andpd 0x2f621(%rip), %xmm0    # 0x40130
incq %r13
ucomisd 0x2f54e(%rip), %xmm0    # 0x40068
jbe 0x10af3
decq %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x18c1c
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x18c1c
movsd 0x28(%rsp), %xmm1
mulsd (%rax), %xmm1
xorpd %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
movapd %xmm0, %xmm1
movapd 0x10(%rsp), %xmm2
andpd %xmm2, %xmm1
xorpd 0x2f5d8(%rip), %xmm2    # 0x40140
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movapd %xmm0, 0x10(%rsp)
movq 0x50(%rsp), %rdi
callq 0xe670
incl %ebp
movsd 0x2f4de(%rip), %xmm0    # 0x40068
ucomisd 0x60(%rsp), %xmm0
jbe 0x10a72
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x10bbe
movq %rbx, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x18b38
movsd (%rax), %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, (%rax)
incq %r15
jmp 0x10b99
movsd 0x2f4aa(%rip), %xmm0    # 0x40070
divsd 0x10(%rsp), %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
leaq 0x78(%rsp), %rdi
callq 0x18c52
movq 0x30(%rsp), %rdi
callq 0xe670
movsd (%rsp), %xmm0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10c0e
jmp 0x10c15
jmp 0x10c09
jmp 0x10c15
movq %rax, %rbx
jmp 0x10c22
movq %rax, %rbx
jmp 0x10c2c
jmp 0x10c15
movq %rax, %rbx
movq 0x50(%rsp), %rdi
callq 0xe670
leaq 0x78(%rsp), %rdi
callq 0x18c52
movq 0x30(%rsp), %rdi
callq 0xe670
movq %rbx, %rdi
callq 0xe9f0