// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/./Eigen/src/QR/ColPivHouseholderQR.h
// Function: Eigen::ColPivHouseholderQR<Eigen::Matrix<double, 3, 3, 0, 3, 3>>::compute(Eigen::Matrix<double, 3, 3, 0, 3, 3> const&)
ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const MatrixType& matrix)
{
  check_template_parameters();
  
  using std::abs;
  Index rows = matrix.rows();
  Index cols = matrix.cols();
  Index size = matrix.diagonalSize();
  
  // the column permutation is stored as int indices, so just to be sure:
  eigen_assert(cols<=NumTraits<int>::highest());

  m_qr = matrix;
  m_hCoeffs.resize(size);

  m_temp.resize(cols);

  m_colsTranspositions.resize(matrix.cols());
  Index number_of_transpositions = 0;

  m_colSqNorms.resize(cols);
  for(Index k = 0; k < cols; ++k)
    m_colSqNorms.coeffRef(k) = m_qr.col(k).squaredNorm();

  RealScalar threshold_helper = m_colSqNorms.maxCoeff() * numext::abs2(NumTraits<Scalar>::epsilon()) / RealScalar(rows);

  m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case)
  m_maxpivot = RealScalar(0);

  for(Index k = 0; k < size; ++k)
  {
    // first, we look up in our table m_colSqNorms which column has the biggest squared norm
    Index biggest_col_index;
    RealScalar biggest_col_sq_norm = m_colSqNorms.tail(cols-k).maxCoeff(&biggest_col_index);
    biggest_col_index += k;

    // since our table m_colSqNorms accumulates imprecision at every step, we must now recompute
    // the actual squared norm of the selected column.
    // Note that not doing so does result in solve() sometimes returning inf/nan values
    // when running the unit test with 1000 repetitions.
    biggest_col_sq_norm = m_qr.col(biggest_col_index).tail(rows-k).squaredNorm();

    // we store that back into our table: it can't hurt to correct our table.
    m_colSqNorms.coeffRef(biggest_col_index) = biggest_col_sq_norm;

    // Track the number of meaningful pivots but do not stop the decomposition to make
    // sure that the initial matrix is properly reproduced. See bug 941.
    if(m_nonzero_pivots==size && biggest_col_sq_norm < threshold_helper * RealScalar(rows-k))
      m_nonzero_pivots = k;

    // apply the transposition to the columns
    m_colsTranspositions.coeffRef(k) = biggest_col_index;
    if(k != biggest_col_index) {
      m_qr.col(k).swap(m_qr.col(biggest_col_index));
      std::swap(m_colSqNorms.coeffRef(k), m_colSqNorms.coeffRef(biggest_col_index));
      ++number_of_transpositions;
    }

    // generate the householder vector, store it below the diagonal
    RealScalar beta;
    m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);

    // apply the householder transformation to the diagonal coefficient
    m_qr.coeffRef(k,k) = beta;

    // remember the maximum absolute value of diagonal coefficients
    if(abs(beta) > m_maxpivot) m_maxpivot = abs(beta);

    // apply the householder transformation
    m_qr.bottomRightCorner(rows-k, cols-k-1)
        .applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &m_temp.coeffRef(k+1));

    // update our table of squared norms of the columns
    m_colSqNorms.tail(cols-k-1) -= m_qr.row(k).tail(cols-k-1).cwiseAbs2();
  }

  m_colsPermutation.setIdentity(PermIndexType(cols));
  for(PermIndexType k = 0; k < size/*m_nonzero_pivots*/; ++k)
    m_colsPermutation.applyTranspositionOnTheRight(k, PermIndexType(m_colsTranspositions.coeff(k)));

  m_det_pq = (number_of_transpositions%2) ? -1 : 1;
  m_isInitialized = true;

  return *this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
callq 0xc51b0
leaq 0xa0(%rbx), %rbp
xorl %r14d, %r14d
leaq 0x88(%rsp), %r15
cmpq $0x3, %r14
je 0xc4ac8
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xc5222
movq %r15, %rdi
callq 0xc4e6c
movsd %xmm0, 0xa0(%rbx,%r14,8)
incq %r14
jmp 0xc4a9d
movsd 0xb0(%rbx), %xmm0
maxsd 0xa8(%rbx), %xmm0
maxsd 0xa0(%rbx), %xmm0
mulsd 0x41c98(%rip), %xmm0    # 0x106780
divsd 0x3c728(%rip), %xmm0    # 0x101218
movsd %xmm0, 0x18(%rsp)
movq $0x3, 0xd0(%rbx)
andq $0x0, 0xc8(%rbx)
pushq $0x2
popq %r15
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
xorl %r14d, %r14d
movq %rbp, 0x20(%rsp)
cmpq $0x18, %r12
je 0xc4d93
movq %r15, 0x38(%rsp)
leaq 0x1(%r15), %r13
leaq 0x88(%rsp), %rdi
movq %rbp, %rsi
movq %rdi, %rbp
movq %r13, %rdx
callq 0xc4e8e
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0xc4ea6
movq 0x8(%rsp), %rdx
addq %r14, %rdx
movq %rdx, 0x8(%rsp)
leaq 0x48(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xc5222
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc4ed0
movq %rbp, %rdi
callq 0xc4ee8
movq 0x8(%rsp), %rax
movsd %xmm0, 0xa0(%rbx,%rax,8)
cmpq $0x3, 0xd0(%rbx)
jne 0xc4bba
cvtsi2sd %r13, %xmm1
mulsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xc4bba
movq %r14, 0xd0(%rbx)
movq %rax, 0x70(%rbx,%r12)
cmpq %rax, %r14
jne 0xc4bcb
leaq 0x48(%rsp), %r15
jmp 0xc4c2b
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xc5222
movq 0x8(%rsp), %rdx
leaq 0x48(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xc5222
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xc4f1a
movq 0x8(%rsp), %rax
movsd 0xa0(%rbx,%r12), %xmm0
movsd 0xa0(%rbx,%rax,8), %xmm1
movsd %xmm1, 0xa0(%rbx,%r12)
movsd %xmm0, 0xa0(%rbx,%rax,8)
incq 0x10(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xc5222
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc4ed0
movq %rbp, %rdi
leaq (%rbx,%r12), %rbp
addq $0x48, %rbp
movq %rbp, %rsi
leaq 0x40(%rsp), %rdx
callq 0xc4f2c
movsd 0x40(%rsp), %xmm0
movq %r12, 0x28(%rsp)
movsd %xmm0, (%rbx,%r12,4)
andpd 0x37428(%rip), %xmm0    # 0xfc0a0
ucomisd 0xc8(%rbx), %xmm0
jbe 0xc4c8a
movsd %xmm0, 0xc8(%rbx)
leaq 0x48(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq 0x38(%rsp), %r15
movq %r15, %rcx
callq 0xc4f78
leaq 0xd0(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xc5222
leaq 0x88(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xc4ed0
leaq 0x1(%r14), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %r12
leaq (%rbx,%r12), %rcx
addq $0x90, %rcx
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xc4f98
leaq 0xf8(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xc6aac
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0xc511a
movq 0x48(%rsp), %rax
movq %rax, 0x88(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, 0x98(%rsp)
leaq 0x70(%rsp), %rax
movupd (%rax), %xmm0
leaq 0xb0(%rsp), %rax
movupd %xmm0, (%rax)
movq 0x80(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0xd0(%rsp), %r14
movq %r14, %rdi
movq 0x20(%rsp), %rbp
movq %rbp, %rsi
movq %r15, %rdx
callq 0xc4e8e
movq %r14, %rdi
movq %r13, %rsi
callq 0xc5132
addq $0x8, %r12
decq %r15
movq 0x30(%rsp), %r14
jmp 0xc4b21
leaq 0x60(%rbx), %r14
pushq $0x3
popq %rsi
movq %r14, %rdi
callq 0xc515a
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0xc4dc0
movl 0x70(%rbx,%r15,8), %edx
movq %r14, %rdi
movl %r15d, %esi
callq 0xc516c
incq %r15
jmp 0xc4da5
movq 0x10(%rsp), %rax
andl $0x1, %eax
negq %rax
orq $0x1, %rax
movq %rax, 0xd8(%rbx)
movb $0x1, 0xb8(%rbx)
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq